Hello sir,<br><br>i made an streamer using your libraries which streams the live video from camera <br>int initLm555Settings(void)<br>{<br>scheduler = BasicTaskScheduler::createNew();<br> env = BasicUsageEnvironment::createNew(*scheduler);<br>
destinationAddressStr<br><br>#ifdef USE_SSM<br> <br>= "232.255.42.42";<br><br>#else<br> <br>= StreamingIp;<br>#endif<br> const unsigned short rtpPortNum = 18888;<br>const unsigned short rtcpPortNum = rtpPortNum+1;<br>
const unsigned char ttl = 7;<br>struct in_addr destinationAddress;<br> <br> destinationAddress.s_addr = our_inet_addr(destinationAddressStr);<br> <br>const Port rtpPort(rtpPortNum);<br> const Port rtcpPort(rtcpPortNum);<br>
<br><br> Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);<br>Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);<br><br>#ifdef USE_SSM<br> <br> rtpGroupsock.multicastSendOnly();<br> <br> rtcpGroupsock.multicastSendOnly();<br>
<br>#endif<br>g_ExitEventLoop = 0;<br>ideoSink =<br> SimpleRTPSink::createNew(*env, &rtpGroupsock, 33, 90000, "video", "MP2T",<br> 1, True, False /*no 'M' bit*/);<br> setSendBufferTo(*env, rtpGroupsock.socketNum(), 1024 * 1024);<br>
<br> // Create (and start) a 'RTCP instance' for this RTP sink:<br> const unsigned estimatedSessionBandwidth = 5000; // in kbps; for RTCP b/w share<br> const unsigned maxCNAMElen = 100;<br> unsigned char CNAME[maxCNAMElen+1];<br>
gethostname((char*)CNAME, maxCNAMElen);<br> CNAME[maxCNAMElen] = '\0'; // just in case<br><br> RTCPInstance* rtcp =<br> RTCPInstance::createNew(*env, &rtcpGroupsock,<br> estimatedSessionBandwidth, CNAME,<br>
videoSink, NULL /* we're a server */, isSSM);<br><br> UserAuthenticationDatabase* authDB = NULL; <br> portNumBits rtspServerPortNum = 554;<br> unsigned reclamationTestSeconds=65U;<br>rtspServer = RTSPServer::createNew(*env,rtspServerPortNum, authDB, reclamationTestSeconds); <br>
if (rtspServer == NULL)<br> {<br> *env << "Failed to create RTSP server: " <<env->getResultMsg()<<"\n";<br> <br> rtspServerPortNum = 8554;<br> rtspServer = RTSPServer::createNew(*env,rtspServerPortNum);<br>
if (rtspServer == NULL)<br> {<br> return 0;<br> }<br> else<br> {<br> <br> *env << "Created RTSP server.."<<"\n.";<br>
}<br> }<br> else<br> {<br> *env << "Created RTSP server.."<<"\n.";<br><br> Boolean const inputStreamIsRawUDP = False; <br>char const* descriptionString={"Session streamed by \"testOnDemandRT\""};<br>
sms= ServerMediaSession::createNew(*env, streamName, streamName,descriptionString);<br>sms->addSubsession(MPEG2TransportUDPServerMediaSubsession::createNew(*env,destinationAddressStr,rtpPortNum1,inputStreamIsRawUDP));<br>
rtspServer->addServerMediaSession(sms);<br><br> char* url = rtspServer->rtspURL(sms);<br>*env << "Play this stream using the URL \"" << url << "\"\n";<br> delete[] url;<br>
if (rtspServer->setUpTunnelingOverHTTP(sport) || rtspServer->setUpTunnelingOverHTTP(sport) || rtspServer->setUpTunnelingOverHTTP(sport))<br> {<br>cout<<"\n\n\n(We use port "<<rtspServer->httpServerPortNum()<<" for optional RTSP-over-HTTP tunneling.)\n";<br>
<br> } <br> else<br> {<br> <br> cout<<"\n\n\n(RTSP-over-HTTP tunneling is not available.)";<br> }<br> play();<br> env->taskScheduler().doEventLoop(&g_ExitEventLoop);<br>
if(rtspServer)<br> Medium::close(rtspServer);<br> if(rtcp)<br> Medium::close(rtcp);<br> <br> if(videoSink)<br> Medium::close(videoSink);<br> if(fileSource)<br> Medium::close(fileSource);<br> rtpGroupsock.removeAllDestinations();<br>
rtcpGroupsock.removeAllDestinations();<br><br> env->reclaim();<br> <br> delete scheduler;<br> <br> return 0; // only to prevent compiler warning<br>}<br>void afterPlaying(void* /*clientData*/) {<br> *env << "...done reading from file\n";<br>
<br> videoSink->stopPlaying();<br> // Note that this also closes the input file that this source read from.<br> Medium::close(videoSource);<br> <br><br> // Start playing once again:<br> play();<br>}<br><br>//================================================================<br>
// play(): Play the input source. <br>//=================================================================<br>void play() {<br> // Open the input file as a 'byte-stream file source':<br><br> fi_params.nFICardFrameSize = TRANSPORT_PACKETS_PER_NETWORK_PACKET * TRANSPORT_PACKET_SIZE;<br>
fi_params.pfnGetRTPPayload = GetRTPPayload;<br> fi_params.socketNum = videoSink->groupsockBeingUsed().socketNum();<br><br> DeviceParameters temp;<br><br> fileSource = DeviceSourceFICard::createNew(*env, fi_params, temp);<br>
if (fileSource == NULL) {<br> *env << "Unable to open Foresight card as a byte-stream file source\n";<br> exit(1);<br> }<br> FramedSource* videoES = fileSource;<br><br> // Create a framer for the Video Elementary Stream:<br>
<br> videoSource = MPEG1or2VideoStreamDiscreteFramer::createNew(*env, videoES);//original<br><br> <br> // Finally, start playing:<br> *env << "Beginning to read from file...\n";<br> videoSink->startPlaying(*videoSource, afterPlaying, videoSink);<br>
<br>// env->taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc*)periodicbrMeasurement1, videoSink);<br>}<br><br><br>void StartRTPProcess(void)<br>{<br> <br> g_hRtpComThread = CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,<br>
(LPTHREAD_START_ROUTINE)initLm555Settings, 0, 0, &g_dwRtpComThreadID);<br><br> if(g_hRtpComThread) SetThreadPriority(g_hRtpComThread, THREAD_PRIORITY_LOWEST/*THREAD_PRIORITY_NORMAL*/);<br> <br>}<br>int StopRTProcess(void) <br>
{<br> <br> try{<br> <br> if( videoSource )<br> videoSource->stopGettingFrames();<br> <br> <br> *env <<"in StopRTProcess\n";<br> Sleep(500);<br> <br> Medium::close(rtspServer);<br>
g_ExitEventLoop = 1;<br> g_ExitEventLoop = 0;<br> g_hRtpComThread = 0;<br> g_dwRtpComThreadID = 0;<br> <br> return 0;<br>}<br><br>The streaming done by above streamer is catched by proxy server to which i give the url given by streamer at the line "char* url".<br>
this streaming is then seen by the client by using the proxy server URL,when the client say to stop stream the streamer calls its method StopRTProcess(void) but i got stuck in the line " Medium::close(rtspServer);",can you please tell why?<br>
I know i have modified your code but still need some of your help<br><br><br>Thanks<br><br>