[Live-devel] Dynamically adding streams with reference counting

Rawling, Stuart SRawling at pelco.com
Tue Jun 24 16:20:18 PDT 2008


Hi all,

I am trying to implement a dynamic rtsp server.  By this I mean it will add
the appropriate ServerMediaSession to the server when a url is requested.
For example, if the server receives: rtsp:ip:port/mystreamid, it will look
up to see if the session exists, and if not dynamically add it.  To do this
I overrode the RTSPServer::lookupServerMediaSession method as recommended on
this list.  

It adds the stream by creating a new ServerMediaSession, and adding the
appropriate ServerMediaSubsessions.  Each custom ServerMediaSubsession (
inherited from OnDemandServerMediaSubsession) implements a custom
createNewStreamSource which returns a custom framed source object that
provides the data.

I have the initiation and streaming working great!  However, I also want to
know when the client has closed its connection so I can remove the dynamic
ServerMediaSession.  I was planning on implementing it in the following way:

Create a custom ServerMediaSession object that has a couple of new functions
that allow reference counting.  In the ServerMediaSubsession implentation
when a FramedSource object is created (ie. when createNewStreamSource is
called) the count on the ServerMediaSession incremented, if it is destroyed
(ie. CloseStreamSource is called) the reference is decremented.  If the
reference count is zero, then a event is triggered to remove the
ServerMediaSession from the RTSPServer.

I am aware of the following caveat with what I am planning: When the
sdpLines function is called it initiates and destroys a FramedSource object
in order to generate the sdp.  I know I have to handle this situation.

I think it would be easier to have access to the fDestinationHashTable
object in the OnDemandServerMediaSubsession, as this keeps a track of the
destinations and can be queried through the numEntries method.  This is
currently a private member variable in OnDemandServerMediaSubsession and
cannot be accessed.

I really want to know if you guys think that what I am planning to do makes
sense, or if you know of a better way.

I appreciate any help that can be offered.
Cheers
Stuart




- ------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this transmission is legally privileged and confidential, intended only for the use of the individual(s) or entities named above. This email and any files transmitted with it are the property of Pelco. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you receive this communication in error, please notify us immediately by telephone call to +1-559-292-1981 or forward the e-mail to administrator at pelco.com and then permanently delete the e-mail and destroy all soft and hard copies of the message and any attachments. Thank you for your cooperation. 
- ------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20080624/f9e9ba28/attachment.html>


More information about the live-devel mailing list