EMIPLIB
|
00001 /* 00002 00003 This file is a part of EMIPLIB, the EDM Media over IP Library. 00004 00005 Copyright (C) 2006-2011 Hasselt University - Expertise Centre for 00006 Digital Media (EDM) (http://www.edm.uhasselt.be) 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00021 USA 00022 00023 */ 00024 00029 #ifndef MIPRAWVIDEOMESSAGE_H 00030 00031 #define MIPRAWVIDEOMESSAGE_H 00032 00033 #include "mipconfig.h" 00034 #include "mipvideomessage.h" 00035 #include "miptypes.h" 00036 #include "miptime.h" 00037 #include <string.h> 00038 00054 #define MIPRAWVIDEOMESSAGE_TYPE_YUV420P 0x00000001 00055 #define MIPRAWVIDEOMESSAGE_TYPE_YUYV 0x00000002 00056 #define MIPRAWVIDEOMESSAGE_TYPE_RGB24 0x00000004 00057 #define MIPRAWVIDEOMESSAGE_TYPE_RGB32 0x00000008 00058 00060 class EMIPLIB_IMPORTEXPORT MIPRawYUV420PVideoMessage : public MIPVideoMessage 00061 { 00062 public: 00071 MIPRawYUV420PVideoMessage(int width, int height, uint8_t *pData, bool deleteData) : MIPVideoMessage(true, MIPRAWVIDEOMESSAGE_TYPE_YUV420P, width, height) 00072 { m_pData = pData; m_deleteData = deleteData; } 00073 ~MIPRawYUV420PVideoMessage() { if (m_deleteData) delete [] m_pData; } 00074 00076 const uint8_t *getImageData() const { return m_pData; } 00077 00079 MIPMediaMessage *createCopy() const 00080 { 00081 size_t dataSize = (getWidth()*getHeight()*3)/2; 00082 uint8_t *pData = new uint8_t [dataSize]; 00083 00084 memcpy(pData, m_pData, dataSize); 00085 MIPMediaMessage *pMsg = new MIPRawYUV420PVideoMessage(getWidth(), getHeight(), pData, true); 00086 pMsg->copyMediaInfoFrom(*this); 00087 return pMsg; 00088 } 00089 private: 00090 bool m_deleteData; 00091 uint8_t *m_pData; 00092 }; 00093 00095 class EMIPLIB_IMPORTEXPORT MIPRawYUYVVideoMessage : public MIPVideoMessage 00096 { 00097 public: 00106 MIPRawYUYVVideoMessage(int width, int height, uint8_t *pData, bool deleteData) : MIPVideoMessage(true, MIPRAWVIDEOMESSAGE_TYPE_YUYV, width, height) 00107 { m_pData = pData; m_deleteData = deleteData; } 00108 ~MIPRawYUYVVideoMessage() { if (m_deleteData) delete [] m_pData; } 00109 00111 const uint8_t *getImageData() const { return m_pData; } 00112 00114 MIPMediaMessage *createCopy() const 00115 { 00116 size_t dataSize = getWidth()*getHeight()*2; 00117 uint8_t *pData = new uint8_t [dataSize]; 00118 00119 memcpy(pData, m_pData, dataSize); 00120 MIPMediaMessage *pMsg = new MIPRawYUYVVideoMessage(getWidth(), getHeight(), pData, true); 00121 pMsg->copyMediaInfoFrom(*this); 00122 return pMsg; 00123 } 00124 private: 00125 bool m_deleteData; 00126 uint8_t *m_pData; 00127 }; 00128 00130 class EMIPLIB_IMPORTEXPORT MIPRawRGBVideoMessage : public MIPVideoMessage 00131 { 00132 public: 00142 MIPRawRGBVideoMessage(int width, int height, uint8_t *pData, bool depth32, bool deleteData) : MIPVideoMessage(true, (depth32)?MIPRAWVIDEOMESSAGE_TYPE_RGB32:MIPRAWVIDEOMESSAGE_TYPE_RGB24, width, height) 00143 { m_pData = pData; m_deleteData = deleteData; m_depth32 = depth32; } 00144 ~MIPRawRGBVideoMessage() { if (m_deleteData) delete [] m_pData; } 00145 00147 const uint8_t *getImageData() const { return m_pData; } 00148 00150 bool is32Bit() const { return m_depth32; } 00151 00153 MIPMediaMessage *createCopy() const 00154 { 00155 size_t dataSize = getWidth()*getHeight(); 00156 00157 if (m_depth32) 00158 dataSize *= 4; 00159 else 00160 dataSize *= 3; 00161 00162 uint8_t *pData = new uint8_t [dataSize]; 00163 00164 memcpy(pData, m_pData, dataSize); 00165 MIPMediaMessage *pMsg = new MIPRawRGBVideoMessage(getWidth(), getHeight(), pData, m_depth32, true); 00166 pMsg->copyMediaInfoFrom(*this); 00167 return pMsg; 00168 } 00169 private: 00170 bool m_deleteData; 00171 uint8_t *m_pData; 00172 bool m_depth32; 00173 }; 00174 00175 #endif // MIPRAWVIDEOMESSAGE_H 00176