#include "liveMedia.hh"#include "BasicUsageEnvironment.hh"Include dependency graph for testMPEG4VideoToDarwin.cpp:

Go to the source code of this file.
Functions | |
| void | usage () |
| Boolean | awaitConfigInfo (RTPSink *sink) |
| void | play () |
| int | main (int argc, char **argv) |
| void | afterPlaying (void *clientData) |
| static void | checkForAuxSDPLine (void *clientData) |
Variables | |
| UsageEnvironment * | env |
| char const * | inputFileName = "test.m4e" |
| char const * | remoteStreamName = "test.sdp" |
| MPEG4VideoStreamFramer * | videoSource |
| RTPSink * | videoSink |
| char const * | programName |
| static char | doneFlag = 0 |
| void afterPlaying | ( | void * | clientData | ) |
Definition at line 121 of file testMPEG4VideoToDarwin.cpp.
References Medium::close(), env, play(), and videoSource.
00121 { 00122 *env << "...done reading from file\n"; 00123 00124 Medium::close(videoSource); 00125 // Note: This also closes the input file that this source read from. 00126 00127 // Start playing once again: 00128 play(); 00129 }
Definition at line 166 of file testMPEG4VideoToDarwin.cpp.
References RTPSink::auxSDPLine(), checkForAuxSDPLine(), TaskScheduler::doEventLoop(), env, NULL, and UsageEnvironment::taskScheduler().
Referenced by main().
00166 { 00167 // Check whether the sink's 'auxSDPLine()' is ready: 00168 checkForAuxSDPLine(sink); 00169 00170 env->taskScheduler().doEventLoop(&doneFlag); 00171 00172 char const* auxSDPLine = sink->auxSDPLine(); 00173 return auxSDPLine != NULL; 00174 }
| static void checkForAuxSDPLine | ( | void * | clientData | ) | [static] |
Definition at line 153 of file testMPEG4VideoToDarwin.cpp.
References RTPSink::auxSDPLine(), checkForAuxSDPLine(), env, NULL, TaskScheduler::scheduleDelayedTask(), and UsageEnvironment::taskScheduler().
00153 { 00154 RTPSink* sink = (RTPSink*)clientData; 00155 if (sink->auxSDPLine() != NULL) { 00156 // Signal the event loop that we're done: 00157 doneFlag = ~0; 00158 } else { 00159 // No luck yet. Try again, after a brief delay: 00160 int uSecsToDelay = 100000; // 100 ms 00161 env->taskScheduler().scheduleDelayedTask(uSecsToDelay, 00162 (TaskFunc*)checkForAuxSDPLine, sink); 00163 } 00164 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 50 of file testMPEG4VideoToDarwin.cpp.
References DarwinInjector::addStream(), awaitConfigInfo(), RTCPInstance::createNew(), MPEG4ESVideoRTPSink::createNew(), DarwinInjector::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, UsageEnvironment::getResultMsg(), NULL, play(), programName, remoteStreamName, rtcpGroupsockVideo, rtpGroupsockVideo, DarwinInjector::setDestination(), UsageEnvironment::taskScheduler(), usage(), videoRTCP, and videoSink.
00050 { 00051 // Begin by setting up our usage environment: 00052 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00053 env = BasicUsageEnvironment::createNew(*scheduler); 00054 00055 // Parse command-line arguments: 00056 programName = argv[0]; 00057 if (argc != 2) usage(); 00058 char const* dssNameOrAddress = argv[1]; 00059 00060 // Create a 'Darwin injector' object: 00061 DarwinInjector* injector = DarwinInjector::createNew(*env, programName); 00062 00063 // Create 'groupsocks' for RTP and RTCP. 00064 // (Note: Because we will actually be streaming through a remote Darwin server, 00065 // via TCP, we just use dummy destination addresses, port numbers, and TTLs here.) 00066 struct in_addr dummyDestAddress; 00067 dummyDestAddress.s_addr = 0; 00068 Groupsock rtpGroupsockVideo(*env, dummyDestAddress, 0, 0); 00069 Groupsock rtcpGroupsockVideo(*env, dummyDestAddress, 0, 0); 00070 00071 // Create a 'MPEG-4 Video RTP' sink from the RTP 'groupsock': 00072 videoSink = MPEG4ESVideoRTPSink::createNew(*env, &rtpGroupsockVideo, 96); 00073 00074 // HACK, specifically for MPEG-4 video: 00075 // Before we can use this RTP sink, we need its MPEG-4 'config' information (for 00076 // use in the SDP description). Unfortunately, this config information depends 00077 // on the the properties of the MPEG-4 input data. Therefore, we need to start 00078 // 'playing' this RTP sink from the input source now, and wait until we get 00079 // the needed config information, before continuing: 00080 // that we need: 00081 *env << "Beginning streaming...\n"; 00082 play(); 00083 00084 if (!awaitConfigInfo(videoSink)) { 00085 *env << "Failed to get MPEG-4 'config' information from input file: " 00086 << env->getResultMsg() << "\n"; 00087 exit(1); 00088 } 00089 00090 // Create (and start) a 'RTCP instance' for this RTP sink: 00091 const unsigned estimatedSessionBandwidthVideo = 500; // in kbps; for RTCP b/w share 00092 const unsigned maxCNAMElen = 100; 00093 unsigned char CNAME[maxCNAMElen+1]; 00094 gethostname((char*)CNAME, maxCNAMElen); 00095 CNAME[maxCNAMElen] = '\0'; // just in case 00096 RTCPInstance* videoRTCP = 00097 RTCPInstance::createNew(*env, &rtcpGroupsockVideo, 00098 estimatedSessionBandwidthVideo, CNAME, 00099 videoSink, NULL /* we're a server */); 00100 // Note: This starts RTCP running automatically 00101 00102 // Add these to our 'Darwin injector': 00103 injector->addStream(videoSink, videoRTCP); 00104 00105 // Next, specify the destination Darwin Streaming Server: 00106 if (!injector->setDestination(dssNameOrAddress, remoteStreamName, 00107 programName, "LIVE555 Streaming Media")) { 00108 *env << "injector->setDestination() failed: " 00109 << env->getResultMsg() << "\n"; 00110 exit(1); 00111 } 00112 00113 *env << "Play this stream (from the Darwin Streaming Server) using the URL:\n" 00114 << "\trtsp://" << dssNameOrAddress << "/" << remoteStreamName << "\n"; 00115 00116 env->taskScheduler().doEventLoop(); // does not return 00117 00118 return 0; // only to prevent compiler warning 00119 }
| void play | ( | ) |
| void usage | ( | ) |
Definition at line 41 of file testMPEG4VideoToDarwin.cpp.
References env, and programName.
00041 { 00042 *env << "usage: " << programName 00043 << " <Darwin Streaming Server name or IP address>\n"; 00044 exit(1); 00045 }
char doneFlag = 0 [static] |
Definition at line 151 of file testMPEG4VideoToDarwin.cpp.
Definition at line 33 of file testMPEG4VideoToDarwin.cpp.
| char const* inputFileName = "test.m4e" |
Definition at line 34 of file testMPEG4VideoToDarwin.cpp.
| char const* programName |
Definition at line 39 of file testMPEG4VideoToDarwin.cpp.
| char const* remoteStreamName = "test.sdp" |
Definition at line 35 of file testMPEG4VideoToDarwin.cpp.
Definition at line 37 of file testMPEG4VideoToDarwin.cpp.
Definition at line 36 of file testMPEG4VideoToDarwin.cpp.
1.5.2