ESInfo Class Reference

Info object that describes one elementary stream <short description="">. More...

#include <ESInfo.hpp>

Inheritance diagram for ESInfo:

List of all members.

Public Member Functions

 ESInfo (u64 streamId, u32 streamtype, ContainerInfo *vob, u32 timeIncrement, u8 *encodeddecconf, u32 objtype, u32 bufsize, u32 avg, u32 maxBand, u32 timeScale, u64 duration, u32 size, bool complete=true, CodecID codec_id=CODEC_ID_NONE, float quality=1.0)
 creates an ESInfo object
u32 getHeaders (u8 **pHeaders) const
 returns the size of the header, returns 0 in case of error.
u64 getStreamId () const
const u8 * getEncodedDecoderConfig () const
 returns a pointer to the decode config
virtual void setEncodedDecoderConfig (u8 *enc)
 creates a shallow copy of enc
void setDecoderConfig (const u8 *dec, int size)
 encodes dec and deep-copies it
u32 getObjectType () const
u32 getStreamType () const
u32 getBufferSize () const
virtual u32 getHandlerType () const =0
virtual bool isVisualStream () const =0
virtual bool isAudioStream () const =0
virtual bool isODStream () const =0
virtual bool isSceneDescriptionStream () const =0
virtual void generateDescriptionText ()
const char * getDescriptionText () const
virtual ESInfoclone (ContainerInfo *mp4)=0
 creates a deep copy of the ES
bool getCompleteState () const
float getStreamQuality () const
void setCompleteState (bool comp)
void setInput (const char *inp)
 sets a deep copy of input at this object, input will be freed when the destructor is called
const char * getInput () const
u32 getAvgBandwidth () const
void setAvgBandwidth (u32 uiBandwidth)
 Needed in Adaptor classes.
u32 getMaxBandwidth () const
void setMaxBandwidth (u32 uiMaxBandwidth)
u32 getMediaTimeScale () const
 returns the timescale of the stream measured in ticks/second
void setMediaTimeScale (u32 uiMediaTimeScale)
 set the mediaTimeScale
u64 getDuration () const
 returns the duration of the ElementaryStream expressed in ticks
void setDuration (u64 uiDuration)
u64 getDurationInMs () const
 returns the duration of the media in ms
u32 getOrigMediaSize () const
void setOrigMediaSize (u32 mediaSize)
u32 getCurrentDemuxedMediaSize () const
 returns the size of the current media.
u32 getFrameNumber (double timeInSeconds, bool upround=true) const
 calculates the frame number for the given time stamp which is expressed in seconds
double getMediaTime (u32 frameNo) const
 Calculates media time in seconds from frame number.
void setVOPTimeIncrement (u32 ticks)
 updates the delta times between two consecutive frames in ticks
u32 getVOPTimeIncrement () const
u32 getNumberOfMediaSamples () const
ContainerInfogetContainerInfo ()
bool getDecConfUpdated () const
void clearDecConfUpdated ()
bool enableFrameStatistic ()
 creates a new frame statistic object.
void disableFrameStatistic ()
BitFieldgetFrameStatistic ()
void setFrameStatistic (BitField *)
ReferenceCountergetUsageCounter ()
void setCloneCounter (ReferenceCounter *&ref)
ReferenceCountergetCloneCounter ()
void setCodecID (CodecID id)
CodecID getCodecID ()
bool destroy ()
 deletes all locally stored files belonging to this object

Protected Attributes

u64 streamId
u32 streamType
ContainerInfovo
char * input
 input specifies a local file or an url string
u8 * encodedDecoderConfig
u32 objectType
u32 bufferSize
u32 avgBandwidth
u32 maxBandwidth
u32 mediaTimeScale
 the timescale of the media, in ticks/second
u64 duration
 the duration of the stream expressed in the medias timescale
u32 mediaSize
 the byteSize of the original ES
u32 vopTimeIncrement
bool decConfUpdated
bool complete
BitFieldframeStatistic
ReferenceCounterusageCounter
ReferenceCounterexistingClones
 stores the number of existing clones for this ESInfo including the original one
CodecID codec_id
 This is the codec id for the stream as provided by ffmpeg Cannot be used with ISOMP4.
float quality
char description [MAX_STR_LEN]
char * Language

Detailed Description

Info object that describes one elementary stream <short description="">.

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
ESInfo.hpp,v 1.24 2006/05/15 10:41:39 mkropfbe Exp

