[Live-devel] Adding streams to already-running event loop
Eric Blanpied
eric at sparkalley.com
Wed Nov 12 11:52:28 PST 2014
Hi Ross,
Thanks for your help so far.
I’ve got this working along the lines you’ve described, but the problem I’m running into is a need for some kind of external (to live555 thread) reference to each RTSPClient, in order to trigger other events (stopping one, for example). That’s why I thought about creating the clients outside of the loop, but I can understand why that’s not a good idea. Creating the RTSPClient instance inside the eventTrigger handler doesn’t provide a way to pass a reference back, either (as far as I can tell).
Do you have any recommendation on how to give the main application thread a useful reference to each stream for use with later event triggers? It seems to me that this would be a common desire for an app that handles multiple streams.
thanks,
-e
> On Nov 11, 2014, at 1:07 PM, Ross Finlayson <finlayson at live555.com> wrote:
>
>>
>> myClient = myRTSPClient::createNew(env, url, etc.);
>> ourScheduler->triggerEvent(myRTSPClient::addStreamEventTriggerId, myClient);
>
> Because you are calling “triggerEvent()” from an external thread (again, if you’re in the LIVE555 event loop thread when you decide to create a new stream, then you don’t need event triggers at all), you can’t call “myRTSPClient::createNew()” from within that thread. Instead, the “myRTSPClient::createNew()” call should occur (along with a subsequent “sendDescribeCommand()”) within the event handler function - i.e., within the LIVE555 event loop.
>
> So, to get this, you can do something like:
>
> ///// Within the LIVE555 thread:
>
> void newStreamHandler(void* clientData) {
> char* url = (char*)clientData;
> myRTSPClient* myClient = myRTSPClient::createNew(env, url, etc.);
> myClient->addStreamToLoop();
> }
>
> TaskScheduler* live555TaskScheduler = &(envir().taskScheduler()); // A global variable
> EventTriggerId newStreamEventTrigger = envir().taskScheduler().createEventTrigger(newStreamHandler); // A global variable
> // Note that you need to create only one event trigger
>
> envir().taskScheduler().doEventLoop(); // does not return
>
> ///// Then later, within a separate thread:
>
> live555TaskScheduler->triggerEvent(newStreamEventTrigger, url_for_the_new_stream);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20141112/05cc57c1/attachment.html>
More information about the live-devel
mailing list