testProgs/testGSMStreamer.cpp File Reference

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

Include dependency graph for testGSMStreamer.cpp:

Go to the source code of this file.

Data Structures

struct  sessionState_t

Functions

void afterPlaying (void *clientData)
void play ()
int main (int argc, char **argv)

Variables

Boolean const isSSM = False
UsageEnvironmentenv
sessionState_t sessionState


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 62 of file testGSMStreamer.cpp.

References RTSPServer::addServerMediaSession(), ServerMediaSession::addSubsession(), PassiveServerMediaSubsession::createNew(), ServerMediaSession::createNew(), RTSPServer::createNew(), RTCPInstance::createNew(), GSMAudioRTPSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, UsageEnvironment::getResultMsg(), isSSM, Groupsock::multicastSendOnly(), NULL, our_inet_addr(), play(), sessionState_t::rtcpGroupsock, sessionState_t::rtcpInstance, sessionState_t::rtpGroupsock, rtspServer, RTSPServer::rtspURL(), sessionState, sessionState_t::sink, sms, and UsageEnvironment::taskScheduler().

00062                                 {
00063   // Begin by setting up our usage environment:
00064   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00065   env = BasicUsageEnvironment::createNew(*scheduler);
00066 
00067   // Create 'groupsocks' for RTP and RTCP:
00068   char* destinationAddressStr
00069 #ifdef USE_SSM
00070     = "232.255.42.42";
00071 #else
00072     = "239.255.42.42";
00073   // Note: This is a multicast address.  If you wish to stream using
00074   // unicast instead, then replace this string with the unicast address
00075   // of the (single) destination.  (You may also need to make a similar
00076   // change to the receiver program.)
00077 #endif
00078   const unsigned short rtpPortNum = 6666;
00079   const unsigned short rtcpPortNum = rtpPortNum+1;
00080   const unsigned char ttl = 1; // low, in case routers don't admin scope
00081 
00082   struct in_addr destinationAddress;
00083   destinationAddress.s_addr = our_inet_addr(destinationAddressStr);
00084   const Port rtpPort(rtpPortNum);
00085   const Port rtcpPort(rtcpPortNum);
00086 
00087   sessionState.rtpGroupsock
00088     = new Groupsock(*env, destinationAddress, rtpPort, ttl);
00089   sessionState.rtcpGroupsock
00090     = new Groupsock(*env, destinationAddress, rtcpPort, ttl);
00091 #ifdef USE_SSM
00092   sessionState.rtpGroupsock->multicastSendOnly();
00093   sessionState.rtcpGroupsock->multicastSendOnly();
00094 #endif
00095 
00096   // Create a 'GSM RTP' sink from the RTP 'groupsock':
00097   sessionState.sink
00098     = GSMAudioRTPSink::createNew(*env, sessionState.rtpGroupsock);
00099 
00100   // Create (and start) a 'RTCP instance' for this RTP sink:
00101   const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share
00102   const unsigned maxCNAMElen = 100;
00103   unsigned char CNAME[maxCNAMElen+1];
00104   gethostname((char*)CNAME, maxCNAMElen);
00105   CNAME[maxCNAMElen] = '\0'; // just in case
00106   sessionState.rtcpInstance
00107     = RTCPInstance::createNew(*env, sessionState.rtcpGroupsock,
00108                               estimatedSessionBandwidth, CNAME,
00109                               sessionState.sink, NULL /* we're a server */,
00110                               isSSM);
00111   // Note: This starts RTCP running automatically
00112 
00113 #ifdef IMPLEMENT_RTSP_SERVER
00114   rtspServer = RTSPServer::createNew(*env, 8554);
00115   if (rtspServer == NULL) {
00116     *env << "Failed to create RTSP server: " << env->getResultMsg() << "%s\n";
00117     exit(1);
00118   }
00119   ServerMediaSession* sms
00120     = ServerMediaSession::createNew(*env, "testStream", "GSM input",
00121                 "Session streamed by \"testGSMStreamer\"", isSSM);
00122   sms->addSubsession(PassiveServerMediaSubsession::createNew(*sessionState.sink, sessionState.rtcpInstance));
00123   rtspServer->addServerMediaSession(sms);
00124 
00125   char* url = rtspServer->rtspURL(sms);
00126   *env << "Play this stream using the URL \"" << url << "\"\n";
00127   delete[] url;
00128 #endif
00129 
00130   play();
00131 
00132   env->taskScheduler().doEventLoop(); // does not return
00133   return 0; // only to prevent compiler warning
00134 }

void play (  ) 


Variable Documentation

UsageEnvironment* env

Definition at line 46 of file testGSMStreamer.cpp.

Boolean const isSSM = False

Definition at line 35 of file testGSMStreamer.cpp.

Referenced by main().

struct sessionState_t sessionState

Referenced by main().


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