[Live-devel] Question about Recursive TaskScheduler::doEventLoop Call
Ross Finlayson
finlayson at live555.com
Mon Jan 11 03:09:15 PST 2021
> On Jan 11, 2021, at 5:56 PM, Mit Shan <shanmingming at itssky.com> wrote:
>
> I want to achieve the following function in live555 RTSP server:
>
> (a). Block for some time in the method "GenericMediaServer::lookupServerMediaSession"
Note that "GenericMediaServer::lookupServerMediaSession” is part of the library code, and thus is not meant to be modified. Instead, you should subclass “RTSPServer”, and reimplement the virtual function “lookupServerMediaSession” in your subclass. (This is what we did for the “DynamicRTSPServer” code in the “mediaServer” directory.)
> One solution, from previous mailing list, is call "TaskScheduler::doEventLoop" with a watch variable in "GenericMediaServer::lookupServerMediaSession"
Again, you would do this in a subclass implementation of “lookupServerMediaSession”; not by modifying the existing code.
> , to block current process, and resume from here when watch variable set.
>
> But I find a problem here: there may be several operation (a) at the same time, which means "TaskScheduler::doEventLoop" is called recursively multiple times, with several watch variable. And earlier used watch variable can only be detected after inner call of "TaskScheduler::doEventLoop" function returns.
>
> Is my understanding correct?
Yes. Unfortunately, the “lookupServerMediaSession” function was meant to be synchronous, so the only way that I can see for it to ‘block’ (handling events) within its implementation is to (recursively) call “doEventLoop()” with a 'watch variable' parameter. This does have the problem that you noted - that if there are subsequent calls to “lookupServerMediaSession” within this event loop, then handling will be LIFO - but I don’t see any alternative.
But perhaps we should step back and ask why you want to block within your implementation of “lookupServerMediaSession”? What are you trying to do here?
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
More information about the live-devel
mailing list