Definition at line 80 of file ESInfo.hpp.


Constructor & Destructor Documentation

ESInfo::ESInfo u64  streamId,
u32  streamtype,
ContainerInfo vob,
u32  timeIncrement,
u8 *  encodeddecconf,
u32  objtype,
u32  bufsize,
u32  avg,
u32  maxBand,
u32  timeScale,
u64  duration,
u32  size,
bool  complete = true,
CodecID  codec_id = CODEC_ID_NONE,
float  quality = 1.0
 

creates an ESInfo object

Parameters:
encodeddecconf is only shallow copied and freed in the destructor
avgBW and
maxBW specify the bandwidth of the given ES and are in Bits/sec !
Definition at line 58 of file ESInfo.cpp.

References codec_id, duration, existingClones, input, mediaSize, and mediaTimeScale.

00062 { 00063 dprintf_full("ESInfo::ESInfo created with duration %llu timeIncrement %u avgBW %u kbps\n", 00064 dur, timeIncrement,avgBand/1024); 00065 assert(timeScale>0); // otherwise div zero Bugs are possible 00066 description[0]='\0'; 00067 frameStatistic=NULL; 00068 decConfUpdated=false; 00069 input = NULL; 00070 streamId = streamid; 00071 vo = vob; 00072 encodedDecoderConfig = encodeddecconf; 00073 objectType = objtype; 00074 streamType = streamtype; 00075 bufferSize = bufsize; 00076 00077 avgBandwidth = avgBand; 00078 maxBandwidth = maxBand; 00079 mediaTimeScale = timeScale; 00080 duration = dur; 00081 mediaSize = size; 00082 vopTimeIncrement=timeIncrement; 00083 complete=comp; 00084 existingClones=NULL; 00085 usageCounter=new ReferenceCounter(); 00086 codec_id = codecID; 00087 quality = stQuality; 00088 generateDescriptionText(); 00089 }


Member Function Documentation

bool ESInfo::enableFrameStatistic  ) 
 

creates a new frame statistic object.

fails if already one exists Definition at line 237 of file ESInfo.cpp.

References getNumberOfMediaSamples().

Referenced by destroy(), RawStreamIO::open(), MPGStreamIO::open(), BufferedIO::open(), and RTSP::parseResponseDescribe().

00238 { 00239 dprintf_full("ESInfo::enableFrameStatistic\n"); 00240 if(frameStatistic==NULL) { 00241 frameStatistic=new BitField(getNumberOfMediaSamples(),false); 00242 return true; 00243 } 00244 return false; 00245 };

u32 ESInfo::getCurrentDemuxedMediaSize  )  const
 

returns the size of the current media.

Will also work for streams that are currently streamed to the diskDefinition at line 318 of file ESInfo.cpp.

References input.

00319 { 00320 if(!input) 00321 return 0; 00322 FILE* fp=fopen(this->input,"rb"); 00323 u32 res=0; 00324 if(fp) { 00325 fseek(fp,0,SEEK_END); 00326 long l=ftell(fp); 00327 fclose(fp); 00328 if(l>0) 00329 res=(u32)l; 00330 } 00331 return res; 00332 };

u32 ESInfo::getFrameNumber double  timeInSeconds,
bool  upround = true
const
 

calculates the frame number for the given time stamp which is expressed in seconds

Parameters:
timeInSeconds is a double, which will be mapped onto a frame number
upround forces ceil() or floor()
Returns:
the closest (up-rounded) framenumber, so second 2.25 with 25fps will lead to frame 56.25 ==> 57
Definition at line 214 of file ESInfo.cpp.

References mediaTimeScale.

Referenced by ContainerDemux::adaptESInfo().

00214 { 00215 // Example: 2.5 seconds, framerate is 25 00216 // the result is 25*2.5=37 00217 u32 result; 00218 if (upround) 00219 result=(u32)ceil(timeInSeconds*((double)mediaTimeScale)/((double)vopTimeIncrement)); 00220 else 00221 result=(u32)floor(timeInSeconds*((double)mediaTimeScale)/((double)vopTimeIncrement)); 00222 dprintf_full("ESInfo::getFrameNumber(%f) == No %i (rounded %s)\r\n",timeInSeconds,result,upround?"up":"down"); 00223 return result; 00224 };

u32 ESInfo::getHeaders u8 **  pHeaders  )  const
 

returns the size of the header, returns 0 in case of error.

