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

Go to the source code of this file.
Defines | |
| #define | TRANSPORT_PACKET_SIZE 188 |
| #define | TRANSPORT_PACKETS_PER_NETWORK_PACKET 7 |
Functions | |
| void | play () |
| int | main (int argc, char **argv) |
| void | afterPlaying (void *) |
Variables | |
| Boolean const | isSSM = False |
| UsageEnvironment * | env |
| char const * | inputFileName = "test.ts" |
| FramedSource * | videoSource |
| RTPSink * | videoSink |
| #define TRANSPORT_PACKET_SIZE 188 |
Definition at line 37 of file testMPEG2TransportStreamer.cpp.
| #define TRANSPORT_PACKETS_PER_NETWORK_PACKET 7 |
Definition at line 38 of file testMPEG2TransportStreamer.cpp.
| void afterPlaying | ( | void * | ) |
Definition at line 129 of file testMPEG2TransportStreamer.cpp.
References Medium::close(), env, play(), and videoSource.
00129 { 00130 *env << "...done reading from file\n"; 00131 00132 Medium::close(videoSource); 00133 // Note that this also closes the input file that this source read from. 00134 00135 play(); 00136 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 48 of file testMPEG2TransportStreamer.cpp.
References RTSPServer::addServerMediaSession(), ServerMediaSession::addSubsession(), PassiveServerMediaSubsession::createNew(), ServerMediaSession::createNew(), RTSPServer::createNew(), RTCPInstance::createNew(), SimpleRTPSink::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, False, UsageEnvironment::getResultMsg(), inputFileName, isSSM, Groupsock::multicastSendOnly(), NULL, our_inet_addr(), play(), rtspServer, RTSPServer::rtspURL(), UsageEnvironment::taskScheduler(), True, and videoSink.
00048 { 00049 // Begin by setting up our usage environment: 00050 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00051 env = BasicUsageEnvironment::createNew(*scheduler); 00052 00053 // Create 'groupsocks' for RTP and RTCP: 00054 char* destinationAddressStr 00055 #ifdef USE_SSM 00056 = "232.255.42.42"; 00057 #else 00058 = "239.255.42.42"; 00059 // Note: This is a multicast address. If you wish to stream using 00060 // unicast instead, then replace this string with the unicast address 00061 // of the (single) destination. (You may also need to make a similar 00062 // change to the receiver program.) 00063 #endif 00064 const unsigned short rtpPortNum = 1234; 00065 const unsigned short rtcpPortNum = rtpPortNum+1; 00066 const unsigned char ttl = 7; // low, in case routers don't admin scope 00067 00068 struct in_addr destinationAddress; 00069 destinationAddress.s_addr = our_inet_addr(destinationAddressStr); 00070 const Port rtpPort(rtpPortNum); 00071 const Port rtcpPort(rtcpPortNum); 00072 00073 Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl); 00074 Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl); 00075 #ifdef USE_SSM 00076 rtpGroupsock.multicastSendOnly(); 00077 rtcpGroupsock.multicastSendOnly(); 00078 #endif 00079 00080 // Create an appropriate 'RTP sink' from the RTP 'groupsock': 00081 videoSink = 00082 SimpleRTPSink::createNew(*env, &rtpGroupsock, 33, 90000, "video", "mp2t", 00083 1, True, False /*no 'M' bit*/); 00084 00085 // Create (and start) a 'RTCP instance' for this RTP sink: 00086 const unsigned estimatedSessionBandwidth = 5000; // in kbps; for RTCP b/w share 00087 const unsigned maxCNAMElen = 100; 00088 unsigned char CNAME[maxCNAMElen+1]; 00089 gethostname((char*)CNAME, maxCNAMElen); 00090 CNAME[maxCNAMElen] = '\0'; // just in case 00091 #ifdef IMPLEMENT_RTSP_SERVER 00092 RTCPInstance* rtcp = 00093 #endif 00094 RTCPInstance::createNew(*env, &rtcpGroupsock, 00095 estimatedSessionBandwidth, CNAME, 00096 videoSink, NULL /* we're a server */, isSSM); 00097 // Note: This starts RTCP running automatically 00098 00099 #ifdef IMPLEMENT_RTSP_SERVER 00100 RTSPServer* rtspServer = RTSPServer::createNew(*env); 00101 // Note that this (attempts to) start a server on the default RTSP server 00102 // port: 554. To use a different port number, add it as an extra 00103 // (optional) parameter to the "RTSPServer::createNew()" call above. 00104 if (rtspServer == NULL) { 00105 *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n"; 00106 exit(1); 00107 } 00108 ServerMediaSession* sms 00109 = ServerMediaSession::createNew(*env, "testStream", inputFileName, 00110 "Session streamed by \"testMPEG2TransportStreamer\"", 00111 isSSM); 00112 sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp)); 00113 rtspServer->addServerMediaSession(sms); 00114 00115 char* url = rtspServer->rtspURL(sms); 00116 *env << "Play this stream using the URL \"" << url << "\"\n"; 00117 delete[] url; 00118 #endif 00119 00120 // Finally, start the streaming: 00121 *env << "Beginning streaming...\n"; 00122 play(); 00123 00124 env->taskScheduler().doEventLoop(); // does not return 00125 00126 return 0; // only to prevent compiler warning 00127 }
| void play | ( | ) |
Definition at line 41 of file testMPEG2TransportStreamer.cpp.
| char const* inputFileName = "test.ts" |
Definition at line 42 of file testMPEG2TransportStreamer.cpp.
Definition at line 30 of file testMPEG2TransportStreamer.cpp.
Definition at line 44 of file testMPEG2TransportStreamer.cpp.
Definition at line 43 of file testMPEG2TransportStreamer.cpp.
1.5.2