[Live-devel] Multicast streams from multiple devices
Martin Morissette
martin.morissette at gmail.com
Sat Apr 23 13:31:38 PDT 2005
Hi Ross,
I am part of a AUV (autonomous underwater vehicule) team and we use
your library to stream underwater videos. So far, live worked
extremely well for us and we would like to thank you for it.
On the other hand, we've been having a few issues while trying to
stream from more than one device (camera). The folowing code is a
method that let's us add a stream for a camera at any time, the
problem, is that when we add more than one, the streams seems to
overlap each other (i.e. we'll see part of the first camera and part
of the second at the same time). Can you see anything wrong with my
code?
string LiveStreamer::addStream(string name, ImageSource* imageSource)
{
if(!(streams.empty() || (streams.find(name) == streams.end())) ){
throw Exception("Specified stream already exists",name);
}
// Create a 'MPEG-4 Video RTP' sink from the RTP 'groupsock':
RTPSink* 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
liveStreamTL.writeLock();
// Add SMS to Map for further removal!
streams[name] = ServerMediaSession::createNew(*env, name.c_str(),
name.c_str(),
"Session streamed by \"S.O.N.I.A.
Vision Server\"", True /*SSM*/);
ServerMediaSession* sms = streams[name];
sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink,
rtcp));
rtspServer->addServerMediaSession(sms);
char* url = rtspServer->rtspURL(sms);
string urlString(url);
delete[] url;
FramedSource* videoES = new MpegSource(*env, imageSource);
// Create a framer for the Video Elementary Stream:
videoSource = MPEG4VideoStreamDiscreteFramer::createNew(*env, videoES);
// Finally, start playing:
videoSink->startPlaying(*videoSource, NULL, videoSink);
liveStreamTL.unlock();
return urlString;
}
Thank you very much
Martin
More information about the live-devel
mailing list