[Live-devel] [PATCH 4/4] StreamReplicator: add frame delivery timeout

Ross Finlayson finlayson at live555.com
Mon May 25 07:50:27 PDT 2015


> In our application replicas are being used by RTPSinks, to multiply one source (from encoder) to multiple clients using class derived from OnDemandServerMediaSubsession (we need to support unicast).

If all of your clients are unicast RTSP clients, all using just one “OnDemandServerMediaSubsession” subclass, then you shouldn’t need to use “StreamReplicator” at all.  Instead, just ensure that your “OnDemandServerMediaSubsession” subclass’s constructor sets the “reuseFirstSource” parameter to True when it calls the parent (“OnDemandServerMediaSubsession”) constructor.  Setting the “reuseFirstSource” parameter to True will ensure that only one instance of your encoder source (your “FramedSource” subclass) is in existence at any time.  (You must still allow for your “FramedSource” subclass to be closed, then later re-opened; however, no more than one object of this class will be in existence at any given time.)

In this case the ‘replication’ (transmitting packets to the multiple unicast clients) will happen automatically at a lower level, inside the “Groupsock” object.

(Note, for example, the “testOnDemandRTSPServer” demonstration application (in “testProgs”).  If you were to change the definition of the “reuseFirstSource” variable in this code from False to True, then you could stream from the same file source to multiple concurrent unicast clients, with no additional change to the code.)


> To summarize: If timeout checks are made independently  for each of N replicas there will be 2*N scheduled tasks for each frame (1 made by RTPSink + 1 for timeout check) and N tasks will get canceled (in the normal mode of operation, when timeouts are never reached). If timeout checks are made in bulk like in proposed patch there will be N+1 scheduled tasks and 1 canceled task for each frame.

Why not have your application create just one timeout task, but - when this task is run - have it check all of the N replicas at once?

In any case, as I noted earlier, the “StreamReplicator” class is the wrong place to be putting ‘timeout’ functionality.  It’s better to simply require that the code that reads from each active replica be ‘well-behaved’, and continue reading from each replica - or else use the existing ‘deactivate’ mechanism (either by calling “stopGettingFrames()”, or by closing the replica) - if it no longer wishes to keep reading from it.

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/20150525/2983faa9/attachment.html>


More information about the live-devel mailing list