[Live-devel] question RTSP server

Ross Finlayson finlayson at live555.com
Mon Jan 9 09:24:49 PST 2023



> On Jan 9, 2023, at 6:21 AM, g.jaegy <g.jaegy at imagine3d.fr> wrote:
> 
> Fantastic, thanks a lot for that quick and very precise answer.
> 
> I've managed to update the code quickly, however, I'm just facing a little issue : I am not completely sure what the "reuseFirstSource" parameter in the OnDemandServerMediaSubsession() constructor means.

This parameter is important if more than one RTSP client is streaming from the server at the same time.  If "reuseFirstSource” is set to True, then each of these multiple RTSP clients will get data from the same source object, rather than the source object being created anew for each new RTSP client.  So, when you’re streaming from a live source (rather than a file), as you are doing, setting “reuseFirstSource” to True is the right thing to do.

HOWEVER, this doesn’t mean that your source object will be created only once, and destroyed only once.  As you discovered, the source object will get created once by “sdpLines()” (to implement the first RTSP “DESCRIBE” command), and then destroyed.  It will then get created again (to implement the RTSP “SETUP” command), and later destroyed when the streaming ends.  And this latter create/destroy sequence can happen multiple times, if a new client starts streaming after the previous client has ended.

Therefore, it’s important that you take this into account when you implement the constructor and destructor for your source object.  These can get called multiple times, in sequence - but not concurrently (provided that “reuseFirstSource” is True).  E.g., you can see constructor,destructor,constructor,destructor - but not constructor,constructor,destructor,destructor.


> So, I guess I'll have to instanciate both the framer, and my custom input source to that, each time createNewStreamSource() gets called. 

Yes, your “createNewStreamSource()” implementation must create a new input source object, and then a new “H265VideoStreamDiscreteFramer” object that uses it.  However, the implementation of your input source object can use a single underlying data structure (the actual data source).


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




More information about the live-devel mailing list