testProgs/testH264VideoStreamer.cpp File Reference

#include <liveMedia.hh>
#include <BasicUsageEnvironment.hh>
#include <GroupsockHelper.hh>

Include dependency graph for testH264VideoStreamer.cpp:

Go to the source code of this file.

Functions

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

Variables

UsageEnvironmentenv
char const * inputFileName = "test.264"
H264VideoStreamFramervideoSource
RTPSinkvideoSink


Function Documentation

void afterPlaying ( void *   ) 

Definition at line 104 of file testH264VideoStreamer.cpp.

References Medium::close(), env, play(), MediaSink::stopPlaying(), videoSink, and videoSource.

00104                                         {
00105   *env << "...done reading from file\n";
00106   videoSink->stopPlaying();
00107   Medium::close(videoSource);
00108   // Note that this also closes the input file that this source read from.
00109 
00110   // Start playing once again:
00111   play();
00112 }

int main ( int  argc,
char **  argv 
)

Definition at line 38 of file testH264VideoStreamer.cpp.

References RTSPServer::addServerMediaSession(), ServerMediaSession::addSubsession(), chooseRandomIPv4SSMAddress(), PassiveServerMediaSubsession::createNew(), ServerMediaSession::createNew(), RTSPServer::createNew(), RTCPInstance::createNew(), H264VideoRTPSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, exit, UsageEnvironment::getResultMsg(), inputFileName, OutPacketBuffer::maxSize, Groupsock::multicastSendOnly(), NULL, play(), rtcp, rtspServer, RTSPServer::rtspURL(), sms, UsageEnvironment::taskScheduler(), True, and videoSink.

00038                                 {
00039   // Begin by setting up our usage environment:
00040   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00041   env = BasicUsageEnvironment::createNew(*scheduler);
00042 
00043   // Create 'groupsocks' for RTP and RTCP:
00044   struct in_addr destinationAddress;
00045   destinationAddress.s_addr = chooseRandomIPv4SSMAddress(*env);
00046   // Note: This is a multicast address.  If you wish instead to stream
00047   // using unicast, then you should use the "testOnDemandRTSPServer"
00048   // test program - not this test program - as a model.
00049 
00050   const unsigned short rtpPortNum = 18888;
00051   const unsigned short rtcpPortNum = rtpPortNum+1;
00052   const unsigned char ttl = 255;
00053 
00054   const Port rtpPort(rtpPortNum);
00055   const Port rtcpPort(rtcpPortNum);
00056 
00057   Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);
00058   rtpGroupsock.multicastSendOnly(); // we're a SSM source
00059   Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);
00060   rtcpGroupsock.multicastSendOnly(); // we're a SSM source
00061 
00062   // Create a 'H264 Video RTP' sink from the RTP 'groupsock':
00063   OutPacketBuffer::maxSize = 100000;
00064   videoSink = H264VideoRTPSink::createNew(*env, &rtpGroupsock, 96);
00065 
00066   // Create (and start) a 'RTCP instance' for this RTP sink:
00067   const unsigned estimatedSessionBandwidth = 500; // in kbps; for RTCP b/w share
00068   const unsigned maxCNAMElen = 100;
00069   unsigned char CNAME[maxCNAMElen+1];
00070   gethostname((char*)CNAME, maxCNAMElen);
00071   CNAME[maxCNAMElen] = '\0'; // just in case
00072   RTCPInstance* rtcp
00073   = RTCPInstance::createNew(*env, &rtcpGroupsock,
00074                             estimatedSessionBandwidth, CNAME,
00075                             videoSink, NULL /* we're a server */,
00076                             True /* we're a SSM source */);
00077   // Note: This starts RTCP running automatically
00078 
00079   RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554);
00080   if (rtspServer == NULL) {
00081     *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
00082     exit(1);
00083   }
00084   ServerMediaSession* sms
00085     = ServerMediaSession::createNew(*env, "testStream", inputFileName,
00086                    "Session streamed by \"testH264VideoStreamer\"",
00087                                            True /*SSM*/);
00088   sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp));
00089   rtspServer->addServerMediaSession(sms);
00090 
00091   char* url = rtspServer->rtspURL(sms);
00092   *env << "Play this stream using the URL \"" << url << "\"\n";
00093   delete[] url;
00094 
00095   // Start the streaming:
00096   *env << "Beginning streaming...\n";
00097   play();
00098 
00099   env->taskScheduler().doEventLoop(); // does not return
00100 
00101   return 0; // only to prevent compiler warning
00102 }

void play (  ) 


Variable Documentation

UsageEnvironment* env

Definition at line 31 of file testH264VideoStreamer.cpp.

char const* inputFileName = "test.264"

Definition at line 32 of file testH264VideoStreamer.cpp.

RTPSink* videoSink

Definition at line 34 of file testH264VideoStreamer.cpp.

H264VideoStreamFramer* videoSource

Definition at line 33 of file testH264VideoStreamer.cpp.


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