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

Go to the source code of this file.
Data Structures | |
| struct | sessionState_t |
Functions | |
| void | afterPlaying (void *clientData) |
| int | main (int argc, char **argv) |
Variables | |
| sessionState_t | sessionState |
| UsageEnvironment * | env |
| 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 46 of file testMP3Receiver.cpp.
References afterPlaying(), Groupsock::changeDestinationParameters(), MP3FromADUSource::createNew(), MP3ADUdeinterleaver::createNew(), RTCPInstance::createNew(), MP3ADURTPSource::createNew(), MPEG1or2AudioRTPSource::createNew(), FileSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, NULL, our_inet_addr(), sessionState_t::rtcpInstance, sessionState, sessionState_t::sink, sessionState_t::source, MediaSink::startPlaying(), and UsageEnvironment::taskScheduler().
00046 { 00047 // Begin by setting up our usage environment: 00048 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00049 env = BasicUsageEnvironment::createNew(*scheduler); 00050 00051 // Create the data sink for 'stdout': 00052 sessionState.sink = FileSink::createNew(*env, "stdout"); 00053 // Note: The string "stdout" is handled as a special case. 00054 // A real file name could have been used instead. 00055 00056 // Create 'groupsocks' for RTP and RTCP: 00057 char const* sessionAddressStr 00058 #ifdef USE_SSM 00059 = "232.255.42.42"; 00060 #else 00061 = "239.255.42.42"; 00062 // Note: If the session is unicast rather than multicast, 00063 // then replace this string with "0.0.0.0" 00064 #endif 00065 const unsigned short rtpPortNum = 6666; 00066 const unsigned short rtcpPortNum = rtpPortNum+1; 00067 #ifndef USE_SSM 00068 const unsigned char ttl = 1; // low, in case routers don't admin scope 00069 #endif 00070 00071 struct in_addr sessionAddress; 00072 sessionAddress.s_addr = our_inet_addr(sessionAddressStr); 00073 const Port rtpPort(rtpPortNum); 00074 const Port rtcpPort(rtcpPortNum); 00075 00076 #ifdef USE_SSM 00077 char* sourceAddressStr = "aaa.bbb.ccc.ddd"; 00078 // replace this with the real source address 00079 struct in_addr sourceFilterAddress; 00080 sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr); 00081 00082 Groupsock rtpGroupsock(*env, sessionAddress, sourceFilterAddress, rtpPort); 00083 Groupsock rtcpGroupsock(*env, sessionAddress, sourceFilterAddress, rtcpPort); 00084 rtcpGroupsock.changeDestinationParameters(sourceFilterAddress,0,~0); 00085 // our RTCP "RR"s are sent back using unicast 00086 #else 00087 Groupsock rtpGroupsock(*env, sessionAddress, rtpPort, ttl); 00088 Groupsock rtcpGroupsock(*env, sessionAddress, rtcpPort, ttl); 00089 #endif 00090 00091 RTPSource* rtpSource; 00092 #ifndef STREAM_USING_ADUS 00093 // Create the data source: a "MPEG Audio RTP source" 00094 rtpSource = MPEG1or2AudioRTPSource::createNew(*env, &rtpGroupsock); 00095 #else 00096 // Create the data source: a "MP3 *ADU* RTP source" 00097 unsigned char rtpPayloadFormat = 96; // a dynamic payload type 00098 rtpSource 00099 = MP3ADURTPSource::createNew(*env, &rtpGroupsock, rtpPayloadFormat); 00100 #endif 00101 00102 // Create (and start) a 'RTCP instance' for the RTP source: 00103 const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share 00104 const unsigned maxCNAMElen = 100; 00105 unsigned char CNAME[maxCNAMElen+1]; 00106 gethostname((char*)CNAME, maxCNAMElen); 00107 CNAME[maxCNAMElen] = '\0'; // just in case 00108 sessionState.rtcpInstance 00109 = RTCPInstance::createNew(*env, &rtcpGroupsock, 00110 estimatedSessionBandwidth, CNAME, 00111 NULL /* we're a client */, rtpSource); 00112 // Note: This starts RTCP running automatically 00113 00114 sessionState.source = rtpSource; 00115 #ifdef STREAM_USING_ADUS 00116 // Add a filter that deinterleaves the ADUs after depacketizing them: 00117 sessionState.source 00118 = MP3ADUdeinterleaver::createNew(*env, sessionState.source); 00119 if (sessionState.source == NULL) { 00120 *env << "Unable to create an ADU deinterleaving filter for the source\n"; 00121 exit(1); 00122 } 00123 00124 // Add another filter that converts these ADUs to MP3s: 00125 sessionState.source 00126 = MP3FromADUSource::createNew(*env, sessionState.source); 00127 if (sessionState.source == NULL) { 00128 *env << "Unable to create an ADU->MP3 filter for the source\n"; 00129 exit(1); 00130 } 00131 #endif 00132 00133 // Finally, start receiving the multicast stream: 00134 *env << "Beginning receiving multicast stream...\n"; 00135 sessionState.sink->startPlaying(*sessionState.source, afterPlaying, NULL); 00136 00137 env->taskScheduler().doEventLoop(); // does not return 00138 00139 return 0; // only to prevent compiler warning 00140 }
Definition at line 44 of file testMP3Receiver.cpp.
| struct sessionState_t sessionState |
1.5.2