[Live-devel] Stopping an RTP stream safely/Deleting objects

Ross Finlayson finlayson at live555.com
Wed Nov 16 02:06:17 PST 2011


> I have a similar use case in which the application has to start and stop the OnDemandRTSPServer before the EOF without the process being killed.

Why?  It would be much better to just leave the server running, but add/remove "ServerMediaSubsession" objects as appropriate.


> I am using the code of h264ESVideoTest of testOnDemandRTSPServer
> 
> To stop the server i set the watchVariable to a non null value. 
> when the  doEventLoop(&watchVariable); returns
> 
> I am doing the following. 
>       rtspServer->removeServerMediaSession(sms);
>       delete sms;
>       env->reclaim();
>       delete scheduler;
> 
> Next time when I start the server, port binding is failing. 
> Anything I am missing here ?

A lot, unfortunately.

First, after you call "removeServerMediaSubsession(sms)", you *must not* then do "delete sms" (or "Medium::close(sms)"), because that will cause the object to be deleted twice.

Second, you shouldn't reclaim the "UsageEnvironment" object, unless you first delete all of the objects that use it.  In particular, you must first do
	Medium::close(rtspServer);
but note that if you do that, then this will automatically remove all "ServerMediaSession" objects, so you won't need to do that yourself.

But once again: Rather than doing all this, why not just exit() and then recreate a new process?  This would be much simpler.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20111116/ae2c553e/attachment.html>


More information about the live-devel mailing list