[Live-devel] Changing from Multicast to Unicast

Piers Hawksley piers.hawksley at panogenics.com
Thu Oct 24 10:00:13 PDT 2013


Hi Ross,

Using the following code I can stop a server media session and restart 
it (with different parameters such as multicast address & port). I can 
also change from unicast to multicast and back. However when I change 
from multicast to unicast the multicast stream continues until I request 
an RTSP stream (with VLC).

Am I missing a step in the remove code ?

Note that I am calling the functions this code is in using events 
triggered by triggerEvent so I can have a sleep in the calling thread of 
500ms between removing and adding the server media session. Note also 
that the RTSP server is still (potentially) streaming other server media 
sessions, so I can't stop and restart that.

Looking at wireshark - the RTCP packets continue after the change of 
settings - is this an indication of what the issue might be ?

To remove
rtspServer->deleteServerMediaSession(stream->sms);
stream->sms->deleteAllSubsessions();

To add
stream->sms = ServerMediaSession::createNew(*env, ... );

(For Multicast)
const Port rtpPort(stream->rtpPort);
Groupsock *rtpGroupsock = new Groupsock(*env, destaddr, rtpPort, 
stream->ttl);
rtpGroupsock->multicastSendOnly();
const Port rtcpPort(stream->rtcpPort);
Groupsock *rtcpGroupsock = new Groupsock(*env, destaddr, rtcpPort, 
stream->ttl);
rtcpGroupsock->multicastSendOnly();
RTPSink *sink = SimpleRTPSink::createNew(*env, rtpGroupsock, 33, 90000, 
"video", "MP2T", 1, True, False /*no 'M' bit*/);
RTCPInstance *rtcp = RTCPInstance::createNew(*env, rtcpGroupsock, 
estimatedSessionBandwidth, CNAME, sink, NULL, True);
stream->sms->addSubsession(PassiveServerMediaSubsession::createNew(*sink, rtcp));
MPEG2TransportStreamFromESSource *vidSrc = 
MPEG2TransportStreamFromESSource::createNew(*env);
vidSrc->addNewVideoSource(source, 2);
MPEG2TransportStreamFramer *videoSource = 
MPEG2TransportStreamFramer::createNew(*env, vidSrc);

(For Unicast)
(in createNewStreamSource)
MPEG2TransportStreamFromESSource *videoSource = 
MPEG2TransportStreamFromESSource::createNew(envir());
videoSource->addNewVideoSource(source, 2);
return MPEG2TransportStreamFramer::createNew(envir(), videoSource);
(in createNewRTPSink)
return SimpleRTPSink::createNew(envir(), rtpGroupsock, 33, 90000, 
"video", "MP2T", 1, True, False /*no 'M' bit*/);

(then for both unicast & multicast)
rtspServer->addServerMediaSession(stream->sms);


My encoder produces MPEG2 Elementary Streams, so some of the code 
converts these to Transport Streams (thanks for the library calls to do 
this and 
http://lists.live555.com/pipermail/live-devel/2011-July/013674.html for 
showing me the way).

Many Thanks,

Piers Hawksley


More information about the live-devel mailing list