[Live-devel] RTSP only in Lan - Lan ?!

Marlon Reid Marlon at scansoft.co.za
Thu Jan 12 06:55:59 PST 2012


Make sure that your firewall allows communications on the network for
the specified port.
 

________________________________

From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of GS Net Player
Sent: 12 January 2012 14:12
To: live-devel at ns.live555.com
Subject: [Live-devel] RTSP only in Lan - Lan ?!


Can someone tell me why my rtsp code only works in the local network (
Lan - Lan )  but not on Windows Server 2008 ( hosting ) ?
here's my code:

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

UsageEnvironment* env;

Boolean const isSSM = True;

char const* inputFileName = "udp://@239.255.42.42:8888";
MPEG1or2VideoStreamFramer* videoSource;
RTPSink* videoSink;

void play(); // forward

Boolean reuseFirstSource = True;

Boolean iFramesOnly = False;

static void announceStream(RTSPServer* rtspServer, ServerMediaSession*
sms,
               char const* streamName, char const* inputFileName); //
fwd

int main(int argc, char** argv) {
  // Begin by setting up our usage environment:
  TaskScheduler* scheduler = BasicTaskScheduler::createNew();
  env = BasicUsageEnvironment::createNew(*scheduler);

 
    // Create a 'groupsock' for the input multicast group,port:
  char const* inputAddressStr
#ifdef USE_SSM
    = "232.255.42.42";
#else
    = "239.255.42.42";
#endif
  struct in_addr inputAddress;
  inputAddress.s_addr = our_inet_addr(inputAddressStr);

  Port const inputPort(8888);
  unsigned char const inputTTL = 0; // we're only reading from this
mcast group

#ifdef USE_SSM
  char* sourceAddressStr = "udp://@239.255.42.42:8888";
                           // replace this with the real source address
  struct in_addr sourceFilterAddress;
  sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr);

  Groupsock inputGroupsock(*env, inputAddress, sourceFilterAddress,
inputPort);
#else
  Groupsock inputGroupsock(*env, inputAddress, inputPort, inputTTL);
#endif

  // Then create a liveMedia 'source' object, encapsulating this
groupsock:
  FramedSource* source = BasicUDPSource::createNew(*env,
&inputGroupsock);
  FramedSource* source2 = BasicUDPSource::createNew(*env,
&inputGroupsock);

  char const* outputAddressStr = "239.255.43.43"; // this could also be
unicast
    // Note: You may change "outputAddressStr" to use a different
multicast
    // (or unicast address), but do *not* change it to use the same
multicast
    // address as "inputAddressStr".
  struct in_addr outputAddress;
  outputAddress.s_addr = our_inet_addr(outputAddressStr);

  Port const outputPort(4444);
  unsigned char const outputTTL = 255;

  Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);

  // Create a 'MPEG-4 Video RTP' sink from the RTP 'groupsock':
  unsigned const maxPacketSize = 65536; // allow for large UDP packets
  videoSink = SimpleRTPSink::createNew(*env, &outputGroupsock, 33,
90000, "video", "mp2t",
                 1, True, False /*no 'M' bit*/);
// MediaSink* sink = SimpleRTPSink::createNew(*env, &outputGroupsock,
33, 90000, "video", "mp2t",
//                 1, True, False /*no 'M' bit*/);

    

    const unsigned estimatedSessionBandwidth = 4500; // in kbps; for
RTCP b/w share
  const unsigned maxCNAMElen = 100;
  unsigned char CNAME[maxCNAMElen+1];
  gethostname((char*)CNAME, maxCNAMElen);
  CNAME[maxCNAMElen] = '\0'; // just in case

  RTCPInstance* rtcp = RTCPInstance::createNew(*env, &inputGroupsock,
                  estimatedSessionBandwidth, CNAME,
                  videoSink, NULL /* we're a server */, isSSM);
  
  RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554);
  if (rtspServer == NULL) {
    *env << "Failed to create RTSP server: " << env->getResultMsg() <<
"\n";
    exit(1);
  }
  ServerMediaSession* sms
    = ServerMediaSession::createNew(*env, "testStream", inputFileName,
           "Session streamed by \"testMPEG4VideoStreamer\"",
                       isSSM);
  sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink,
rtcp));
  rtspServer->addServerMediaSession(sms);


  char* url = rtspServer->rtspURL(sms);
  *env << "Play this stream using the URL \"" << url << "\"\n";
  delete[] url;


  videoSource = MPEG1or2VideoStreamDiscreteFramer::createNew(*env,
source);
    videoSink->startPlaying(*videoSource, NULL, NULL);

    if (rtspServer->setUpTunnelingOverHTTP(80) ||
rtspServer->setUpTunnelingOverHTTP(8000) ||
rtspServer->setUpTunnelingOverHTTP(8080)) {
    *env << "\n(We use port " << rtspServer->httpServerPortNum() << "
for optional RTSP-over-HTTP tunneling.)\n";
  } else {
    *env << "\n(RTSP-over-HTTP tunneling is not available.)\n";
  }

//    sink->startPlaying(*source2, NULL, NULL);

    env->taskScheduler().doEventLoop(); // does not return

  return 0; // only to prevent compiler warning
}

static void announceStream(RTSPServer* rtspServer, ServerMediaSession*
sms,
               char const* streamName, char const* inputFileName) {
  char* url = rtspServer->rtspURL(sms);
  UsageEnvironment& env = rtspServer->envir();
  env << "\n\"" << streamName << "\" stream, from the file \""
      << inputFileName << "\"\n";
  env << "Play this stream using the URL \"" << url << "\"\n";
  delete[] url;
}


greeting
Igor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120112/274086d4/attachment-0001.html>


More information about the live-devel mailing list