[Live-devel] Limiting frame rate for a source

Ross Finlayson finlayson at live555.com
Tue Apr 22 13:20:11 PDT 2014


> I was hoping that there was some built in rate limitation that only caused doGetNextFrame()
> to get called when a new frame was needed. 

No, it's the data source that decides when it delivers data.  There are two possible ways to do this:

If your data source class encodes and delivers a frame immediately when "doGetNextFrame()" is called, then presumably you are also setting "fDurationInMicroseconds" before you complete delivery to the downstream object (using "FramedSource::afterGetting()").  (If you are encoding/delivering a frame immediately, but *not* setting "fDurationInMicroseconds", then "fDurationInMicroseconds" is staying at its default value of 0, and you will be delivering frames as fast as you can generate them, which is bad :-)  In this case, to change the frame rate, just change the value of "fDurationInMicroseconds".

If, however, you want your data source class to not encode/deliver a frame immediately, but instead wait for the encoder to make a new frame available, then - as you noted - the encoder will need to be a separate thread of control (so that you don't delay, waiting for the encoded frame to come available).  In this case you would implement your 'data source' class similar to the demo code that's in "DeviceSource.cpp".  Note that in this code's "doGetNextFrame()" implementation, if no frame is immediately available to be delivered, we return immediately (i.e., do not block).  Instead, we rely upon a separate thread of control (the encoder thread) later 'signaling' the availability of a new frame - e.g., using "TaskScheduler::triggerEvent()".  (Note that "triggerEvent()" is the *only* LIVE555 function that can be called from a non-LIVE555 event loop thread.)


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140422/3f30e04d/attachment.html>


More information about the live-devel mailing list