[Live-devel] Streaming from a live camera
Martin Morissette
martin.morissette at gmail.com
Mon Feb 21 21:56:55 PST 2005
Hi Ross,
first of all, thank you for your quick response!
In my first message I wasn't very clear regarding issue with streaming
from a live camera. I feed my ES into a MPEG4VideoStreamDiscreteFramer
and my RTCPInstance uses MPEG4ESVideoRTPSink.
My code looks like this:
void LiveStreamer::run()
{
// 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";
throw new Exception("Failed to create RTSP server","");
}
ServerMediaSession* sms = ServerMediaSession::createNew(*env,
"testStream", "front cam",
"Session streamed by
\"testMPEG4VideoStreamer\"", True /*SSM*/);
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;
// Start the streaming:
*env << "Beginning streaming...\n";
play();
env->taskScheduler().doEventLoop(); // does not return
}
void LiveStreamer::play() {
FramedSource* videoES = new MpegSource(*env, buffer);
// Create a framer for the Video Elementary Stream:
videoSource = MPEG4VideoStreamDiscreteFramer::createNew(*env, videoES);
// Finally, start playing:
*env << "Beginning to read from file...\n";
videoSink->startPlaying(*videoSource, /*(void (*)(void*))
afterPlaying*/NULL, videoSink);
}
>From what I see, the scheduler calls the doGetNextFrame constantly (I
added a print in my encoder class) but whenever I connect to the URL
that live gives me (rtsp://192.168.1.2:8554/testStream) the VLC client
gives the folowing error message:
-----------------------------------------------------------------------
livedotcom: PLAY failed No RTSP session is currently in progress
main: no suitable access module for 'rtsp://192.168.1.2:8554/testStream
-----------------------------------------------------------------------
I've tryied writting to disk the output of my encoder and streaming it
with your testProgs
testOnDemandRTSPServer works using the mpeg4ESVideoTest stream
but
testMPEG4VideoStreamer gives me the same output it does in my applications!?
Can you see anything wrong?
Also, regarding my second question about dynamically adding streams to
the scheduler, I was talking of another protocole that my server would
support (not the RTSP server but acquisition server). So there are no
problem if I start the scheduler even if there is no SMS?
Thank you for your help
Martin
On Sun, 20 Feb 2005 19:26:53 -0800, Ross Finlayson <finlayson at live.com> wrote:
>
> >Unfortunetely this does not work. Do you see anything wrong?
>
> No, but you haven't said anything about what you're doing with the data
> from your "MpegSource" class. I.e., what filter and sink classes are you
> feeding it into?
>
> >The encoder variable is an XviD MPEG4 video encoder that encodes the
> >frames from my camera, settnig fTo to the encoded frame and returning
> >the size of the encoded frame.
>
> You should be feeding this data into a "MPEG4VideoStreamDiscreteFramer",
> and from that to a "MPEG4ESVideoRTPSink".
>
> >Also, is it possible with LIVE.com to dynamically add streams to the
> >RTSP server.
>
> Yes, using "RTSPServer::addServerMediaSession()". (To remove a stream,
> call "RTSPServer::removeServerMediaSession()".)
>
> >Is it possible to have one RTSP server running
> >and adding (or removing) a stream (let's say the output of a certain
> >vision algorithm) to it whenever a client request it (the request will
> >be managed by my acquisition server wich will then communicate with
> >the LIVE thread).
>
> If by "request a stream", you mean using RTSP (i.e., using a "rtsp://"
> URL), then no, because all RTSP server processing must be done by the RTSP
> server. Also, there's currently no mechanism in the code that allows a
> RTSP server - in response to a new RTSP "DESCRIBE" command - to add a new
> "ServerMediaSession" to the server.
>
> If, however, by "request a stream", you mean using some other protocol
> (i.e., not RTSP), then yes, you can do this.
>
> Ross Finlayson
> LIVE.COM
> <http://www.live.com/>
>
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live.com
> http://lists.live.com/mailman/listinfo/live-devel
>
More information about the live-devel
mailing list