ESInfo.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: ESInfo.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 PS_ELEMENTARYSTREAMINFO_HPP 00045 #define PS_ELEMENTARYSTREAMINFO_HPP 00046 00047 00048 #include "global.hpp" 00049 #include <assert.h> 00050 00051 #ifdef ISOMP4 00052 #include "ISOMP4ContainerFile.hpp" 00053 #include "ISOMovies.h" 00054 #include "avformat.h" 00055 #else 00056 //#include "ffMP4ContainerFile.hpp" 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #include "avformat.h" 00060 } 00061 #endif 00062 #endif 00063 00064 class ContainerInfo; 00065 class BitField; 00066 class ReferenceCounter; 00067 00068 00080 class ESInfo { 00081 public: 00088 ESInfo(u64 streamId, u32 streamtype, ContainerInfo * vob, u32 timeIncrement, 00089 u8 * encodeddecconf, u32 objtype, u32 bufsize, 00090 u32 avg, u32 maxBand, u32 timeScale, 00091 u64 duration, u32 size, bool complete=true, 00092 CodecID codec_id = CODEC_ID_NONE, float quality = 1.0); 00093 00094 virtual ~ESInfo(); 00095 00098 u32 getHeaders(u8 **pHeaders) const; 00099 00100 u64 getStreamId() const { 00101 return streamId; 00102 }; 00103 00105 const u8 *getEncodedDecoderConfig() const { 00106 return encodedDecoderConfig; 00107 }; 00108 00110 virtual void setEncodedDecoderConfig(u8 * enc); 00111 00113 void setDecoderConfig(const u8 * dec, int size); 00114 00115 u32 getObjectType() const { 00116 return objectType; 00117 }; 00118 00119 u32 getStreamType() const { 00120 return streamType; 00121 }; 00122 00123 u32 getBufferSize() const { 00124 return bufferSize; 00125 }; 00126 00127 /* bool openSucceeded() const { 00128 return handlerType != (u32) - 1; 00129 }; */ 00130 virtual u32 getHandlerType() const=0; 00131 00132 virtual bool isVisualStream() const=0; 00133 00134 virtual bool isAudioStream() const=0; 00135 00136 virtual bool isODStream() const=0; 00137 00138 virtual bool isSceneDescriptionStream() const=0; 00139 00140 virtual void generateDescriptionText() { strcpy(description,"Generic ESInfo");}; 00141 00142 const char *getDescriptionText() const { return description;}; 00143 00145 virtual ESInfo *clone(ContainerInfo * mp4)=0; 00146 00147 bool getCompleteState() const; 00148 00149 float getStreamQuality() const { return quality;}; 00150 00151 void setCompleteState(bool comp) { 00152 complete=comp; 00153 } 00154 00158 void setInput(const char *inp); 00159 00161 const char *getInput() const { 00162 return input; 00163 }; 00164 00165 /* @returns avg BW in Bits/sec */ 00166 u32 getAvgBandwidth() const { 00167 return avgBandwidth; 00168 }; 00172 void setAvgBandwidth(u32 uiBandwidth) { 00173 avgBandwidth = uiBandwidth; 00174 }; 00175 u32 getMaxBandwidth() const { 00176 return maxBandwidth; 00177 }; 00178 void setMaxBandwidth(u32 uiMaxBandwidth) { 00179 maxBandwidth = uiMaxBandwidth; 00180 }; 00182 u32 getMediaTimeScale() const { 00183 return mediaTimeScale; 00184 }; 00186 void setMediaTimeScale(u32 uiMediaTimeScale) { 00187 assert(uiMediaTimeScale>0); 00188 mediaTimeScale = uiMediaTimeScale; 00189 }; 00190 00192 u64 getDuration() const { 00193 return duration; 00194 }; 00195 void setDuration(u64 uiDuration); 00196 00198 u64 getDurationInMs() const { 00199 return (duration * 1000) / mediaTimeScale; 00200 }; 00201 u32 getOrigMediaSize() const { 00202 return mediaSize; 00203 }; 00204 00205 void setOrigMediaSize(u32 mediaSize) { 00206 this->mediaSize = mediaSize; 00207 }; 00208 00212 u32 getCurrentDemuxedMediaSize() const; 00213 00219 u32 getFrameNumber(double timeInSeconds, bool upround = true) const; 00220 00224 double getMediaTime(u32 frameNo) const; 00225 00228 void setVOPTimeIncrement(u32 ticks); 00229 00230 u32 getVOPTimeIncrement() const { 00231 return vopTimeIncrement; 00232 }; 00233 00235 u32 getNumberOfMediaSamples() const { 00236 if(vopTimeIncrement==0) 00237 return 0; 00238 return (duration/vopTimeIncrement); 00239 }; 00240 00241 ContainerInfo *getContainerInfo() { 00242 return vo; 00243 }; 00244 00245 bool getDecConfUpdated() const { return decConfUpdated;}; 00246 00247 void clearDecConfUpdated() { decConfUpdated=false;}; 00248 00250 bool enableFrameStatistic(); 00251 00252 /* frees an existing frame statistics object */ 00253 void disableFrameStatistic(); 00254 00255 BitField* getFrameStatistic(); 00256 00257 void setFrameStatistic(BitField*); 00258 00259 ReferenceCounter* getUsageCounter() { return usageCounter;}; 00260 00261 void setCloneCounter( ReferenceCounter* &ref); 00262 00263 ReferenceCounter* getCloneCounter() { return existingClones;} 00264 00265 void setCodecID(CodecID id) { 00266 codec_id = id; 00267 } 00268 00269 CodecID getCodecID() { 00270 return codec_id; 00271 } 00272 00274 bool destroy(); 00275 00276 protected: 00277 u64 streamId; 00278 u32 streamType; 00279 ContainerInfo *vo; 00281 char *input; 00282 u8 *encodedDecoderConfig; 00283 u32 objectType; 00284 u32 bufferSize; 00285 u32 avgBandwidth; 00286 u32 maxBandwidth; 00288 u32 mediaTimeScale; 00290 u64 duration; 00292 u32 mediaSize; 00293 u32 vopTimeIncrement; 00294 bool decConfUpdated; 00295 bool complete; 00296 BitField* frameStatistic; 00297 ReferenceCounter* usageCounter; 00299 ReferenceCounter* existingClones; 00302 CodecID codec_id; 00303 /* the quality of stream as determined by ffmpeg 00304 * Its a value between 1(good) and 31(bad) 00305 * Needed for transcoding. 00306 */ 00307 float quality; 00308 char description[MAX_STR_LEN]; 00309 00310 /* Language spoken or displayed in either audio or video */ 00311 char *Language; 00312 00313 private: 00314 bool loadInfo(char *file); 00315 00316 }; 00317 00318 #endif