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

Go to the source code of this file.
Functions | |
| void | usage () |
| void | play () |
| int | main (int argc, char **argv) |
| void | afterPlaying (void *clientData) |
Variables | |
| UsageEnvironment * | env |
| char const * | inputFileName = "test.mpg" |
| char const * | remoteStreamName = "test.sdp" |
| MPEG1or2Demux * | mpegDemux |
| FramedSource * | audioSource |
| FramedSource * | videoSource |
| RTPSink * | audioSink |
| RTPSink * | videoSink |
| char const * | programName |
| Boolean | iFramesOnly = False |
| void afterPlaying | ( | void * | clientData | ) |
Definition at line 140 of file testMPEG1or2AudioVideoToDarwin.cpp.
References audioSink, audioSource, Medium::close(), env, FramedSource::isCurrentlyAwaitingData(), mpegDemux, play(), MediaSink::stopPlaying(), videoSink, and videoSource.
00140 { 00141 // One of the sinks has ended playing. 00142 // Check whether any of the sources have a pending read. If so, 00143 // wait until its sink ends playing also: 00144 if (audioSource->isCurrentlyAwaitingData() 00145 || videoSource->isCurrentlyAwaitingData()) return; 00146 00147 // Now that both sinks have ended, close both input sources, 00148 // and start playing again: 00149 *env << "...done reading from file\n"; 00150 00151 audioSink->stopPlaying(); 00152 videoSink->stopPlaying(); 00153 // ensures that both are shut down 00154 Medium::close(audioSource); 00155 Medium::close(videoSource); 00156 Medium::close(mpegDemux); 00157 // Note: This also closes the input file that this source read from. 00158 00159 // Start playing once again: 00160 play(); 00161 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 57 of file testMPEG1or2AudioVideoToDarwin.cpp.
References DarwinInjector::addStream(), audioRTCP, audioSink, MPEG1or2VideoRTPSink::createNew(), RTCPInstance::createNew(), MPEG1or2AudioRTPSink::createNew(), DarwinInjector::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, UsageEnvironment::getResultMsg(), NULL, play(), programName, remoteStreamName, rtcpGroupsockAudio, rtcpGroupsockVideo, rtpGroupsockAudio, rtpGroupsockVideo, DarwinInjector::setDestination(), UsageEnvironment::taskScheduler(), usage(), videoRTCP, and videoSink.
00057 { 00058 // Begin by setting up our usage environment: 00059 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00060 env = BasicUsageEnvironment::createNew(*scheduler); 00061 00062 // Parse command-line arguments: 00063 programName = argv[0]; 00064 if (argc != 2) usage(); 00065 char const* dssNameOrAddress = argv[1]; 00066 00067 // Create a 'Darwin injector' object: 00068 DarwinInjector* injector = DarwinInjector::createNew(*env, programName); 00069 00071 // Create 'groupsocks' for RTP and RTCP. 00072 // (Note: Because we will actually be streaming through a remote Darwin server, 00073 // via TCP, we just use dummy destination addresses, port numbers, and TTLs here.) 00074 struct in_addr dummyDestAddress; 00075 dummyDestAddress.s_addr = 0; 00076 Groupsock rtpGroupsockAudio(*env, dummyDestAddress, 0, 0); 00077 Groupsock rtcpGroupsockAudio(*env, dummyDestAddress, 0, 0); 00078 00079 // Create a 'MPEG Audio RTP' sink from the RTP 'groupsock': 00080 audioSink = MPEG1or2AudioRTPSink::createNew(*env, &rtpGroupsockAudio); 00081 00082 // Create (and start) a 'RTCP instance' for this RTP sink: 00083 const unsigned estimatedSessionBandwidthAudio = 160; // in kbps; for RTCP b/w share 00084 const unsigned maxCNAMElen = 100; 00085 unsigned char CNAME[maxCNAMElen+1]; 00086 gethostname((char*)CNAME, maxCNAMElen); 00087 CNAME[maxCNAMElen] = '\0'; // just in case 00088 RTCPInstance* audioRTCP = 00089 RTCPInstance::createNew(*env, &rtcpGroupsockAudio, 00090 estimatedSessionBandwidthAudio, CNAME, 00091 audioSink, NULL /* we're a server */); 00092 // Note: This starts RTCP running automatically 00093 00094 // Add these to our 'Darwin injector': 00095 injector->addStream(audioSink, audioRTCP); 00097 00099 // Create 'groupsocks' for RTP and RTCP. 00100 // (Note: Because we will actually be streaming through a remote Darwin server, 00101 // via TCP, we just use dummy destination addresses, port numbers, and TTLs here.) 00102 Groupsock rtpGroupsockVideo(*env, dummyDestAddress, 0, 0); 00103 Groupsock rtcpGroupsockVideo(*env, dummyDestAddress, 0, 0); 00104 00105 // Create a 'MPEG Video RTP' sink from the RTP 'groupsock': 00106 videoSink = MPEG1or2VideoRTPSink::createNew(*env, &rtpGroupsockVideo); 00107 00108 // Create (and start) a 'RTCP instance' for this RTP sink: 00109 const unsigned estimatedSessionBandwidthVideo = 4500; // in kbps; for RTCP b/w share 00110 RTCPInstance* videoRTCP = 00111 RTCPInstance::createNew(*env, &rtcpGroupsockVideo, 00112 estimatedSessionBandwidthVideo, CNAME, 00113 videoSink, NULL /* we're a server */); 00114 // Note: This starts RTCP running automatically 00115 00116 // Add these to our 'Darwin injector': 00117 injector->addStream(videoSink, videoRTCP); 00119 00120 // Next, specify the destination Darwin Streaming Server: 00121 if (!injector->setDestination(dssNameOrAddress, remoteStreamName, 00122 programName, "LIVE555 Streaming Media")) { 00123 *env << "injector->setDestination() failed: " 00124 << env->getResultMsg() << "\n"; 00125 exit(1); 00126 } 00127 00128 *env << "Play this stream (from the Darwin Streaming Server) using the URL:\n" 00129 << "\trtsp://" << dssNameOrAddress << "/" << remoteStreamName << "\n"; 00130 00131 // Finally, start the streaming: 00132 *env << "Beginning streaming...\n"; 00133 play(); 00134 00135 env->taskScheduler().doEventLoop(); // does not return 00136 00137 return 0; // only to prevent compiler warning 00138 }
| void play | ( | ) |
| void usage | ( | ) |
Definition at line 49 of file testMPEG1or2AudioVideoToDarwin.cpp.
References env, and programName.
00049 { 00050 *env << "usage: " << programName 00051 << " <Darwin Streaming Server name or IP address>\n"; 00052 exit(1); 00053 }
Definition at line 40 of file testMPEG1or2AudioVideoToDarwin.cpp.
Definition at line 38 of file testMPEG1or2AudioVideoToDarwin.cpp.
Definition at line 34 of file testMPEG1or2AudioVideoToDarwin.cpp.
Definition at line 47 of file testMPEG1or2AudioVideoToDarwin.cpp.
| char const* inputFileName = "test.mpg" |
Definition at line 35 of file testMPEG1or2AudioVideoToDarwin.cpp.
Definition at line 37 of file testMPEG1or2AudioVideoToDarwin.cpp.
| char const* programName |
Definition at line 43 of file testMPEG1or2AudioVideoToDarwin.cpp.
| char const* remoteStreamName = "test.sdp" |
Definition at line 41 of file testMPEG1or2AudioVideoToDarwin.cpp.
Definition at line 39 of file testMPEG1or2AudioVideoToDarwin.cpp.
1.5.2