If *pheaders is != NULL an assertion is thrown! Definition at line 158 of file ESInfo.cpp.

References SDP::decodeDecoderConfig().

Referenced by MPGStreamIO::setToFrameNumber(), and Rtp::writeFrame().

00159 { 00160 if (!encodedDecoderConfig) { 00161 dprintf_err("ESInfo::getHeaders No decoder Config found\n"); 00162 return 0; 00163 } 00164 assert( (*pHeaders) == NULL); 00165 int size = strlen((char *) encodedDecoderConfig); 00166 if (size < 1) { 00167 dprintf_err("ESInfo::getHeaders %llu: Failed to get EncodedDecoderConfig, got %s\n", 00168 streamId, encodedDecoderConfig); 00169 return 0; 00170 } 00171 00172 u8 *decConf = new u8[size / 2 + 1]; 00173 SDP::decodeDecoderConfig(decConf, encodedDecoderConfig, size); 00174 // problem: decoderConfig is some extended Header 00175 // we have some leading bytes, and then we have 00 00 01h, the start of the header 00176 // so search for this hex value 00177 int i = 0; 00178 u32 data = 65535; 00179 u32 offset = 0; 00180 // generic streams have different headers 00181 if (!isVisualStream() && !isAudioStream()) { 00182 i = size / 2; // do not change them 00183 } 00184 00185 while (i < size / 2 - 1 && (data & 0x00FFFFFF) != 1) { 00186 data <<= 8; 00187 data += decConf[i]; 00188 i++; 00189 } 00190 if ((data & 0x00FFFFFF) == 1) { // we read 2 zeros followed by a 1 00191 // found the header 00192 dprintf_full("ESInfo::getHeaders: Found header in decconf %x\n", data); 00193 // then set offset to point to the first 0 00194 // i points after the 1 -> header is 00 00 01 xx-> reduce by 3 00195 // 00 01 02 03 00 00 01 xx -> i=7 -> i=4 00196 offset = i - sizeof(data) + 1; 00197 } 00198 00199 *pHeaders= new u8[size / 2 - offset+1]; 00200 memcpy(*pHeaders, (decConf + offset), size / 2 - offset); 00201 (*pHeaders)[size / 2 - offset] = 0; 00202 dprintf_full 00203 ("ESInfo::getHeaders: Offset is %i, header size is %i first 4 bytes are %x %x %x %x\n", 00204 offset, (size/2-offset),decConf[offset], decConf[offset + 1], decConf[offset + 2], 00205 decConf[offset + 3]); 00206 00207 delete[] decConf; 00208 return size / 2 - offset; 00209 };

const char* ESInfo::getInput  )  const [inline]
 

Returns:
the file name of the elementary stream (or container stream)
Definition at line 161 of file ESInfo.hpp.

References input.

Referenced by MPGStreamIO::open(), and ProxySession::tearDown().

00161 { 00162 return input; 00163 };

double ESInfo::getMediaTime u32  frameNo  )  const
 

Calculates media time in seconds from frame number.

Returns 0.0 on error. Definition at line 227 of file ESInfo.cpp.

References mediaTimeScale.

00228 { 00229 if (!mediaTimeScale) { 00230 dprintf_err("ESInfo::getMediaTime(frameNo = %u) ERROR: mediaTimeScale is 0!\n", frameNo); 00231 return 0.0; 00232 } 00233 return (double) frameNo * (double) vopTimeIncrement / (double) mediaTimeScale; 00234 }

u32 ESInfo::getNumberOfMediaSamples  )  const [inline]
 

Returns:
number of frames this ES consists of
Definition at line 235 of file ESInfo.hpp.

Referenced by ContainerDemux::demultiplexAndUpdateIO(), enableFrameStatistic(), Rtp::getFrame(), ContainerInfo::loadFromCfgFile(), RawStreamIO::open(), MPGStreamIO::open(), BufferedIO::open(), MPGStreamIO::setToClosestIFrame(), and setVOPTimeIncrement().

00235 { 00236 if(vopTimeIncrement==0) 00237 return 0; 00238 return (duration/vopTimeIncrement); 00239 };

void ESInfo::setAvgBandwidth u32  uiBandwidth  )  [inline]
 

Needed in Adaptor classes.

Definition at line 172 of file ESInfo.hpp.

00172 { 00173 avgBandwidth = uiBandwidth; 00174 };


The documentation for this class was generated from the following files: