Sunshine master
Self-hosted game stream host for Moonlight.
video::avcodec_encode_session_t Class Reference

FFmpeg AVCodec encode session and parameter-set rewriting state. More...

Inheritance diagram for video::avcodec_encode_session_t:
[legend]
Collaboration diagram for video::avcodec_encode_session_t:
[legend]

Public Member Functions

 avcodec_encode_session_t (avcodec_ctx_t &&avcodec_ctx, std::unique_ptr< platf::avcodec_encode_device_t > encode_device, int inject)
 Initialize an FFmpeg encode session and its hardware encode device.
 
 avcodec_encode_session_t (avcodec_encode_session_t &&other) noexcept=default
 Move an FFmpeg encode session without duplicating codec/device ownership.
 
int convert (platf::img_t &img) override
 Encode one frame with FFmpeg AVCodec and prepare packet replacements.
 
void invalidate_ref_frames (int64_t first_frame, int64_t last_frame) override
 Mark the frame range whose references must be invalidated.
 
avcodec_encode_session_toperator= (avcodec_encode_session_t &&other)
 Assign state from another instance while preserving ownership semantics.
 
void request_idr_frame () override
 Mark the frame as a request for an IDR frame.
 
void request_normal_frame () override
 Mark the frame as a request for a normal inter frame.
 
- Public Member Functions inherited from video::encode_session_t

Public Attributes

avcodec_ctx_t avcodec_ctx
 FFmpeg codec context owned by the encode session.
 
std::unique_ptr< platf::avcodec_encode_device_tdevice
 Platform device used by the FFmpeg hardware encoder.
 
int inject
 Number of upcoming IDR frames that should receive rewritten parameter sets.
 
std::vector< packet_raw_t::replace_treplacements
 NAL-unit byte ranges that must be replaced before packet send.
 
cbs::nal_t sps
 Original and rewritten sequence parameter set for IDR injection.
 
cbs::nal_t vps
 Original and rewritten HEVC video parameter set for IDR injection.
 

Detailed Description

FFmpeg AVCodec encode session and parameter-set rewriting state.

Constructor & Destructor Documentation

◆ avcodec_encode_session_t() [1/2]

video::avcodec_encode_session_t::avcodec_encode_session_t ( avcodec_ctx_t && avcodec_ctx,
std::unique_ptr< platf::avcodec_encode_device_t > encode_device,
int inject )
inline

Initialize an FFmpeg encode session and its hardware encode device.

Parameters
avcodec_ctxOpen FFmpeg codec context for the selected encoder.
encode_devicePlatform encode device that supplies frames to FFmpeg.
injectWhether SPS/VPS replacement data should be injected.

◆ avcodec_encode_session_t() [2/2]

video::avcodec_encode_session_t::avcodec_encode_session_t ( avcodec_encode_session_t && other)
defaultnoexcept

Move an FFmpeg encode session without duplicating codec/device ownership.

Parameters
otherSource object whose state is copied or moved into this object.

Member Function Documentation

◆ convert()

int video::avcodec_encode_session_t::convert ( platf::img_t & img)
inlineoverridevirtual

Encode one frame with FFmpeg AVCodec and prepare packet replacements.

Parameters
imgImage or frame object to read from or populate.
Returns
Conversion status.

Implements video::encode_session_t.

◆ invalidate_ref_frames()

void video::avcodec_encode_session_t::invalidate_ref_frames ( int64_t first_frame,
int64_t last_frame )
inlineoverridevirtual

Mark the frame range whose references must be invalidated.

Parameters
first_frameFirst frame.
last_frameLast frame.

Implements video::encode_session_t.

◆ operator=()

avcodec_encode_session_t & video::avcodec_encode_session_t::operator= ( avcodec_encode_session_t && other)
inline

Assign state from another instance while preserving ownership semantics.

Parameters
otherSource object whose state is copied or moved into this object.
Returns
Reference or value produced by the operator.

◆ request_idr_frame()

void video::avcodec_encode_session_t::request_idr_frame ( )
inlineoverridevirtual

Mark the frame as a request for an IDR frame.

Implements video::encode_session_t.

◆ request_normal_frame()

void video::avcodec_encode_session_t::request_normal_frame ( )
inlineoverridevirtual

Mark the frame as a request for a normal inter frame.

Implements video::encode_session_t.


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