[Live-devel] Run a method when streaming starts for another client?

Ross Finlayson finlayson at live555.com
Thu Aug 13 15:31:37 PDT 2015


> On Aug 13, 2015, at 5:16 AM, Usama Shah <usama.shah at gorillabox.net> wrote:
> 
> I need to send some extra data `sendIframes` when a new client connects to our RTSP server. This is what I have found and done so far
> 
>     env->taskScheduler().scheduleDelayedTask(5000000, (TaskFunc*)sendIframes, NULL); //failed
>     //delaying is useless as we need to send only to the new client connects
> 
>     EventTriggerId eId = env->taskScheduler().createEventTrigger((TaskFunc*)sendIframes); 
>     env->taskScheduler().triggerEvent(eId,NULL);//failed
>     //how do we trigger it when new client connects or when streaming starts for the new client?
> 
>     env->taskScheduler().setBackgroundHandling(0, SOCKET_READABLE|SOCKET_WRITABLE,(TaskScheduler::BackgroundHandlerProc*)&sendIframes,NULL);//how to use this?
>     //this looks like the right way to do what we want but how exactly?
>     
>     env->taskScheduler().doEventLoop(); // does not return
>     
> `doEventLoop()` handles new connections and send stream to the new clients all be itself.
> 
> At the moment only thing I can think of is to edit the source code of Live555. 

You should not need to do this (especially if you want support on this mailing list).

If you don’t have “reuseFirstSource” set to True in your “OnDemandServerMediaSubsession” subclass(es), then a new instance of your media source object will be created each time a new client connects.  In that case you can simply insert the ‘I frames’ at the start of the data that your media source object delivers.

If, however, you have "reuseFirstSource” set to True in your “OnDemandServerMediaSubsession” subclass(es) - e.g., because you’re streaming from a live source - then things get more complicated (because the media source object doesn’t learn directly when the 2nd (and later) concurrent client connects to the server).  In that case, you could subclass your “RTSPServer”, and reimplement either the
	createNewClientSession()
virtual function (which gets called after each client’s first “SETUP” command), or the
	RTSPClientSession::handleCmd_PLAY()
virtual function (which gets called each each client’s “PLAY” command).


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/20150813/98ae3927/attachment.html>


More information about the live-devel mailing list