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

Go to the source code of this file.
Data Structures | |
| struct | sessionState_t |
Functions | |
| void | play () |
| int | main (int argc, char **argv) |
| void | afterPlaying (void *clientData) |
Variables | |
| Boolean const | isSSM = False |
| UsageEnvironment * | env |
| sessionState_t | sessionState |
| char const * | inputFileName = "test.mp3" |
| 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 64 of file testMP3Streamer.cpp.
References RTSPServer::addServerMediaSession(), ServerMediaSession::addSubsession(), PassiveServerMediaSubsession::createNew(), ServerMediaSession::createNew(), RTSPServer::createNew(), RTCPInstance::createNew(), MPEG1or2AudioRTPSink::createNew(), MP3ADURTPSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, UsageEnvironment::getResultMsg(), inputFileName, isSSM, Groupsock::multicastSendOnly(), NULL, our_inet_addr(), play(), sessionState_t::rtcpGroupsock, sessionState_t::rtcpInstance, sessionState_t::rtpGroupsock, rtspServer, RTSPServer::rtspURL(), sessionState, sessionState_t::sink, and UsageEnvironment::taskScheduler().
00064 { 00065 // Begin by setting up our usage environment: 00066 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00067 env = BasicUsageEnvironment::createNew(*scheduler); 00068 00069 // Create 'groupsocks' for RTP and RTCP: 00070 char const* destinationAddressStr 00071 #ifdef USE_SSM 00072 = "232.255.42.42"; 00073 #else 00074 = "239.255.42.42"; 00075 // Note: This is a multicast address. If you wish to stream using 00076 // unicast instead, then replace this string with the unicast address 00077 // of the (single) destination. (You may also need to make a similar 00078 // change to the receiver program.) 00079 #endif 00080 const unsigned short rtpPortNum = 6666; 00081 const unsigned short rtcpPortNum = rtpPortNum+1; 00082 const unsigned char ttl = 1; // low, in case routers don't admin scope 00083 00084 struct in_addr destinationAddress; 00085 destinationAddress.s_addr = our_inet_addr(destinationAddressStr); 00086 const Port rtpPort(rtpPortNum); 00087 const Port rtcpPort(rtcpPortNum); 00088 00089 sessionState.rtpGroupsock 00090 = new Groupsock(*env, destinationAddress, rtpPort, ttl); 00091 sessionState.rtcpGroupsock 00092 = new Groupsock(*env, destinationAddress, rtcpPort, ttl); 00093 #ifdef USE_SSM 00094 sessionState.rtpGroupsock->multicastSendOnly(); 00095 sessionState.rtcpGroupsock->multicastSendOnly(); 00096 #endif 00097 00098 // Create a 'MP3 RTP' sink from the RTP 'groupsock': 00099 #ifdef STREAM_USING_ADUS 00100 unsigned char rtpPayloadFormat = 96; // A dynamic payload format code 00101 sessionState.sink 00102 = MP3ADURTPSink::createNew(*env, sessionState.rtpGroupsock, 00103 rtpPayloadFormat); 00104 #else 00105 sessionState.sink 00106 = MPEG1or2AudioRTPSink::createNew(*env, sessionState.rtpGroupsock); 00107 #endif 00108 00109 // Create (and start) a 'RTCP instance' for this RTP sink: 00110 const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share 00111 const unsigned maxCNAMElen = 100; 00112 unsigned char CNAME[maxCNAMElen+1]; 00113 gethostname((char*)CNAME, maxCNAMElen); 00114 CNAME[maxCNAMElen] = '\0'; // just in case 00115 sessionState.rtcpInstance 00116 = RTCPInstance::createNew(*env, sessionState.rtcpGroupsock, 00117 estimatedSessionBandwidth, CNAME, 00118 sessionState.sink, NULL /* we're a server */, 00119 isSSM); 00120 // Note: This starts RTCP running automatically 00121 00122 #ifdef IMPLEMENT_RTSP_SERVER 00123 rtspServer = RTSPServer::createNew(*env); 00124 // Note that this (attempts to) start a server on the default RTSP server 00125 // port: 554. To use a different port number, add it as an extra 00126 // (optional) parameter to the "RTSPServer::createNew()" call above. 00127 if (rtspServer == NULL) { 00128 *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n"; 00129 exit(1); 00130 } 00131 ServerMediaSession* sms 00132 = ServerMediaSession::createNew(*env, "testStream", inputFileName, 00133 "Session streamed by \"testMP3Streamer\"", isSSM); 00134 sms->addSubsession(PassiveServerMediaSubsession::createNew(*sessionState.sink, sessionState.rtcpInstance)); 00135 rtspServer->addServerMediaSession(sms); 00136 00137 char* url = rtspServer->rtspURL(sms); 00138 *env << "Play this stream using the URL \"" << url << "\"\n"; 00139 delete[] url; 00140 #endif 00141 00142 play(); 00143 00144 env->taskScheduler().doEventLoop(); // does not return 00145 return 0; // only to prevent compiler warning 00146 }
| void play | ( | ) |
Definition at line 48 of file testMP3Streamer.cpp.
| char const* inputFileName = "test.mp3" |
Definition at line 60 of file testMP3Streamer.cpp.
Definition at line 37 of file testMP3Streamer.cpp.
| struct sessionState_t sessionState |
1.5.2