Hi All,
I am trying to perform multicast live streaming from a web camera.
The web camera is continuously generating mpeg 4 stream (single file with extension as .m4e). I am performing the streaming using testMPEG4VideoStreamer.
The way I do it is that I initialize the current position to 0, and start the testMPEG4VideoStreamer.exe
AS soon as the "afterPlaying" callback gets called, I again call the play() method with the new value of the current position .
Please refer to the below code:
 
#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"
#include "GroupsockHelper.hh"
UsageEnvironment* env;
char const* inputFileName = "test.m4e";
MPEG4VideoStreamFramer* videoSource;
RTPSink* videoSink;
long currentPos = 0;
void play(long); // forward
int main(int argc, char** argv) {
  // Begin by setting up our usage environment:
  TaskScheduler* scheduler = BasicTaskScheduler::createNew();
  env = BasicUsageEnvironment::createNew(*scheduler);
  // Create 'groupsocks' for RTP and RTCP:
  struct in_addr destinationAddress;
  destinationAddress.s_addr = chooseRandomIPv4SSMAddress(*env);
  // Note: This is a multicast address.  If you wish instead to stream
  // using unicast, then you should use the "testOnDemandRTSPServer"
  // test program - not this test program - as a model.
  const unsigned short rtpPortNum = 18888;
  const unsigned short rtcpPortNum = rtpPortNum+1;
  const unsigned char ttl = 255;
  const Port rtpPort(rtpPortNum);
  const Port rtcpPort(rtcpPortNum);
  Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);
  rtpGroupsock.multicastSendOnly(); // we're a SSM source
  Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);
  rtcpGroupsock.multicastSendOnly(); // we're a SSM source
  // Create a 'MPEG-4 Video RTP' sink from the RTP 'groupsock':
  videoSink = MPEG4ESVideoRTPSink::createNew(*env, &rtpGroupsock, 96);
  // Create (and start) a 'RTCP instance' for this RTP sink:
  const unsigned estimatedSessionBandwidth = 500; // 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, &rtcpGroupsock,
       estimatedSessionBandwidth, CNAME,
       videoSink, NULL /* we're a server */,
       True /* we're a SSM source */);
  // Note: This starts RTCP running automatically
  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, inputFileName, inputFileName,
     "Session streamed by \"testMPEG4VideoStreamer\"",
        True /*SSM*/);
  sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp));
  rtspServer->addServerMediaSession(sms);
  char* url = "">   *env << "Play this stream using the URL \"" << url << "\"\n";
  delete[] url;
  // Start the streaming:
  *env << "Beginning streaming...\n";
   *env << "Playing with currentPosition as " << currentPos << "\n";
  play(currentPos);
  env->taskScheduler().doEventLoop(); // does not return
  return 0; // only to prevent compiler warning
}
void afterPlaying(void* /*clientData*/) {
  *env << "...done reading from file\n";
  Medium::close(videoSource);
  // Note that this also closes the input file that this source read from.
  // Start playing once again:
   
  *env << "Playing with currentPosition as " << currentPos << "\n";
    play(currentPos);
 
}
void play(long currentPosition) {
  // Open the input file as a 'byte-stream file source':
  ByteStreamFileSource* fileSource
    = ByteStreamFileSource::createNew(*env, inputFileName);
  if (fileSource == NULL) {
    *env << "Unable to open file \"" << inputFileName
  << "\" as a byte-stream file source\n";
    exit(1);
  }
  long currentFileSize = (long)(fileSource->fileSize());
  *env << "Current File Size ...." << currentFileSize << "\n";
  *env << "Seeking to position ...." << currentPosition << "\n";
  fileSource->seekToByteAbsolute(currentPosition);
  FramedSource* videoES = fileSource;
  // Create a framer for the Video Elementary Stream:
  videoSource = MPEG4VideoStreamFramer::createNew(*env, videoES);
  videoSource->flushInput();
  // Finally, start playing:
  *env << "Beginning to read from file...\n";
  //currentPos +=  (currentFileSize-currentPosition);
  currentPos = currentFileSize;
  videoSink->startPlaying(*videoSource, afterPlaying, videoSink); 
}

 

 

However, on opening the rtsp url from VLC player, although no error is reported. However, VLC player does not show any video. Please help me in identifying my mistake


 


::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to