#include <video.h>
Public Types | |
using | OnClearFrameQueueFunction = std::function< void()> |
Full state for either audio or video. Responsible for pulling packets from the packet queue and decoding them into frames.
using OnClearFrameQueueFunction = std::function<void()> |
~AVState | ( | ) |
Destructor
bool addEndOfFilePacket | ( | ) |
Adds the 'end of file' packet to the packet queue. The end of file packet is a special packet with a nullptr for data.
bool addIOFinishedPacket | ( | ) |
Adds the 'I/O finished' packet to the packet queue. This functions as a command to the decode thread.
bool addPacket | ( | AVPacket & | packet | ) |
Adds a packet to the packet queue.
packet | The packet to add. |
bool addSeekEndPacket | ( | double | seekTargetSecs | ) |
Adds the 'seek end' packet to the packet queue. This functions as a command to the decode thread.
bool addSeekStartPacket | ( | ) |
Adds the 'seek start' packet to the packet queue. This functions as a command to the decode thread.
void cancelWaitForEndOfFileProcessed | ( | ) |
Cancel any outstanding waits for end of file to be processed
void cancelWaitForFrameQueueEmpty | ( | ) |
Cancel any outstanding waits for the frame queue to be empty
void clearFrameQueue | ( | ) |
Clears frame queue.
void clearPacketQueue | ( | ) |
Clears packet queue.
void close | ( | ) |
Destroys codec.
void drainSeekFrameQueue | ( | ) |
Consumes all frames in the frame queue until the decode thread needs new packets.
void exitDecodeThread | ( | bool | join | ) |
Stops the decode thread and blocks waiting for it to exit if join is true.
join | If true, the function blocks until the thread is exited, otherwise false. |
AVCodec& getCodec | ( | ) |
AVCodecContext& getCodecContext | ( | ) |
int getStream | ( | ) | const |
void init | ( | int | stream, |
AVCodec * | codec, | ||
AVCodecContext * | codecContext | ||
) |
Initializes stream and codec.
stream | Video or audio stream index. |
codec | codec to use |
codecContext | context associated with the codec |
bool isFinished | ( | ) | const |
bool isValid | ( | ) | const |
bool matchesStream | ( | const AVPacket & | packet | ) | const |
void notifyExitIOThread | ( | ) |
Unblocks synchronization primitives for succesful exit of I/O thread.
void notifyStartIOThread | ( | ) |
Prepares for start of I/O thread, reset synchronization primitives.
Frame peekFrame | ( | ) |
Frame popFrame | ( | ) |
Block until a frame can be popped from the queue.
Frame popSeekFrame | ( | ) |
void resetEndOfFileProcessed | ( | ) |
Reset the state of the end of file processed event so that subsequent waits will wait normally
void resetWaitForFrameQueueEmpty | ( | ) |
Reset the state of the frame queue so that subsequent waits will wait normally
void startDecodeThread | ( | const OnClearFrameQueueFunction & | onClearFrameQueueFunction = OnClearFrameQueueFunction() | ) |
Spawns the decode thread.
onClearFrameQueueFunction | An optional function that can be used to perform additional work when the frame queue is cleared. |
Frame tryPopFrame | ( | double | pts | ) |
Non-blocking popping of the next frame. The pts is checked to see if the next frame is equal or greater than the pts passed. If so, the frame is popped. Otherwise, an empty frame is returned.
pts | The 'current time' that is tested against the frames' PTS. |
bool waitForEndOfFileProcessed | ( | ) |
Blocks until the EOF packet that was added by addEndOfFilePacket is consumed by the decode thread.
bool waitForFrameQueueEmpty | ( | bool & | exitIOThreadSignalled | ) |
Wait for the frame to be empty
exitIOThreadSignalled | When I/O thread is in exit mode, this must be true. |
int waitForReceiveFrame | ( | ) |
Blocks until the decode thread has called avcoded_receive. This is used to perform lock-step production of packets and frames.
void waitSeekStartPacketProcessed | ( | ) |
Blocks until the 'seek start' packet that was added by addSeekStartPacket is consumed by the decode thread.