This class provices the actual audio/video decoder for the video player. More...
#include <VideoDisplay/AVDecoder.hpp>
Classes | |
| class | Options |
| Video and audio parameters for AVDecoder when opening a new media file. More... | |
| class | SeekRequest |
| Seeking request that can be sent to the decoder. More... | |
Public Types | |
| typedef Valuable::State< State > | DecoderState |
| State class used in the decoder. | |
|
typedef Radiant::FlagsT < ErrorFlagsEnum > | ErrorFlags |
| enum | ErrorFlagsEnum { ERROR_VIDEO_FRAME_BUFFER_UNDERRUN = 1 << 0 } |
| enum | PlayMode { PAUSE, PLAY } |
| Decoder playing state. More... | |
| enum | SeekDirection { SEEK_ANY_DIRECTION = 0, SEEK_ONLY_FORWARD, SEEK_ONLY_BACKWARD } |
| Seeking direction constraint for SeekRequest. More... | |
| enum | SeekFlags { SEEK_FLAGS_NONE = 0, SEEK_REAL_TIME } |
| Seeking flags. More... | |
| enum | SeekType { SEEK_NONE = 0, SEEK_BY_SECONDS, SEEK_RELATIVE, SEEK_BY_BYTES } |
| Describes the unit used in SeekRequest. More... | |
| enum | State { STATE_LOADING = 1 << 1, STATE_HEADER_READY = 1 << 2, STATE_READY = 1 << 3, STATE_ERROR = 1 << 4, STATE_FINISHED = 1 << 5 } |
| AVDecoder loading state. More... | |
Public Types inherited from Radiant::Thread | |
| typedef void * | id_t |
| Thread id type. More... | |
Public Member Functions | |
| virtual void | close ()=0 |
| Marks the decoder for shutting down, doesn't block. | |
| virtual double | duration () const =0 |
| First this value is based on stream headers, but might be fine-tuned after the stream reaches to the end / maybe starts a new loop cycle. More... | |
| bool | finished () const |
| Checks if decoder has done running. More... | |
| virtual VideoFrame * | getFrame (const Timestamp &ts, ErrorFlags &errors) const =0 |
| Gets a video frame from buffer that should be visible at the given timestamp. More... | |
| virtual Timestamp | getTimestampAt (const Radiant::TimeStamp &ts) const =0 |
| Based on the current playback and audio state, converts an absolute wall-clock timestamp to video timestamp. More... | |
| bool | hasError () const |
| Checks if there has been an unrecoverable error. More... | |
| bool | isHeaderReady () const |
| Has the decoder opened the media file correctly. More... | |
| virtual bool | isLooping () const =0 |
| virtual Timestamp | latestDecodedVideoTimestamp () const =0 |
| Decoder might have many frames in a buffer, this is the video timestamp of the latest decoded frame in that buffer. More... | |
| virtual void | panAudioTo (Nimble::Vector2f location) const =0 |
| Sets audio panning to specific location. More... | |
| virtual PlayMode | playMode () const =0 |
| virtual bool | realTimeSeeking () const =0 |
| Special mode for low-latency seeking without buffering. More... | |
| virtual int | releaseOldVideoFrames (const Timestamp &ts, bool *eof=nullptr)=0 |
| Deletes older video frames from the buffer, this needs to be called after the frame has been consumed, otherwise the buffer will fill quickly. More... | |
| virtual void | seek (const SeekRequest &req)=0 |
| Schedules a seek. More... | |
| void | seek (double seconds) |
| Shorthand for making absolute seeking request. More... | |
| void | seekRelative (double pos) |
| Shorthand for making a relative seek request. More... | |
| virtual void | setAudioGain (float gain)=0 |
| Controls the gain (volume) of the video sound-track. More... | |
| virtual void | setLooping (bool doLoop)=0 |
| virtual void | setPlayMode (PlayMode mode)=0 |
| void | setPreviousDecoder (std::shared_ptr< AVDecoder > decoder) |
| This decoder might require that the previous version of the decoder should be first deleted. More... | |
| virtual void | setRealTimeSeeking (bool value)=0 |
| DecoderState & | state () |
| Current decoder state. More... | |
| const DecoderState & | state () const |
| Current decoder state. More... | |
| virtual Nimble::Size | videoSize () const =0 |
| Decoded video resolution. More... | |
| virtual Nimble::Matrix4f | yuvMatrix () const =0 |
| YUV to RGB conversion matrix using the active video color profile. More... | |
| virtual | ~AVDecoder () |
| Deletes the decoder, blocks until all decoder threads have died. | |
Public Member Functions inherited from Radiant::Thread | |
| bool | isRunning () const |
| Check if the thread is running. More... | |
| void | run () |
| Starts the thread. | |
| void | setName (const QString &name) |
| Set the thread name. More... | |
| Thread (const QString &name="Radiant::Thread") | |
| Construct a thread structure. More... | |
| bool | waitEnd (int timeoutms=0) |
| Waits until thread is finished. More... | |
| virtual | ~Thread () |
| Destructor. More... | |
Static Public Member Functions | |
| static std::shared_ptr< AVDecoder > | create (const Options &options, const QString &backend="") |
| Creates a new decoder and loads it with given options. More... | |
Static Public Member Functions inherited from Radiant::Thread | |
| static id_t | myThreadId () |
| The id of the calling thread. More... | |
Protected Member Functions | |
| AVDecoder () | |
| Constructs a new empty decoder, load() function will always be called after this. | |
| virtual void | load (const Options &options)=0 |
| Initializes the decoder, but doesn't start the decoder thread. More... | |
| virtual void | runDecoder ()=0 |
| Run the actual decoder, called from the decoder thread. | |
This class provices the actual audio/video decoder for the video player.
To use this class, first make a new instance with create() and then start the decoder thread with run().
Seeking direction constraint for SeekRequest.
This eliminates twitching while seeking.
| Enumerator | |
|---|---|
| SEEK_ANY_DIRECTION |
No limitations on the seeking. |
| SEEK_ONLY_FORWARD |
Only seek forward in the stream. |
| SEEK_ONLY_BACKWARD |
Only seek backward in the stream. |
Describes the unit used in SeekRequest.
Not all of these might be supported by the demuxer or video / audio codecs.
AVDecoder loading state.
|
static |
Creates a new decoder and loads it with given options.
| options | options given to load() |
| backend | use empty string for automatic backend |
|
pure virtual |
First this value is based on stream headers, but might be fine-tuned after the stream reaches to the end / maybe starts a new loop cycle.
Implemented in VideoDisplay::LibavDecoder.
| bool VideoDisplay::AVDecoder::finished | ( | ) | const |
Checks if decoder has done running.
|
pure virtual |
Gets a video frame from buffer that should be visible at the given timestamp.
If this frame can't be found, then the closest frame will be used.
| ts | video timestamp | |
| [out] | errors | ErrorFlags |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Based on the current playback and audio state, converts an absolute wall-clock timestamp to video timestamp.
This is most useful for video/audio synchronization
| ts | real (wall-clock) timestamp |
Implemented in VideoDisplay::LibavDecoder.
| bool VideoDisplay::AVDecoder::hasError | ( | ) | const |
Checks if there has been an unrecoverable error.
| bool VideoDisplay::AVDecoder::isHeaderReady | ( | ) | const |
Has the decoder opened the media file correctly.
When this is true, videoSize() will return valid size
|
pure virtual |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Decoder might have many frames in a buffer, this is the video timestamp of the latest decoded frame in that buffer.
Implemented in VideoDisplay::LibavDecoder.
|
protectedpure virtual |
Initializes the decoder, but doesn't start the decoder thread.
| options | opening options |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Sets audio panning to specific location.
| location | 2D location of the audio |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Special mode for low-latency seeking without buffering.
This should be used only with certain UI elements, where the seeking target might change in real-time. When in real-time seeking mode, the video acts like it's paused
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Deletes older video frames from the buffer, this needs to be called after the frame has been consumed, otherwise the buffer will fill quickly.
| ts | timestamp of the previous consumed frame |
| eof | null or pointer to bool that will be set to true if the stream is at EOF |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
Schedules a seek.
If the previous request is still waiting, new request will replace the old one
| req | new seek request |
Implemented in VideoDisplay::LibavDecoder.
|
inline |
Shorthand for making absolute seeking request.
| seconds | timestamp in seconds |
|
inline |
Shorthand for making a relative seek request.
| pos | relative position, value should be between 0 and 1 |
|
pure virtual |
Controls the gain (volume) of the video sound-track.
| gain | new audio gain, typical range is 0-1, although larger values can be used as well. Default value is 1. |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
| doLoop | new looping mode |
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
| mode | new play mode |
Implemented in VideoDisplay::LibavDecoder.
| void VideoDisplay::AVDecoder::setPreviousDecoder | ( | std::shared_ptr< AVDecoder > | decoder | ) |
This decoder might require that the previous version of the decoder should be first deleted.
Since it might block take a long time, this decoder is deleted in the child loop of the new decoder
| decoder | old decoder that will deleted before this decoder is started, assuming that there are no more references to the old decoder outside this class. |
|
pure virtual |
| value | true if real-time seeking is asked |
Implemented in VideoDisplay::LibavDecoder.
| DecoderState& VideoDisplay::AVDecoder::state | ( | ) |
Current decoder state.
| const DecoderState& VideoDisplay::AVDecoder::state | ( | ) | const |
Current decoder state.
|
pure virtual |
Decoded video resolution.
Will return invalid Nimble::Size if isHeaderReady returns false, we are not decoding a video stream, or if video decoding is disabled.
Implemented in VideoDisplay::LibavDecoder.
|
pure virtual |
YUV to RGB conversion matrix using the active video color profile.
This can be used directly in GLSL: vec4 rgb = m * vec4(y, u, v, 1.0);
Implemented in VideoDisplay::LibavDecoder.