Ocean
|
This class implements a simple video decoder for Android using encoded media samples from memory as input. More...
Public Member Functions | |
VideoDecoder () | |
Default constructor creating an un-initialized decoder. More... | |
VideoDecoder (VideoDecoder &&videoDecoder) noexcept | |
Move constructor. More... | |
~VideoDecoder () | |
Destructs the video decoder and releases all associated resources. More... | |
bool | initialize (const std::string &mime, const unsigned int width, const unsigned int height) |
bool | start () |
Starts the video decoder. More... | |
bool | stop () |
Stops the video decoder. More... | |
bool | pushSample (const void *data, const size_t size, const uint64_t presentationTime) |
Adds a new media sample which needs to be decoded to the video decoder. More... | |
Frame | popFrame (int64_t *presentationTime=nullptr) |
Optional the frame's presentation time will be returned, this is the presentation time which was used when the corresponding sample was provided in decodedSample(). More... | |
bool | isInitialized () const |
Returns whether this decode is initialized. More... | |
bool | isStarted () const |
Returns whether this decoder is currently running. More... | |
void | release () |
Explicitly releases this video encoder. More... | |
VideoDecoder & | operator= (VideoDecoder &&videoDecoder) noexcept |
Move operator. More... | |
Static Public Member Functions | |
static Frame | extractVideoFrameFromCodecOutputBuffer (AMediaCodec *const mediaCodec, int64_t *presentationTime=nullptr) |
Extracts the video frame from an output buffer of a video codec. More... | |
Protected Member Functions | |
VideoDecoder (const VideoDecoder &)=delete | |
Disabled copy constructor. More... | |
VideoDecoder & | operator= (const VideoDecoder &)=delete |
Disabled copy operator. More... | |
Protected Attributes | |
NativeMediaLibrary::ScopedSubscription | nativeMediaLibrarySubscription_ |
The subscription for the native media library. More... | |
NativeMediaLibrary::ScopedAMediaCodec | decoder_ |
The Android media decoder used to decode the video. More... | |
bool | isStarted_ = false |
True, if the decoder is currently started. More... | |
Lock | lock_ |
The decoder's lock. More... | |
This class implements a simple video decoder for Android using encoded media samples from memory as input.
Usage:
Ocean::Media::Android::VideoDecoder::VideoDecoder | ( | ) |
Default constructor creating an un-initialized decoder.
|
inlinenoexcept |
Move constructor.
videoDecoder | The decoder to be moved |
Ocean::Media::Android::VideoDecoder::~VideoDecoder | ( | ) |
Destructs the video decoder and releases all associated resources.
|
protecteddelete |
Disabled copy constructor.
|
static |
Extracts the video frame from an output buffer of a video codec.
mediaCodec | The media codec to which the output buffer belongs, must be valid |
presentationTime | Optional resulting presentation time in micro seconds, with range (-infinity, infinity) |
bool Ocean::Media::Android::VideoDecoder::initialize | ( | const std::string & | mime, |
const unsigned int | width, | ||
const unsigned int | height | ||
) |
mime | The MIME type (Multipurpose Internet Mail Extensions) of the video to be decoded, e.g., "video/avc", "video/hevc", ... |
width | The width of the video to be decoded, in pixel, with range [1, infinity) |
height | The height of the video to be decoded, in pixel, with range [1, infinity) |
|
inline |
|
inline |
|
protecteddelete |
Disabled copy operator.
|
inlinenoexcept |
Move operator.
videoDecoder | The video decoder to be moved |
Frame Ocean::Media::Android::VideoDecoder::popFrame | ( | int64_t * | presentationTime = nullptr | ) |
Optional the frame's presentation time will be returned, this is the presentation time which was used when the corresponding sample was provided in decodedSample().
presentationTime | Optional resulting presentation time in micro seconds, with range (-infinity, infinity) |
bool Ocean::Media::Android::VideoDecoder::pushSample | ( | const void * | data, |
const size_t | size, | ||
const uint64_t | presentationTime | ||
) |
Adds a new media sample which needs to be decoded to the video decoder.
The decoder needs to be initialized and started.
The presentation time is mainly intended to allow associating the provided encoded media sample with the resulting decoded frame when calling popFrame().
However, it's recommended to define a reasonable presentation time for each sample (e.g., let the first sample start at 0 and increment the time by 1^6/fps for each following sample.
data | The data of the encoded media sample, must be valid |
size | The size of the encoded media sample, in bytes, with range [1, infinity) |
presentationTime | The presentation time of the sample, in microseconds, with range [0, infinity) |
void Ocean::Media::Android::VideoDecoder::release | ( | ) |
Explicitly releases this video encoder.
If the encoder is still running, the encoder will be stopped as well.
bool Ocean::Media::Android::VideoDecoder::start | ( | ) |
bool Ocean::Media::Android::VideoDecoder::stop | ( | ) |
Stops the video decoder.
|
protected |
The Android media decoder used to decode the video.
|
protected |
True, if the decoder is currently started.
|
mutableprotected |
The decoder's lock.
|
protected |
The subscription for the native media library.