ContainerDemux Class Reference

is used for simple demultiplexing of mp4 streams, so adaptors can be easily applied for eg. <short description=""> More...

#include <ContainerDemux.hpp>

List of all members.


Static Public Member Functions

ContainerInfodemultiplex (ContainerInfo *&info, const char *outputDir, const Adaptor *visualAdaptor=NULL, bool omitHeader=false, bool deleteMP4=false, bool visualizeAdaptation=false)
 takes the info object and demultiplexes every ES into a separate file.
void demultiplexAndUpdateIO (ContainerInfo *&mp4Info, const char *outputDir, const Adaptor *visualAdaptor=NULL, bool omitHeader=false, bool deleteMP4=false, bool visualizeAdaptation=false)
 same as demultiplex(..) but the input descriptors are updated to point to the new input.
void adaptESInfo (ESInfo *es, const char *outputFile, Adaptor *adaptor=NULL, u32 startFrame=0u, u32 endFrame=4294967295u, bool omitHeader=false, bool visualize=false)
 adapts single ESInfo
void adaptESInfo (ESInfo *es, const char *outputFile, Adaptor *adaptor=NULL, double startSecond=0.0, double endSecond=-1.0, bool omitHeader=false, bool visualize=false)
 adapts single ESInfo
DataChannelcreateDataChannel (ESInfo *es, const char *outputFile, Adaptor *adaptor=NULL, u32 startFrame=0u, u32 endFrame=4294967295u, bool omitHeader=false, bool visualize=false)
 creates a DataChannel which is ready for immediate use.

Detailed Description

is used for simple demultiplexing of mp4 streams, so adaptors can be easily applied for eg. <short description="">

transcoding

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
ContainerDemux.hpp,v 1.9 2005/01/25 14:10:42 mkropfbe Exp

Definition at line 71 of file ContainerDemux.hpp.


Member Function Documentation

void ContainerDemux::adaptESInfo ESInfo es,
const char *  outputFile,
Adaptor adaptor = NULL,
double  startSecond = 0.0,
double  endSecond = -1.0,
bool  omitHeader = false,
bool  visualize = false
[static]
 

adapts single ESInfo

Parameters:
es with adaptor
adaptor. If
outputFile is set, the created output will be written to the file, otherwise DevNull will be used as output.
startSecond and
endSecond will not work with system files but only with demultiplexed es!
Definition at line 164 of file ContainerDemux.cpp.

References adaptESInfo(), and ESInfo::getFrameNumber().

