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

Go to the source code of this file.
Functions | |
| void | play () |
| int | main (int argc, char **argv) |
| void | afterPlaying (void *) |
Variables | |
| UsageEnvironment * | env |
| char const * | inputFileName = "test.amr" |
| AMRAudioFileSource * | audioSource |
| RTPSink * | audioSink |
| void afterPlaying | ( | void * | ) |
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 32 of file testAMRAudioStreamer.cpp.
References RTSPServer::addServerMediaSession(), ServerMediaSession::addSubsession(), audioSink, chooseRandomIPv4SSMAddress(), PassiveServerMediaSubsession::createNew(), ServerMediaSession::createNew(), RTSPServer::createNew(), RTCPInstance::createNew(), AMRAudioRTPSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, UsageEnvironment::getResultMsg(), inputFileName, Groupsock::multicastSendOnly(), NULL, play(), rtspServer, RTSPServer::rtspURL(), UsageEnvironment::taskScheduler(), and True.
00032 { 00033 // Begin by setting up our usage environment: 00034 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00035 env = BasicUsageEnvironment::createNew(*scheduler); 00036 00037 // Create 'groupsocks' for RTP and RTCP: 00038 struct in_addr destinationAddress; 00039 destinationAddress.s_addr = chooseRandomIPv4SSMAddress(*env); 00040 // Note: This is a multicast address. If you wish instead to stream 00041 // using unicast, then you should use the "testOnDemandRTSPServer" 00042 // test program - not this test program - as a model. 00043 00044 const unsigned short rtpPortNum = 16666; 00045 const unsigned short rtcpPortNum = rtpPortNum+1; 00046 const unsigned char ttl = 255; 00047 00048 const Port rtpPort(rtpPortNum); 00049 const Port rtcpPort(rtcpPortNum); 00050 00051 Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl); 00052 rtpGroupsock.multicastSendOnly(); // we're a SSM source 00053 Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl); 00054 rtcpGroupsock.multicastSendOnly(); // we're a SSM source 00055 00056 // Create a 'AMR Audio RTP' sink from the RTP 'groupsock': 00057 audioSink = AMRAudioRTPSink::createNew(*env, &rtpGroupsock, 96); 00058 00059 // Create (and start) a 'RTCP instance' for this RTP sink: 00060 const unsigned estimatedSessionBandwidth = 10; // in kbps; for RTCP b/w share 00061 const unsigned maxCNAMElen = 100; 00062 unsigned char CNAME[maxCNAMElen+1]; 00063 gethostname((char*)CNAME, maxCNAMElen); 00064 CNAME[maxCNAMElen] = '\0'; // just in case 00065 RTCPInstance* rtcp 00066 = RTCPInstance::createNew(*env, &rtcpGroupsock, 00067 estimatedSessionBandwidth, CNAME, 00068 audioSink, NULL /* we're a server */, 00069 True /* we're a SSM source */); 00070 // Note: This starts RTCP running automatically 00071 00072 // Create and start a RTSP server to serve this stream. 00073 RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554); 00074 if (rtspServer == NULL) { 00075 *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n"; 00076 exit(1); 00077 } 00078 ServerMediaSession* sms 00079 = ServerMediaSession::createNew(*env, "testStream", inputFileName, 00080 "Session streamed by \"testAMRAudioStreamer\"", 00081 True /*SSM*/); 00082 sms->addSubsession(PassiveServerMediaSubsession::createNew(*audioSink, rtcp)); 00083 rtspServer->addServerMediaSession(sms); 00084 00085 char* url = rtspServer->rtspURL(sms); 00086 *env << "Play this stream using the URL \"" << url << "\"\n"; 00087 delete[] url; 00088 00089 // Start the streaming: 00090 *env << "Beginning streaming...\n"; 00091 play(); 00092 00093 env->taskScheduler().doEventLoop(); // does not return 00094 00095 return 0; // only to prevent compiler warning 00096 }
| void play | ( | ) |
Definition at line 108 of file testAMRAudioStreamer.cpp.
References afterPlaying(), audioSink, audioSource, AMRAudioFileSource::createNew(), env, exit, UsageEnvironment::getResultMsg(), inputFileName, NULL, and MediaSink::startPlaying().
Referenced by afterPlaying(), and main().
00108 { 00109 // Open the input file as an 'AMR audio file source': 00110 AMRAudioFileSource* audioSource 00111 = AMRAudioFileSource::createNew(*env, inputFileName); 00112 if (audioSource == NULL) { 00113 *env << "Unable to open file \"" << inputFileName 00114 << "\" as an AMR audio file source: " 00115 << env->getResultMsg() << "\n"; 00116 exit(1); 00117 } 00118 00119 // Finally, start playing: 00120 *env << "Beginning to read from file...\n"; 00121 audioSink->startPlaying(*audioSource, afterPlaying, audioSink); 00122 }
Definition at line 28 of file testAMRAudioStreamer.cpp.
Referenced by afterPlaying(), main(), and play().
Definition at line 27 of file testAMRAudioStreamer.cpp.
Referenced by afterPlaying(), MPEG1or2DemuxedServerMediaSubsession::createNewRTPSink(), AC3AudioFileServerMediaSubsession::createNewRTPSink(), and play().
Definition at line 25 of file testAMRAudioStreamer.cpp.
| char const* inputFileName = "test.amr" |
1.5.2