Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
platf::avcodec_encode_device_t Struct Reference

AVCodec-backed encode device and frame state. More...

#include <src/platform/common.h>

Inheritance diagram for platf::avcodec_encode_device_t:
Collaboration diagram for platf::avcodec_encode_device_t:

Public Types

using init_hw_device_fn_t = int (*)(avcodec_encode_device_t *encode_device, AVBufferRef **hw_device_buf)
 Callback signature for backend-specific FFmpeg hardware device initialization.

Public Member Functions

virtual void apply_colorspace ()
 Apply the configured colorspace metadata to the active frame.
int convert (platf::img_t &img) override
 Convert a captured image into the encoder input representation.
virtual void init_codec_options (AVCodecContext *ctx, AVDictionary **options)
 Provides a hook for allow platform-specific code to adjust codec options.
virtual void init_hwframes (AVHWFramesContext *frames)
 Initialize the hwframes context.
virtual int prepare_to_derive_context (int hw_device_type)
 Prepare to derive a context.
virtual int set_frame (AVFrame *new_frame, AVBufferRef *hw_frames_ctx)
 Set the frame to be encoded.

Public Attributes

ID3D11Device * d3d11_device = nullptr
 Native D3D11 device borrowed while the encode device is alive.
AVFrame * frame {}
 FFmpeg frame currently owned by the encode device.
bool hardware = false
 Whether this device supplies hardware frames instead of software conversion.
init_hw_device_fn_t init_hw_device = nullptr
 Optional backend-specific hardware device initializer.
Public Attributes inherited from platf::encode_device_t
video::sunshine_colorspace_t colorspace
 Colorspace metadata expected by the encoder.

Detailed Description

AVCodec-backed encode device and frame state.

Member Function Documentation

◆ apply_colorspace()

virtual void platf::avcodec_encode_device_t::apply_colorspace ( )
inlinevirtual

Apply the configured colorspace metadata to the active frame.

Reimplemented in cuda::cuda_t, cuda::gl_cuda_vram_t, platf::dxgi::d3d_avcodec_encode_device_t, va::va_t, video::avcodec_software_encode_device_t, and vk::vk_vram_t.

◆ convert()

int platf::avcodec_encode_device_t::convert ( platf::img_t & img)
inlineoverridevirtual

Convert a captured image into the encoder input representation.

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

Implements platf::encode_device_t.

Reimplemented in cuda::cuda_ram_t, cuda::cuda_vram_t, cuda::gl_cuda_vram_t, platf::dxgi::d3d_avcodec_encode_device_t, platf::nv12_zero_device, va::va_ram_t, va::va_vram_t, video::avcodec_software_encode_device_t, and vk::vk_vram_t.

◆ init_codec_options()

virtual void platf::avcodec_encode_device_t::init_codec_options ( AVCodecContext * ctx,
AVDictionary ** options )
inlinevirtual

Provides a hook for allow platform-specific code to adjust codec options.

Note
Implementations may set or modify codec options prior to codec initialization.
Parameters
ctxNative context object used by the operation or callback.
optionsRequest options or socket options to apply.

Reimplemented in va::va_t, and vk::vk_vram_t.

◆ init_hwframes()

virtual void platf::avcodec_encode_device_t::init_hwframes ( AVHWFramesContext * frames)
inlinevirtual

Initialize the hwframes context.

Note
Implementations may set parameters during initialization of the hwframes context.
Parameters
framesFFmpeg hardware frames context to initialize.

Reimplemented in platf::dxgi::d3d_avcodec_encode_device_t, and vk::vk_vram_t.

◆ prepare_to_derive_context()

virtual int platf::avcodec_encode_device_t::prepare_to_derive_context ( int hw_device_type)
inlinevirtual

Prepare to derive a context.

Note
Implementations may make modifications required before context derivation
Parameters
hw_device_typeFFmpeg hardware device type requested for context derivation.
Returns
0 when context derivation may continue; nonzero to abort.

Reimplemented in platf::dxgi::d3d_avcodec_encode_device_t.

◆ set_frame()

virtual int platf::avcodec_encode_device_t::set_frame ( AVFrame * new_frame,
AVBufferRef * hw_frames_ctx )
inlinevirtual

Set the frame to be encoded.

Note
Implementations must take ownership of 'new_frame'.
Parameters
new_frameVideo or graphics frame being processed.
hw_frames_ctxFFmpeg hardware frames context associated with the frame.
Returns
Status from updating frame.

Reimplemented in cuda::cuda_ram_t, cuda::cuda_t, cuda::gl_cuda_vram_t, platf::dxgi::d3d_avcodec_encode_device_t, platf::nv12_zero_device, va::va_t, video::avcodec_software_encode_device_t, and vk::vk_vram_t.


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