<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<span id="result_box" lang="en"><span class="hps">Can</span> <span class="hps">someone</span> <span class="hps">tell</span> <span class="hps">me</span> <span class="hps">why my</span> rtsp <span class="hps">code</span> <span class="hps">only works</span> <span class="hps">in the local network ( Lan - Lan ) </span> <span class="hps">but not on</span> <span class="hps">Windows</span> <span class="hps">Server 2008 ( hosting ) ?<br></span></span><span id="result_box" class="short_text" lang="en"><span class="hps">here's</span> <span class="hps">my</span> <span class="hps">code:</span></span><br><br>#include "liveMedia.hh"<br>#include "BasicUsageEnvironment.hh"<br>#include "GroupsockHelper.hh"<br><br>UsageEnvironment* env;<br><br>Boolean const isSSM = True;<br><br>char const* inputFileName = "udp://@239.255.42.42:8888";<br>MPEG1or2VideoStreamFramer* videoSource;<br>RTPSink* videoSink;<br><br>void play(); // forward<br><br>Boolean reuseFirstSource = True;<br><br>Boolean iFramesOnly = False;<br><br>static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,<br>               char const* streamName, char const* inputFileName); // fwd<br><br>int main(int argc, char** argv) {<br>  // Begin by setting up our usage environment:<br>  TaskScheduler* scheduler = BasicTaskScheduler::createNew();<br>  env = BasicUsageEnvironment::createNew(*scheduler);<br><br> <br>    // Create a 'groupsock' for the input multicast group,port:<br>  char const* inputAddressStr<br>#ifdef USE_SSM<br>    = "232.255.42.42";<br>#else<br>    = "239.255.42.42";<br>#endif<br>  struct in_addr inputAddress;<br>  inputAddress.s_addr = our_inet_addr(inputAddressStr);<br><br>  Port const inputPort(8888);<br>  unsigned char const inputTTL = 0; // we're only reading from this mcast group<br><br>#ifdef USE_SSM<br>  char* sourceAddressStr = "udp://@239.255.42.42:8888";<br>                           // replace this with the real source address<br>  struct in_addr sourceFilterAddress;<br>  sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr);<br><br>  Groupsock inputGroupsock(*env, inputAddress, sourceFilterAddress, inputPort);<br>#else<br>  Groupsock inputGroupsock(*env, inputAddress, inputPort, inputTTL);<br>#endif<br><br>  // Then create a liveMedia 'source' object, encapsulating this groupsock:<br>  FramedSource* source = BasicUDPSource::createNew(*env, &inputGroupsock);<br>  FramedSource* source2 = BasicUDPSource::createNew(*env, &inputGroupsock);<br><br>  char const* outputAddressStr = "239.255.43.43"; // this could also be unicast<br>    // Note: You may change "outputAddressStr" to use a different multicast<br>    // (or unicast address), but do *not* change it to use the same multicast<br>    // address as "inputAddressStr".<br>  struct in_addr outputAddress;<br>  outputAddress.s_addr = our_inet_addr(outputAddressStr);<br><br>  Port const outputPort(4444);<br>  unsigned char const outputTTL = 255;<br><br>  Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);<br><br>  // Create a 'MPEG-4 Video RTP' sink from the RTP 'groupsock':<br>  unsigned const maxPacketSize = 65536; // allow for large UDP packets<br>  videoSink = SimpleRTPSink::createNew(*env, &outputGroupsock, 33, 90000, "video", "mp2t",<br>                 1, True, False /*no 'M' bit*/);<br>// MediaSink* sink = SimpleRTPSink::createNew(*env, &outputGroupsock, 33, 90000, "video", "mp2t",<br>//                 1, True, False /*no 'M' bit*/);<br><br>    <br><br>    const unsigned estimatedSessionBandwidth = 4500; // 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 = RTCPInstance::createNew(*env, &inputGroupsock,<br>                  estimatedSessionBandwidth, CNAME,<br>                  videoSink, NULL /* we're a server */, isSSM);<br>  <br>  RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554);<br>  if (rtspServer == NULL) {<br>    *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";<br>    exit(1);<br>  }<br>  ServerMediaSession* sms<br>    = ServerMediaSession::createNew(*env, "testStream", inputFileName,<br>           "Session streamed by \"testMPEG4VideoStreamer\"",<br>                       isSSM);<br>  sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp));<br>  rtspServer->addServerMediaSession(sms);<br><br><br>  char* url = rtspServer->rtspURL(sms);<br>  *env << "Play this stream using the URL \"" << url << "\"\n";<br>  delete[] url;<br><br><br>  videoSource = MPEG1or2VideoStreamDiscreteFramer::createNew(*env, source);<br>    videoSink->startPlaying(*videoSource, NULL, NULL);<br><br>    if (rtspServer->setUpTunnelingOverHTTP(80) || rtspServer->setUpTunnelingOverHTTP(8000) || rtspServer->setUpTunnelingOverHTTP(8080)) {<br>    *env << "\n(We use port " << rtspServer->httpServerPortNum() << " for optional RTSP-over-HTTP tunneling.)\n";<br>  } else {<br>    *env << "\n(RTSP-over-HTTP tunneling is not available.)\n";<br>  }<br><br>//    sink->startPlaying(*source2, NULL, NULL);<br><br>    env->taskScheduler().doEventLoop(); // does not return<br><br>  return 0; // only to prevent compiler warning<br>}<br><br>static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,<br>               char const* streamName, char const* inputFileName) {<br>  char* url = rtspServer->rtspURL(sms);<br>  UsageEnvironment& env = rtspServer->envir();<br>  env << "\n\"" << streamName << "\" stream, from the file \""<br>      << inputFileName << "\"\n";<br>  env << "Play this stream using the URL \"" << url << "\"\n";<br>  delete[] url;<br>}<br><br><pre>greeting
Igor</pre><br>                                        </div></body>
</html>