[Live-devel] implementing new device capture

Ross Finlayson finlayson at live.com
Tue Aug 30 11:42:23 PDT 2005


>I'm using an MPEG4 hw encoder and I implemented a DeviceSource-like 
>object for it to capture frames, but I'm having some issues.
>
>Is it a problem if *the very first time* doGetNextFrame() is called 
>for a device and device has no frames yet? It appears this function 
>should simply return (which mine does) if no frames are ready, but 
>it is never invoked again by the scheduler after that.

You need to arrange for that to happen.  If no data is available when 
"goGetNextFrame()" is called, then yes, the right thing to do is to 
just return (*without* calling "deliverFrame()", to use the 
"DeviceSource" code as an example).

However, because no data was available at the time, you must then 
arrange for "deliverFrame()" to be called later, *when* the data 
becomes available.  There are basically three possible ways to do this:
1/ If your input device is a readable socket (this only works on 
Unix, not on Windoze), then you can just call 
"envir().taskScheduler().turnOnBackgroundReadHandling()" to schedule 
a handler function to be called (from within the event loop) when 
data becomes available.  This is the best solution, if you can do it.
2/ If your input device uses some other mechanism for signalling the 
arrival of new data, then you can add this mechanism to the event 
loop, by writing your own "TaskScheduler" subclass, instead of just 
using "BasicTaskScheduler".  (You can usually do this just by 
subclassing "BasicTaskScheduler" and redefining "SingleStep()".)
3/ You can 'poll' for the incoming data, by repeatedly delaying a 
short period of time, then checking for new data - using 
"envir().taskScheduler().scheduleDelayedTask()".  This adds latency 
(the polling interval), but does not require you to write your own 
"TaskScheduler" subclass.


	Ross Finlayson
	LIVE.COM
	<http://www.live.com/>



More information about the live-devel mailing list