class AvCodecContext

Defined at line 25 of file ../../src/media/codec/codecs/sw/ffmpeg/avcodec_context.h

Wraps AVCodecContext type from ffmpeg.

Public Methods

std::optional<std::unique_ptr<AvCodecContext>> CreateDecoder (const fuchsia::media::FormatDetails & format_details, GetBufferCallback get_buffer_callback)

Creates a decoder context. The decoder context can be used to decode an

elementary stream with successive calls to SendPacket() and

ReceiveFrame() in a loop.

In the case of error, std::nullopt is returned.

A decoder can decode one stream at most. A new decoder context should

be created for new streams.

The get_buffer_callback must provide buffers for each frame. To claim

buffers back when the decoder is done referencing them, set up a free

callback in the AVBufferRef provided to each frame.

Calls to get_buffer_callback may also be redirected to

avcodec_default_get_buffer2 if you have an error state and just want ffmpeg

to gracefully conclude its work.

See ffmpeg's get_buffer2 and av_buffer_create for more details.

Defined at line 25 of file ../../src/media/codec/codecs/sw/ffmpeg/avcodec_context.cc

int SendPacket (const CodecPacket * codec_packet)

Sends a compressed packet to the decoder. The semantics of SendPacket and

ReceiveFrame mirror those of avcodec_send_packet and avcodec_receive_frame

of ffmpeg. Returns an ffmpeg return code.

Defined at line 74 of file ../../src/media/codec/codecs/sw/ffmpeg/avcodec_context.cc

std::pair<int, AVFramePtr> ReceiveFrame ()

Receives a frame from ffmpeg decoder, paired with its ffmpeg return code.

Defined at line 100 of file ../../src/media/codec/codecs/sw/ffmpeg/avcodec_context.cc

int EndStream ()

No further packets may be sent to the decoder after this call. Input data

is not discarded and should still be received with calls to ReceiveFrame

until it is all received. Returns an ffmpeg return code.

Defined at line 117 of file ../../src/media/codec/codecs/sw/ffmpeg/avcodec_context.cc

Records