00165 { 00166 assert(es); 00167 u32 startFrame=es->getFrameNumber(startSecond); 00168 u32 endFrame=4294967295u; //2^32-1 00169 if(endSecond > 0.0) 00170 endFrame=es->getFrameNumber(endSecond); 00171 ContainerDemux::adaptESInfo(es,outputFile,adaptor,(u32)startFrame,(u32)endFrame,omitHeader,visualize); 00172 }

void ContainerDemux::adaptESInfo ESInfo es,
const char *  outputFile,
Adaptor adaptor = NULL,
u32  startFrame = 0u,
u32  endFrame = 4294967295u,
bool  omitHeader = false,
bool  visualize = false
[static]
 

adapts single ESInfo

Parameters:
es with adaptor
adaptor. If
outputFile is set, the created output will be written to the file, otherwise DevNull will be used as output.
startFrame and
endFrame will not work with system files but only with demultiplexed es!
Definition at line 145 of file ContainerDemux.cpp.

References createDataChannel(), VThread::running(), VThread::start(), and VThread::wait().

Referenced by adaptESInfo().

00145 { 00146 assert(es); 00147 00148 DataChannel* dc = ContainerDemux::createDataChannel(es,outputFile,adaptor,startFrame,endFrame,omitHeader,visualize); 00149 if(!dc) 00150 return; 00151 00152 dc->start(); 00153 if(dc->running()) 00154 { 00155 dc->wait(); 00156 } 00157 delete dc; 00158 00159 }

DataChannel * ContainerDemux::createDataChannel ESInfo es,
const char *  outputFile,
Adaptor adaptor = NULL,
u32  startFrame = 0u,
u32  endFrame = 4294967295u,
bool  omitHeader = false,
bool  visualize = false
[static]
 

creates a DataChannel which is ready for immediate use.

A DataSink has been inserted and play was called for this DataSink. Access to the inserted DataSink is via id 0. Just start the returned DataChannel with dc->start(). Will return NULL if

Parameters:
es is NULL.
Definition at line 176 of file ContainerDemux.cpp.

References DataChannel::insert(), DataChannel::play(), DataChannel::setAdaptor(), IO::setEndFrameNumber(), IO::setToClosestIFrame(), and DataChannel::visualizeCaching().

Referenced by adaptESInfo().

00178 { 00179 assert(es); 00180 if(!es) // for release build where all asserts vanish 00181 return NULL; 00182 00183 IO* input = IOCreator::createInput(es, false); 00184 00185 input->setToClosestIFrame(startFrame); 00186 input->setEndFrameNumber(endFrame); 00187 IO* output=NULL; 00188 if(outputFile) 00189 output = new MPGStreamIO(es, outputFile, true, omitHeader); 00190 else 00191 output = new DevNull(); 00192 00193 DataSink* datasink = new DataSink(0, output, "127.0.0.1", 0, NULL); 00194 DataChannel* dc = new DataChannel(input, es); 00195 if(visualize) 00196 dc->visualizeCaching(); 00197 dc->setAdaptor(adaptor); 00198 dc->insert(datasink); 00199 dc->play(0, 0.0); 00200 return dc; 00201 }

ContainerInfo * ContainerDemux::demultiplex ContainerInfo *&  info,
const char *  outputDir,
const Adaptor visualAdaptor = NULL,
bool  omitHeader = false,
bool  deleteMP4 = false,
bool  visualizeAdaptation = false
[static]
 

takes the info object and demultiplexes every ES into a separate file.

A copy of the info object with updated input descriptors is returned. if outputDir is set to NULL, no output will be generated Only call this method with an .mp4 file as input. If an adaptor is set, each visualstream will be adapted with this adaptorDefinition at line 60 of file ContainerDemux.cpp.

References ContainerInfo::clone(), and demultiplexAndUpdateIO().

00063 { 00064 ContainerInfo * mp4New = mp4Info->clone(); 00065 ContainerDemux::demultiplexAndUpdateIO(mp4New, outputDir, visualAdaptor, omitHeader, 00066 deleteMP4, visualizeAdaptation); 00067 return mp4New; 00068 }

void ContainerDemux::demultiplexAndUpdateIO ContainerInfo *&  mp4Info,
const char *  outputDir,
const Adaptor visualAdaptor = NULL,
bool  omitHeader = false,
bool  deleteMP4 = false,
bool  visualizeAdaptation = false
[static]
 

same as demultiplex(..) but the input descriptors are updated to point to the new input.

Per default the MP4FILE is NOT DELETED! if outputDir is set to NULL, no output will be generated If an adaptor is set, each visualstream will be adapted with this adaptorDefinition at line 75 of file ContainerDemux.cpp.

References DataChannel::enableCaching(), IO::getCurrentFrameNumber(), DataChannel::getESInfo(), ContainerInfo::getESList(), DataChannel::getInput(), ContainerInfo::getLocalFile(), ESInfo::getNumberOfMediaSamples(), ESInfo::getVOPTimeIncrement(), VThread::running(), ESInfo::setCompleteState(), ESInfo::setDuration(), Adaptor::setESInfo(), VThread::start(), and VThread::wait().

Referenced by demultiplex(), MP7File::generateMP7Description(), and MP7File::writeVariationSet().

00079 { 00080 00081 list < ESInfo * > *es = mp4Info->getESList(); 00082 assert(es && es->size() > 0); 00083 list < ESInfo * >::iterator li = es->begin(); 00084 DataChannel **dc = new DataChannel *[es->size()]; 00085 for (int i = 0; i < (int) es->size(); i++) { 00086 // for each ES create a DataChannel, MP4IO will be used for reading 00087 dc[i] = new DataChannel(IOCreator::createInput((*li), false), (*li)); 00088 00089 char *out = dc[i]->enableCaching(omitHeader,outputDir); 00090 00091 (*li)->setInput(out); 00092 00093 delete[] out; 00094 00095 if ((*li)->isVisualStream() && visualAdaptor != NULL) { 00096 Adaptor* at=((Adaptor*)visualAdaptor)->clone(); 00097 at->setESInfo(*li); 00098 dc[i]->setAdaptor(at); 00099 } 00100 00101 if (visualizeAdaptation && (*li)->isVisualStream()) { 00102 dc[i]->visualizeCaching(); 00103 } 00104 00105 ++li; 00106 } 00107 00108 // rewind the iterator 00109 li = es->begin(); 00110 for (int j = 0; j < (int) es->size(); j++) { 00111 // start & wait for each thread to finish 00112 // -> ISOMP4 lib is not thread safe 00113 dc[j]->start(); 00114 if(dc[j]->running()) 00115 dc[j]->wait(); 00116 /* the stream may have contained empty frames, 00117 * so update the duration to avoid inconsistent 00118 * ESInfo::frameStatistics 00119 */ 00120 ESInfo *ess = (ESInfo *) dc[j]->getESInfo(); 00121 u32 essFrames = ess->getNumberOfMediaSamples(); 00122 u32 readFrames = dc[j]->getInput()->getCurrentFrameNumber(); 00123 if (readFrames != essFrames) { 00124 dprintf_full("ContainerDemux::demultiplexAndUpdateIO() stream %d: read %u frames, correcting ESInfo (was %u)\n", 00125 j, readFrames, essFrames); 00126 ess->setDuration((u64) readFrames * (u64) ess->getVOPTimeIncrement()); 00127 } 00128 ess->setCompleteState(true); 00129 delete dc[j]; 00130 } 00131 delete[] dc; 00132 // now delete the mp4file 00133 if (deleteMP4) { 00134 dprintf_full("ISOMP4ContainerFile::demultiplexAndUpdateIO: Deleting ISOMP4ContainerFile\r\n"); 00135 FILE *fp = fopen(mp4Info->getLocalFile(), "w"); 00136 00137 if (fp) { 00138 fclose(fp); 00139 remove(mp4Info->getLocalFile()); 00140 } 00141 } 00142 }


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