Valkka  1.6.1
OpenSource Video Management
Public Member Functions | List of all members
AVThread Class Reference

A thread consuming frames and feeding them to various encoders. More...

#include <avthread.h>

Inheritance diagram for AVThread:
Inheritance graph
[legend]
Collaboration diagram for AVThread:
Collaboration graph
[legend]

Public Member Functions

 AVThread (const char *name, FrameFilter &outfilter, FrameFifoContext fifo_ctx=FrameFifoContext())
 Default constructor. More...
 
virtual ~AVThread ()
 Default destructor. Calls AVThread::stopCall // <pyapi>
 
- Public Member Functions inherited from DecoderThread
 DecoderThread (const char *name, FrameFilter &outfilter, FrameFifoContext fifo_ctx=FrameFifoContext())
 Default constructor. More...
 
virtual ~DecoderThread ()
 Default destructor. Calls AVThread::stopCall // <pyapi>
 
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 (AVSignalContext signal_ctx)
 Redefined : Thread::SignalContext has been changed to AVThread::SignalContext.
 
void setTimeCorrection (bool val)
 Set number of decoding threads. More...
 
FifoFrameFiltergetFrameFilter ()
 
FifoFrameFiltergetBlockingFrameFilter ()
 
void setTimeTolerance (long int mstol)
 API method: decoder will scrap late frames that are mstol milliseconds late. Call before starting the thread. // <pyapi>
 
void setNumberOfThreads (int n_threads)
 
void decodingOnCall ()
 API method: enable decoding // <pyapi>
 
void decodingOffCall ()
 API method: pause decoding // <pyapi>
 
void requestStopCall ()
 API method: Like Thread::stopCall() but does not block. // <pyapi>
 
- 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.
 

Additional Inherited Members

- Protected Member Functions inherited from DecoderThread
virtual DecoderchooseAudioDecoder (AVCodecID codec_id)
 
virtual DecoderchooseVideoDecoder (AVCodecID codec_id)
 Chooses a video decoder.
 
virtual DecoderfallbackAudioDecoder (AVCodecID codec_id)
 
virtual DecoderfallbackVideoDecoder (AVCodecID codec_id)
 If the the video decoder obtained from chooseVideoDecoder fails for some reason, provide a fallback video decoder instead.
 
FrameFifogetFifo ()
 
void handleSignals ()
 
- 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)
 
- Protected Attributes inherited from DecoderThread
FrameFifo infifo
 Incoming frames are read from here.
 
FifoFrameFilter infilter
 Write incoming frames here.
 
BlockingFifoFrameFilter infilter_block
 Incoming frames can also be written here. If stack runs out of frames, writing will block.
 
int n_threads
 
FrameFilteroutfilter
 Outgoing, decoded frames are written here.
 
std::vector< Decoder * > decoders
 A vector/list of registered and instantiated decoders.
 
long int mstimetolerance
 Drop frames if they are in milliseconds this much late.
 
AbstractFileState state
 Seek, play, stop or what.
 
std::vector< SetupFramesetupframes
 Save decoder(s) setup information.
 
bool is_decoding
 should currently decode or not
 
std::deque< AVSignalContextsignal_fifo
 Redefinition of signal fifo.
 
- 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< SignalContextsignal_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
 

Detailed Description

A thread consuming frames and feeding them to various encoders.

This class implements a "consumer & producer" thread: it reads Frame instances from a FrameFifo, decodes them and writes them to an outbound FrameFilter

Each arriving frame is inspected for its subsession index, i.e. for Frame.subsession_index and passed on to the adequate decoder, which are warehoused in AVThread::decoders. This vector/list is initialized by sending special "setup frames" to AVThread. These frames correspond to frametype FrameType::setup, and they are typically sent by the LiveThread after an rtsp negotiation

See also Code walkthrough: rendering

Constructor & Destructor Documentation

◆ AVThread()

AVThread::AVThread ( const char *  name,
FrameFilter outfilter,
FrameFifoContext  fifo_ctx = FrameFifoContext() 
)

Default constructor.

Parameters
nameName of the thread
outfilterOutgoing frames are written here. Outgoing frames may be of type FrameType::avframe
fifo_ctxParametrization of the internal FrameFifo

The documentation for this class was generated from the following files: