Puts a frame-buffering layer on top of any other FrameIstream object. More...
#include <Transport/BufferedFrameIstream.H>
Classes | |
struct | Checkpoint |
Public Member Functions | |
BufferedFrameIstream (OptionManager &mgr) | |
virtual void | setConfigInfo (const std::string &cfg) |
Interpret the config string as a specification for our underlying input source. | |
virtual bool | setFrameNumber (int n) |
Pass the frame number on to our underlying frame source. | |
virtual GenericFrameSpec | peekFrameSpec () |
Get the specs of our frames. | |
virtual SimTime | getNaturalFrameTime () const |
Returns the same frame time as our underlying source. | |
virtual void | startStream () |
Start filling our buffer. | |
virtual GenericFrame | readFrame () |
Returns the next frame out of our buffer. |
Puts a frame-buffering layer on top of any other FrameIstream object.
Frames are read from their source in a separate worker thread which fills a frame buffer queue; clients of this class running in the main thread can pull frames out of the queue.
To use this from the command-line with the standard --in option provided by InputFrameSeries, put "buf:" in front of your input spec, like this: --in=buf:frame#.pnm or --in=buf:foo.mpg. Then, the frames will actually be read in a worker thread that puts the frames in a FIFO queue; the main thread can retrieve frames from the queue. Control the number of frames in the queue with --input-buffer-size=N. To wait until the queue is completely filled before starting your main loop, put a startStream() just before the loop.
Definition at line 65 of file BufferedFrameIstream.H.
SimTime BufferedFrameIstream::getNaturalFrameTime | ( | ) | const [virtual] |
Returns the same frame time as our underlying source.
Reimplemented from FrameIstream.
Definition at line 146 of file BufferedFrameIstream.C.
References ASSERT, and ModelComponent::started().
GenericFrameSpec BufferedFrameIstream::peekFrameSpec | ( | ) | [virtual] |
Get the specs of our frames.
Implements FrameIstream.
Definition at line 125 of file BufferedFrameIstream.C.
GenericFrame BufferedFrameIstream::readFrame | ( | ) | [virtual] |
Returns the next frame out of our buffer.
Returns an empty frame if either (1) the input source is exhausted, or (2) the input buffer underflowed prior to the input source being exhausted. It is up to the caller whether to treat premature underflow as a fatal error, or whether to retry after a delay.
Implements FrameIstream.
Definition at line 184 of file BufferedFrameIstream.C.
References ASSERT, rutz::ix86_atomic_int::atomic_decr_return(), rutz::ix86_atomic_int::atomic_get(), OModelParam< T >::getVal(), rutz::circular_queue< T >::pop_front(), and ModelComponent::started().
void BufferedFrameIstream::setConfigInfo | ( | const std::string & | cfg | ) | [virtual] |
Interpret the config string as a specification for our underlying input source.
Reimplemented from FrameIstream.
Definition at line 104 of file BufferedFrameIstream.C.
References ModelComponent::addSubComponent(), ASSERT, makeFrameIstream(), and ModelComponent::removeSubComponent().
bool BufferedFrameIstream::setFrameNumber | ( | int | n | ) | [virtual] |
Pass the frame number on to our underlying frame source.
Reimplemented from FrameIstream.
Definition at line 114 of file BufferedFrameIstream.C.
void BufferedFrameIstream::startStream | ( | ) | [virtual] |
Start filling our buffer.
Reimplemented from FrameIstream.
Definition at line 157 of file BufferedFrameIstream.C.
References ASSERT, rutz::ix86_atomic_int::atomic_get(), sec(), rutz::circular_queue< T >::size(), ModelComponent::started(), and rutz::time::wall_clock_now().