[Live-devel] New TaskScheduler 'event trigger' mechanism, and (much) improved "DeviceSource"

Ross Finlayson finlayson at live555.com
Fri Dec 10 22:19:24 PST 2010


One of the biggest problems that developers have had with this 
library is that it has been difficult to define and handle new kinds 
of event - beyond the file/socket I/O and delayed task events that we 
support by default.

In particular, it has been difficult to implement input devices (such 
as encoders) when we want to signal a new event (such as the 
availability of new frame data) from an external thread.  The 'watch 
variable' mechanism - although it can be used - is not particular 
well-suited for this purpose.  Furthermore, the model code in 
"DeviceSource.cpp" has not been particular helpful, because it 
doesn't really describe what to do to handle events that are signaled 
from an external thread.

To overcome this, I have now installed a new version (2010.12.11) of 
the "LIVE555 Streaming Media" library that now includes a new 'event 
trigger' mechanism for "TaskScheduler" (and its subclass, 
"BasicTaskScheduler").

Specifically, you can now - using the new function
	TaskScheduler::createEventTrigger()
- register an event handler function, to be associated with a 
particular 'event trigger id'.  At some later time, you can call
	TaskScheduler:: triggerEvent()
with this 'event trigger id' as parameter, and this will cause the 
event handler function to get called (from within the event loop).

For more details, see "UsageEnvironment/include/UsageEnvironment.hh"

One nice feature of this mechanism is that - unlike other library 
routines - the "triggerEvent()" function can be called from a 
separate thread.  This makes it easier to implement input device 
classes.


I have also updated (and, I hope, significantly improved) the model 
code in "liveMedia/DeviceSource.cpp".  This code describes how to 
implement an input device class that uses the new 'event trigger' 
mechanism (with the event possibly being signaled from an external 
thread).

If you're implementing (or have already implemented) an input device 
class, then I encourage you to take a look at the new "DeviceSource" 
code - and perhaps use this as a model for your code.
-- 

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


More information about the live-devel mailing list