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

Ross Finlayson finlayson at live555.com
Mon Nov 14 19:33:53 PST 2011


> I'm streaming an MPEG-2 TS file using code very similar to testMPEG2TransportStreamer.cpp. In one of my use cases, I need to stop the stream immediately instead of allowing it to complete. I'm doing this currently by passing a watch variable to the taskScheduler().doEventLoop() call and allowing another thread to set that variable when I need to stop playback.

FYI (and this is unrelated to your question below), you might find it simpler to use the new 'event trigger' mechanism instead; see "UsageEnvironment/include/UsageEnvironment.hh"


> My question is what do I need to do after that to safely stop and delete my related objects (UsageEnvironment, RTPSink, etc) if I leave the doEventLoop() early?

First, you can always just call "exit(0)" to leave and destroy the process (i.e., address space, i.e., application).  The OS will take care of closing/reclaiming its sockets.  This is by far the simplest thing to do, and it's what you should do - unless you have a very good reason for wanting to keep the process around.

But, if you really want to keep the process around, you can reclaim the LIVE555 objects by doing the following (generally speaking, you're reclaiming objects in the reverse order from the order that you created them):

  videoSink->stopPlaying();
  Medium::close(videoSource);
  Medium::close(videoSink);
  delete rtpGroupsock;
  delete rtcpGroupsock;
  env->reclaim();
  delete scheduler;

(I'm basing this on the "testMPEG2TransportStreamer" code, because you said you used that code as a model.)
  

> I'd like to reuse the RTPsink but give it different parameters on a subsequent use.

No, you can't do that.  Just delete it (using "Medium::close()"), and create a new one next time.

But again, why not just exit the process (application), and launch a new one next time?


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/20111115/859535bf/attachment.html>


More information about the live-devel mailing list