testProgs/testMPEG1or2ProgramToTransportStream.cpp File Reference

#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"

Include dependency graph for testMPEG1or2ProgramToTransportStream.cpp:

Go to the source code of this file.

Functions

void afterPlaying (void *clientData)
int main (int argc, char **argv)

Variables

char const * inputFileName = "in.mpg"
char const * outputFileName = "out.ts"
UsageEnvironmentenv


Function Documentation

void afterPlaying ( void *  clientData  ) 

Definition at line 98 of file testAMRAudioStreamer.cpp.

00098                                         {
00099   *env << "...done reading from file\n";
00100 
00101   audioSink->stopPlaying();
00102   Medium::close(audioSource);
00103   // Note that this also closes the input file that this source read from.
00104 
00105   play();
00106 }

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file testMPEG1or2ProgramToTransportStream.cpp.

References afterPlaying(), FileSink::createNew(), MPEG2TransportStreamFromPESSource::createNew(), MPEG1or2Demux::createNew(), ByteStreamFileSource::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, inputFileName, MPEG1or2Demux::newRawPESStream(), NULL, outputFileName, MediaSink::startPlaying(), and UsageEnvironment::taskScheduler().

00031                                 {
00032   // Begin by setting up our usage environment:
00033   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00034   env = BasicUsageEnvironment::createNew(*scheduler);
00035 
00036   // Open the input file as a 'byte-stream file source':
00037   FramedSource* inputSource = ByteStreamFileSource::createNew(*env, inputFileName);
00038   if (inputSource == NULL) {
00039     *env << "Unable to open file \"" << inputFileName
00040          << "\" as a byte-stream file source\n";
00041     exit(1);
00042   }
00043 
00044   // Create a MPEG demultiplexor that reads from that source.
00045   MPEG1or2Demux* baseDemultiplexor = MPEG1or2Demux::createNew(*env, inputSource);
00046 
00047   // Create, from this, a source that returns raw PES packets:
00048   MPEG1or2DemuxedElementaryStream* pesSource = baseDemultiplexor->newRawPESStream();
00049 
00050   // And, from this, a filter that converts to MPEG-2 Transport Stream frames:
00051   FramedSource* tsFrames
00052     = MPEG2TransportStreamFromPESSource::createNew(*env, pesSource);
00053 
00054   // Open the output file as a 'file sink':
00055   MediaSink* outputSink = FileSink::createNew(*env, outputFileName);
00056   if (outputSink == NULL) {
00057     *env << "Unable to open file \"" << outputFileName << "\" as a file sink\n";
00058     exit(1);
00059   }
00060 
00061   // Finally, start playing:
00062   *env << "Beginning to read...\n";
00063   outputSink->startPlaying(*tsFrames, afterPlaying, NULL);
00064 
00065   env->taskScheduler().doEventLoop(); // does not return
00066 
00067   return 0; // only to prevent compiler warning
00068 }


Variable Documentation

UsageEnvironment* env

Definition at line 29 of file testMPEG1or2ProgramToTransportStream.cpp.

char const* inputFileName = "in.mpg"

Definition at line 24 of file testMPEG1or2ProgramToTransportStream.cpp.

char const* outputFileName = "out.ts"

Definition at line 25 of file testMPEG1or2ProgramToTransportStream.cpp.


Generated on Tue Mar 25 14:38:48 2014 for live by  doxygen 1.5.2