Frame.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: Frame.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef __Frame_hpp__ 00045 #define __Frame_hpp__ 00046 00047 #include "global.hpp" 00048 00049 #include "IO.hpp" 00050 00051 00063 class Frame { 00064 00065 public: 00066 00067 // the frame types 00068 typedef enum { I_VOP, P_VOP, B_VOP, S_VOP, NN_VOP, YUV_VOP, RGB_VOP, 00069 MP3_AUDIO, AAC_AUDIO, RAW_AUDIO, VORBIS_AUDIO, 00070 HEADER_VOP, ERROR_VOP, UNKNOWN_VOP} FrameType, VOP_TYPE; 00071 00072 static const char *VOPTypeToChar(VOP_TYPE t) { 00073 static const char *VOP_CHAR[] = {"I_VOP", "P_VOP", "B_VOP", "S_VOP", "NN_VOP", "YUV_VOP", "RGB_VOP", 00074 "MP3_AUDIO", "AAC_AUDIO", "RAW_AUDIO", "VORBIS_AUDIO", 00075 "HEADER_VOP", "ERROR_VOP", "UNKNOWN_VOP"}; 00076 return VOP_CHAR[t]; 00077 } 00078 00079 Frame(FrameType t); 00080 00081 // concrete methods 00082 void setType(FrameType t) { 00083 if(accessUnit) accessUnit->frameType = (u32)t; 00084 } 00085 00086 FrameType getType() const { 00087 return (accessUnit? (FrameType)accessUnit->frameType: ERROR_VOP); 00088 } 00089 00091 u32 getMediaTimeScale() const { 00092 return mediaTimeScale; 00093 } 00094 00096 void setMediaTimeScale(u32 uiMediaTimeScale) { 00097 mediaTimeScale = uiMediaTimeScale; 00098 } 00099 00103 bool setAU(AU * au, bool detectType = true); 00104 00109 bool unsetAU(); 00110 00111 00112 AU *getAU() const { return accessUnit; }; 00113 00114 void setAUy(u8 *y) { accessUnit->y = y; }; 00115 void setAUu(u8 *u) { accessUnit->u = u; }; 00116 void setAUv(u8 *v) { accessUnit->v = v; }; 00117 00118 /* this codecID should correlate to the according ESInfo->getStreamID() */ 00119 void setCodecID(u32 id) { codecID = id; }; 00120 00121 /* this track ID should correlate to the according ESInfo->getStreamID() */ 00122 u32 getCodecID() { return codecID; }; 00123 00124 /* this streamID should correlate to the according ESInfo->getStreamID() */ 00125 void setStreamID(u32 id) { streamID = id; }; 00126 00127 /* this track ID should correlate to the according ESInfo->getStreamID() */ 00128 u32 getStreamID() { return streamID; }; 00129 00130 /* used by ESSynchronizer, so DataChannel will drop this frame after returning from adaptor chain. 00131 * further, DataChannel will set this for every frame before it is passed to the DataSinks, 00132 * after being sent to all outputs, it's deleted by the DataChannel. 00133 *so if you have some buffering output, make sure to unmark it and delete it on your own! (eg. network writers, muxers,...) */ 00134 void markForDelete(bool yes=true) { markedForDelete = yes; }; 00135 00136 /* DataChannel will drop this frame after returning from adaptor chain, or after passing to the DataSinks */ 00137 bool isMarkedForDelete() { return markedForDelete; }; 00138 00139 // virtual methods 00140 virtual ~ Frame(); 00141 00146 virtual FrameType detectFrameType() { return UNKNOWN_VOP; }; 00147 00148 protected: 00149 00150 AU *accessUnit; 00151 00152 u32 codecID; 00153 00154 u32 streamID; 00155 00156 u32 mediaTimeScale; 00157 00158 bool markedForDelete; 00159 }; 00160 00161 #endif // __Frame_hpp__