[Live-devel] implementing new device capture

Baldine, Illia ibaldine at rti.org
Tue Aug 30 14:45:50 PDT 2005


That's what I thought. Thanks for the input. And thank you for great
work too. Real pleasure to work with your code.
-ilia

-----Original Message-----
From: live-devel-bounces at ns.live.com
[mailto:live-devel-bounces at ns.live.com] On Behalf Of Ross Finlayson
Sent: Tuesday, August 30, 2005 1:42 PM
To: LIVE.COM Streaming Media - development & use
Subject: Re: [Live-devel] implementing new device capture


>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/>

_______________________________________________
live-devel mailing list
live-devel at lists.live.com
http://lists.live.com/mailman/listinfo/live-devel



More information about the live-devel mailing list