testProgs/testDVVideoStreamer.cpp File Reference

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

Include dependency graph for testDVVideoStreamer.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.dv"
DVVideoStreamFramervideoSource
RTPSinkvideoSink


Function Documentation

void afterPlaying ( void *   ) 

Definition at line 99 of file testDVVideoStreamer.cpp.

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

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

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file testDVVideoStreamer.cpp.

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

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

void play (  ) 


Variable Documentation

UsageEnvironment* env

Definition at line 25 of file testDVVideoStreamer.cpp.

char const* inputFileName = "test.dv"

Definition at line 26 of file testDVVideoStreamer.cpp.

RTPSink* videoSink

Definition at line 28 of file testDVVideoStreamer.cpp.

Referenced by afterPlaying(), and main().

DVVideoStreamFramer* videoSource

Definition at line 27 of file testDVVideoStreamer.cpp.

Referenced by afterPlaying().


Generated on Thu Feb 2 23:54:14 2012 for live by  doxygen 1.5.2