Valkka
1.6.1
OpenSource Video Management
|
Thread that caches frames and streams them into output at play speed. More...
#include <cachestream.h>
Public Member Functions | |
FileCacheThread (const char *name) | |
void | run () |
Main execution loop is defined here. | |
void | preRun () |
Called before entering the main execution loop, but after creating the thread. | |
void | postRun () |
Called after the main execution loop exits, but before joining the thread. | |
void | sendSignal (FileCacheSignalContext signal_ctx) |
void | switchCache () |
void | dumpPlayCache () |
void | dumpTmpCache () |
void | sendSetupFrames (SetupFrame *f) |
Sends SetupFrame s to all active slots. | |
void | stopStreams (bool send_state=true) |
void | playStreams (bool send_state=true) |
void | setRefTimeAndStop (bool send_state=true) |
Set reference time and set state to stop. | |
void | seekStreams (long int mstimestamp, bool clear, bool send_state=true) |
Sets target time. Sets FileCacheThread::next = NULL. | |
void | clear () |
Removes any reference time. Stops stream. | |
void | setCallback (void func(long int)) |
void | setPyCallback (PyObject *pobj) |
Define callback. More... | |
void | setPyCallback2 (PyObject *pobj) |
Define callback. More... | |
void | registerStreamCall (FileStreamContext &ctx) |
Pass frames downstream. More... | |
void | deregisterStreamCall (FileStreamContext &ctx) |
FrameFilter & | getFrameFilter () |
Framefilter for writing frames to FileCacheThread. | |
void | requestStopCall () |
API method: stops the thread. More... | |
void | dumpCache () |
void | stopStreamsCall () |
void | playStreamsCall () |
void | clearCall () |
void | seekStreamsCall (long int mstimestamp, bool clear=false) |
Seek. More... | |
Public Member Functions inherited from AbstractFileThread | |
AbstractFileThread (const char *name, FrameFifoContext fifo_ctx=FrameFifoContext(10)) | |
Default constructor. More... | |
Public Member Functions inherited from Thread | |
Thread (const char *name) | |
Default constructor. More... | |
~Thread () | |
Destructor:not virtual. More... | |
virtual void | preJoin () |
Called before the thread is joined. | |
virtual void | postJoin () |
Called after the thread has been joined. | |
virtual void | sendSignal (SignalContext signal_ctx) |
Send a signal to the thread. | |
virtual void | sendSignalAndWait (SignalContext signal_ctx) |
Send a signal to the thread and wait for all signals to be executed. | |
void | setAffinity (int i) |
API method for setting the thread affinity. More... | |
void | startCall () |
API method: starts the thread. | |
virtual void | stopCall () |
API method: stops the thread. More... | |
virtual void | waitStopCall () |
API method: waits until the thread is joined. More... | |
virtual void | waitReady () |
Wait until thread has processed all its signals. | |
Protected Attributes | |
ForkFrameFilter | fork |
Write incoming frames here. | |
TypeFrameFilter | typefilter |
SwitchFrameFilter | switchfilter |
CacheFrameFilter | cache_filter_1 |
CacheFrameFilter | cache_filter_2 |
FrameCache | frame_cache_1 |
FrameCache | frame_cache_2 |
FrameCache * | play_cache |
Points to the current play cache (default frame_cache_2) | |
FrameCache * | tmp_cache |
Points to current cache receiving frames. | |
void(* | callback )(long int mstimestamp) |
PyObject * | pyfunc |
Python callback that emits current time. | |
PyObject * | pyfunc2 |
Python callback that emits current loaded time limits. | |
long int | target_mstimestamp_ |
We should be at this time instant (streamtime) | |
Frame * | next |
long int | reftime |
walltime = frametime_ + reftime | |
long int | walltime |
AbstractFileState | state |
SetupFrame | state_setupframe |
SetupFrame for sending the stream state (seek, play, etc.) | |
std::deque< FileCacheSignalContext > | signal_fifo |
Redefinition of signal fifo. | |
std::vector< FrameFilter * > | slots_ |
Slot number => output framefilter mapping. | |
std::vector< std::vector< SetupFrame * > > | setup_frames |
Slot number, subsession_index => SetupFrame mapping. Book-keeping of SetupFrames. | |
Protected Attributes inherited from AbstractFileThread | |
FrameFifo | infifo |
Incoming frames are read from here. | |
FifoFrameFilter | infilter |
Write incoming frames here. | |
Protected Attributes inherited from Thread | |
std::string | name |
Name of the thread. | |
bool | has_thread |
true if thread has been started | |
bool | stop_requested |
bool | thread_joined |
std::mutex | start_mutex |
Mutex protecting start_condition. | |
std::condition_variable | start_condition |
Notified when the thread has been started. | |
std::mutex | mutex |
Mutex protecting the condition variable and signal queue. | |
std::condition_variable | condition |
Condition variable for the signal queue (triggered when all signals processed). Not necessarily used by all subclasses. | |
std::mutex | loop_mutex |
Protects thread's main execution loop (if necessary) | |
std::deque< SignalContext > | signal_fifo |
Signal queue (fifo). Redefine in child classes. | |
bool | loop |
Use this boolean to control if the main loop in Thread:run should exit. | |
int | core_id |
pthread_attr_t | thread_attr |
Thread attributes, pthread_* way. | |
cpu_set_t | cpuset |
pthread_t | internal_thread |
Private Member Functions | |
void | handleSignal (FileCacheSignalContext &signal_ctx) |
void | handleSignals () |
int | safeGetSlot (SlotNumber slot, FrameFilter *&ff) |
void | registerStream (FileStreamContext &ctx) |
void | deregisterStream (FileStreamContext &ctx) |
Additional Inherited Members | |
Protected Member Functions inherited from Thread | |
void | mainRun () |
Does the preRun, run, postRun sequence. | |
void | closeThread () |
Sends exit signal to the thread, calls join. This method blocks until thread has exited. Set Thread::has_thread to false. | |
Static Protected Member Functions inherited from Thread | |
static void * | mainRun_ (void *p) |
Thread that caches frames and streams them into output at play speed.
* * +----> FrameCache * | * +----> SwitchFrameFilter ---+ This part of the framefilter chain is typically * | | driven by another thread (ValkkaFSReaderThread) * | +----> FrameCache * ---> ForkFrameFilter ----+ * | * | * +----> ClassFrameFilter (MarkerFrame) ---> FileCacheThread event loop * *
void FileCacheThread::registerStreamCall | ( | FileStreamContext & | ctx | ) |
Pass frames downstream.
|
virtual |
API method: stops the thread.
Like Thread::stopCall() but does not block. Waiting for the thread to join is done in Thread::waitStoppedCall()
Reimplemented from Thread.
void FileCacheThread::seekStreamsCall | ( | long int | mstimestamp, |
bool | clear = false |
||
) |
Seek.
mstimestamp | The unix millisecond timestamp |
clear | False (default) = Seek within frames already in the cache. Don't clear internal reference time. True = We're expecting a burst of new frames into the cache (new transmission). Clear internal reference time. |
void FileCacheThread::setPyCallback | ( | PyObject * | pobj | ) |
Define callback.
void FileCacheThread::setPyCallback2 | ( | PyObject * | pobj | ) |
Define callback.