testProgs/testMPEG2TransportReceiver.cpp File Reference

#include "liveMedia.hh"
#include "GroupsockHelper.hh"
#include "BasicUsageEnvironment.hh"

Include dependency graph for testMPEG2TransportReceiver.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
UsageEnvironmentenv


Function Documentation

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 41 of file testMPEG2TransportReceiver.cpp.

References afterPlaying(), Groupsock::changeDestinationParameters(), RTCPInstance::createNew(), SimpleRTPSource::createNew(), FileSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, False, NULL, our_inet_addr(), sessionState_t::rtcpInstance, sessionState, sessionState_t::sink, sessionState_t::source, MediaSink::startPlaying(), and UsageEnvironment::taskScheduler().

00041                                 {
00042   // Begin by setting up our usage environment:
00043   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00044   env = BasicUsageEnvironment::createNew(*scheduler);
00045 
00046   // Create the data sink for 'stdout':
00047   sessionState.sink = FileSink::createNew(*env, "stdout");
00048   // Note: The string "stdout" is handled as a special case.
00049   // A real file name could have been used instead.
00050 
00051   // Create 'groupsocks' for RTP and RTCP:
00052   char const* sessionAddressStr
00053 #ifdef USE_SSM
00054     = "232.255.42.42";
00055 #else
00056     = "239.255.42.42";
00057   // Note: If the session is unicast rather than multicast,
00058   // then replace this string with "0.0.0.0"
00059 #endif
00060   const unsigned short rtpPortNum = 1234;
00061   const unsigned short rtcpPortNum = rtpPortNum+1;
00062 #ifndef USE_SSM
00063   const unsigned char ttl = 1; // low, in case routers don't admin scope
00064 #endif
00065 
00066   struct in_addr sessionAddress;
00067   sessionAddress.s_addr = our_inet_addr(sessionAddressStr);
00068   const Port rtpPort(rtpPortNum);
00069   const Port rtcpPort(rtcpPortNum);
00070 
00071 #ifdef USE_SSM
00072   char* sourceAddressStr = "aaa.bbb.ccc.ddd";
00073                            // replace this with the real source address
00074   struct in_addr sourceFilterAddress;
00075   sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr);
00076 
00077   Groupsock rtpGroupsock(*env, sessionAddress, sourceFilterAddress, rtpPort);
00078   Groupsock rtcpGroupsock(*env, sessionAddress, sourceFilterAddress, rtcpPort);
00079   rtcpGroupsock.changeDestinationParameters(sourceFilterAddress,0,~0);
00080       // our RTCP "RR"s are sent back using unicast
00081 #else
00082   Groupsock rtpGroupsock(*env, sessionAddress, rtpPort, ttl);
00083   Groupsock rtcpGroupsock(*env, sessionAddress, rtcpPort, ttl);
00084 #endif
00085 
00086   // Create the data source: a "MPEG-2 TransportStream RTP source" (which uses a 'simple' RTP payload format):
00087   sessionState.source = SimpleRTPSource::createNew(*env, &rtpGroupsock, 33, 90000, "video/MP2T", 0, False /*no 'M' bit*/);
00088 
00089   // Create (and start) a 'RTCP instance' for the RTP source:
00090   const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share
00091   const unsigned maxCNAMElen = 100;
00092   unsigned char CNAME[maxCNAMElen+1];
00093   gethostname((char*)CNAME, maxCNAMElen);
00094   CNAME[maxCNAMElen] = '\0'; // just in case
00095   sessionState.rtcpInstance
00096     = RTCPInstance::createNew(*env, &rtcpGroupsock,
00097                               estimatedSessionBandwidth, CNAME,
00098                               NULL /* we're a client */, sessionState.source);
00099   // Note: This starts RTCP running automatically
00100 
00101   // Finally, start receiving the multicast stream:
00102   *env << "Beginning receiving multicast stream...\n";
00103   sessionState.sink->startPlaying(*sessionState.source, afterPlaying, NULL);
00104 
00105   env->taskScheduler().doEventLoop(); // does not return
00106 
00107   return 0; // only to prevent compiler warning
00108 }


Variable Documentation

UsageEnvironment* env

Definition at line 39 of file testMPEG2TransportReceiver.cpp.

struct sessionState_t sessionState


Generated on Tue Mar 25 14:38:50 2014 for live by  doxygen 1.5.2