Sunshine master
Self-hosted game stream host for Moonlight.
video.cpp File Reference

Definitions for video. More...

#include <array>
#include <atomic>
#include <bitset>
#include <list>
#include <thread>
#include <boost/pointer_cast.hpp>
#include <libavutil/imgutils.h>
#include <libavutil/mastering_display_metadata.h>
#include <libavutil/opt.h>
#include <libavutil/pixdesc.h>
#include "cbs.h"
#include "config.h"
#include "display_device.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
#include "nvenc/nvenc_base.h"
#include "platform/common.h"
#include "sync.h"
#include "video.h"
#include <libavutil/hwcontext_d3d11va.h>
Include dependency graph for video.cpp:

Classes

class  video::avcodec_encode_session_t
 FFmpeg AVCodec encode session and parameter-set rewriting state. More...
 
class  video::avcodec_software_encode_device_t
 FFmpeg software encode device used when no hardware frames are required. More...
 
struct  video::capture_ctx_t
 Capture thread context shared with the encoder session. More...
 
struct  video::capture_thread_async_ctx_t
 Asynchronous capture thread state. More...
 
struct  video::capture_thread_sync_ctx_t
 Synchronous capture thread state. More...
 
class  video::nvenc_encode_session_t
 NVENC encode session and device state for hardware encoding. More...
 
struct  video::sync_session_ctx_t
 Context object used while synchronizing encode sessions. More...
 
struct  video::sync_session_t
 Synchronization state for one encode session. More...
 

Typedefs

using video::encode_e = platf::capture_e
 Platform capture status returned by encode operations.
 
using video::encode_session_ctx_queue_t = safe::queue_t<sync_session_ctx_t>
 Queue of encode-session contexts waiting for capture work.
 
typedef int(* video::vaapi_init_avcodec_hardware_input_buffer_fn) (platf::avcodec_encode_device_t *encode_device, AVBufferRef **hw_device_buf)
 Callback signature for VA-API AVCodec hardware input initialization.
 

Enumerations

enum  video::flag_e : uint32_t {
  video::DEFAULT = 0 , video::PARALLEL_ENCODING = 1 << 1 , video::H264_ONLY = 1 << 2 , video::LIMITED_GOP_SIZE = 1 << 3 ,
  video::SINGLE_SLICE_ONLY = 1 << 4 , video::CBR_WITH_VBR = 1 << 5 , video::RELAXED_COMPLIANCE = 1 << 6 , video::NO_RC_BUF_LIMIT = 1 << 7 ,
  video::REF_FRAMES_INVALIDATION = 1 << 8 , video::ALWAYS_REPROBE = 1 << 9 , video::YUV444_SUPPORT = 1 << 10 , video::ASYNC_TEARDOWN = 1 << 11 ,
  video::FIXED_GOP_SIZE = 1 << 12
}
 Enumerates supported flag options. More...
 
enum class  video::qsv::profile_av1_e : int { main = 1 , high = 2 }
 Enumerates supported profile AV1 options. More...
 
enum class  video::nv::profile_h264_e : int { high = 2 , high_444p = 3 }
 Enumerates supported profile h264 options. More...
 
enum class  video::qsv::profile_h264_e : int { high = 100 , high_444p = 244 }
 Enumerates supported profile h264 options. More...
 
enum class  video::nv::profile_hevc_e : int { main = 0 , main_10 = 1 , rext = 2 }
 Enumerates supported profile HEVC options. More...
 
enum class  video::qsv::profile_hevc_e : int { main = 1 , main_10 = 2 , rext = 4 }
 Enumerates supported profile HEVC options. More...
 
enum  video::validate_flag_e { video::VUI_PARAMS = 0x01 }
 Enumerates supported validate flag options. More...
 

Functions

void video::capture (safe::mail_t mail, config_t config, void *channel_data)
 Capture and encode video for a streaming session.
 
void video::capture_async (safe::mail_t mail, config_t &config, void *channel_data)
 Capture and encode video using the asynchronous capture thread.
 
void video::captureThread (std::shared_ptr< safe::queue_t< capture_ctx_t > > capture_ctx_queue, sync_util::sync_t< std::weak_ptr< platf::display_t > > &display_wp, safe::signal_t &reinit_event, const encoder_t &encoder)
 Run the shared display capture thread for asynchronous encoding.
 
void video::captureThreadSync ()
 Run synchronous capture and encode work on the capture thread.
 
util::Either< avcodec_buffer_t, int > video::cuda_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *)
 Create an FFmpeg hardware device buffer for CUDA input.
 
void do_nothing (void *)
 No-op lock callback used when FFmpeg requires a D3D11VA lock function.
 
util::Either< avcodec_buffer_t, int > video::dxgi_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *)
 Create an FFmpeg hardware device buffer for D3D11VA input.
 
int video::encode (int64_t frame_nr, encode_session_t &session, safe::mail_raw_t::queue_t< packet_t > &packets, void *channel_data, std::optional< std::chrono::steady_clock::time_point > frame_timestamp)
 Encode one captured frame and queue packets for transmission.
 
int video::encode_avcodec (int64_t frame_nr, avcodec_encode_session_t &session, safe::mail_raw_t::queue_t< packet_t > &packets, void *channel_data, std::optional< std::chrono::steady_clock::time_point > frame_timestamp)
 Drain encoded packets from an FFmpeg encoder session.
 
int video::encode_nvenc (int64_t frame_nr, nvenc_encode_session_t &session, safe::mail_raw_t::queue_t< packet_t > &packets, void *channel_data, std::optional< std::chrono::steady_clock::time_point > frame_timestamp)
 Encode one frame through NVENC and queue the resulting packet.
 
void video::encode_run (int &frame_nr, safe::mail_t mail, img_event_t images, config_t config, std::shared_ptr< platf::display_t > disp, std::unique_ptr< platf::encode_device_t > encode_device, safe::signal_t &reinit_event, const encoder_t &encoder, void *channel_data)
 Run one encode loop for a display capture stream.
 
encode_e video::encode_run_sync (std::vector< std::unique_ptr< sync_session_ctx_t > > &synced_session_ctxs, encode_session_ctx_queue_t &encode_session_ctx_queue, std::vector< std::string > &display_names, int &display_p)
 Run synchronized capture and encoding.
 
void video::end_capture_async (capture_thread_async_ctx_t &ctx)
 Stop capture async processing.
 
void video::end_capture_sync (capture_thread_sync_ctx_t &ctx)
 Stop capture sync processing.
 
void video::free_buffer (AVBufferRef *ref)
 Release a backend buffer allocated for capture or conversion.
 
void video::free_ctx (AVCodecContext *ctx)
 Release context resources.
 
void video::free_frame (AVFrame *frame)
 Release an FFmpeg frame allocated by the capture or conversion backend.
 
std::unique_ptr< avcodec_encode_session_tvideo::make_avcodec_encode_session (platf::display_t *disp, const encoder_t &encoder, const config_t &config, int width, int height, std::unique_ptr< platf::avcodec_encode_device_t > encode_device)
 Create an AVCodec encode session.
 
std::unique_ptr< platf::encode_device_tvideo::make_encode_device (platf::display_t &disp, const encoder_t &encoder, const config_t &config)
 Create encode device.
 
std::unique_ptr< encode_session_tvideo::make_encode_session (platf::display_t *disp, const encoder_t &encoder, const config_t &config, int width, int height, std::unique_ptr< platf::encode_device_t > encode_device)
 Create encode session.
 
std::unique_ptr< nvenc_encode_session_tvideo::make_nvenc_encode_session (const config_t &client_config, std::unique_ptr< platf::nvenc_encode_device_t > encode_device)
 Create NVENC encode session.
 
input::touch_port_t video::make_port (platf::display_t *display, const config_t &config)
 Create a port object or message.
 
std::optional< sync_session_tvideo::make_synced_session (platf::display_t *disp, const encoder_t &encoder, platf::img_t &img, sync_session_ctx_t &ctx)
 Create synced session.
 
platf::mem_type_e video::map_base_dev_type (AVHWDeviceType type)
 Map base dev type values.
 
platf::pix_fmt_e video::map_pix_fmt (AVPixelFormat fmt)
 Map pix fmt values.
 
int video::probe_encoders ()
 Probe encoders and select the preferred encoder. This is called once at startup and each time a stream is launched to ensure the best encoder is selected. Encoder availability can change at runtime due to all sorts of things from driver updates to eGPUs.
 
void video::refresh_displays (platf::mem_type_e dev_type, std::vector< std::string > &display_names, int &current_display_index)
 Update the list of display names before or during a stream.
 
void video::reset_display (std::shared_ptr< platf::display_t > &disp, const platf::mem_type_e &type, const std::string &display_name, const config_t &config)
 Recreate a display capture object after a capture failure.
 
int video::start_capture_async (capture_thread_async_ctx_t &ctx)
 Start the asynchronous capture thread.
 
int video::start_capture_sync (capture_thread_sync_ctx_t &ctx)
 Start the synchronous multi-client capture thread.
 
util::Either< avcodec_buffer_t, int > video::vaapi_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *)
 Create an FFmpeg hardware device buffer for VA-API input.
 
int video::validate_config (std::shared_ptr< platf::display_t > disp, const encoder_t &encoder, const config_t &config)
 Validate config before it is used.
 
bool video::validate_encoder (encoder_t &encoder, bool expect_failure)
 Validate encoder before it is used.
 
util::Either< avcodec_buffer_t, int > video::vt_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *)
 Create an FFmpeg hardware device buffer for VideoToolbox input.
 
util::Either< avcodec_buffer_t, int > video::vulkan_init_avcodec_hardware_input_buffer (platf::avcodec_encode_device_t *)
 Create an FFmpeg hardware device buffer for Vulkan input.
 

Variables

int video::active_av1_mode
 AV1 mode selected by the most recent encoder probe.
 
int video::active_hevc_mode
 HEVC mode selected by the most recent encoder probe.
 
encoder_t video::amdvce
 Amdvce.
 
auto video::capture_thread_async = safe::make_shared<capture_thread_async_ctx_t>(start_capture_async, end_capture_async)
 Capture thread async.
 
auto video::capture_thread_sync = safe::make_shared<capture_thread_sync_ctx_t>(start_capture_sync, end_capture_sync)
 Capture thread sync.
 
bool video::last_encoder_probe_supported_ref_frames_invalidation = false
 Whether the last probe found reference-frame invalidation support.
 
std::array< bool, 3 > video::last_encoder_probe_supported_yuv444_for_codec = {}
 YUV444 support discovered for each probed codec.
 
encoder_t video::mediafoundation
 Mediafoundation.
 
encoder_t video::nvenc
 NVENC.
 
encoder_t video::quicksync
 Quicksync.
 
encoder_t video::software
 Software.
 
encoder_t video::vaapi
 VA-API.
 
encoder_t video::videotoolbox
 Videotoolbox.
 

Detailed Description

Definitions for video.

Enumeration Type Documentation

◆ flag_e

enum video::flag_e : uint32_t

Enumerates supported flag options.

Enumerator
DEFAULT 

Default flags.

PARALLEL_ENCODING 

Capture and encoding can run concurrently on separate threads.

H264_ONLY 

When HEVC is too heavy.

LIMITED_GOP_SIZE 

Some encoders don't like it when you have an infinite GOP_SIZE. e.g. VAAPI.

SINGLE_SLICE_ONLY 

Never use multiple slices. Older intel iGPU's ruin it for everyone else.

CBR_WITH_VBR 

Use a VBR rate control mode to simulate CBR.

RELAXED_COMPLIANCE 

Use FF_COMPLIANCE_UNOFFICIAL compliance mode.

NO_RC_BUF_LIMIT 

Don't set rc_buffer_size.

REF_FRAMES_INVALIDATION 

Support reference frames invalidation.

ALWAYS_REPROBE 

This is an encoder of last resort and we want to aggressively probe for a better one.

YUV444_SUPPORT 

Encoder may support 4:4:4 chroma sampling depending on hardware.

ASYNC_TEARDOWN 

Encoder supports async teardown on a different thread.

FIXED_GOP_SIZE 

Use fixed small GOP size (encoder doesn't support on-demand IDR frames)

◆ profile_av1_e

enum class video::qsv::profile_av1_e : int
strong

Enumerates supported profile AV1 options.

Enumerator
main 

Main profile.

high 

High profile.

◆ profile_h264_e [1/2]

enum class video::nv::profile_h264_e : int
strong

Enumerates supported profile h264 options.

Enumerator
high 

High profile.

high_444p 

High 4:4:4 Predictive profile.

◆ profile_h264_e [2/2]

enum class video::qsv::profile_h264_e : int
strong

Enumerates supported profile h264 options.

Enumerator
high 

High profile.

high_444p 

High 4:4:4 Predictive profile.

◆ profile_hevc_e [1/2]

enum class video::nv::profile_hevc_e : int
strong

Enumerates supported profile HEVC options.

Enumerator
main 

Main profile.

main_10 

Main 10 profile.

rext 

Rext profile.

◆ profile_hevc_e [2/2]

enum class video::qsv::profile_hevc_e : int
strong

Enumerates supported profile HEVC options.

Enumerator
main 

Main profile.

main_10 

Main 10 profile.

rext 

RExt profile.

◆ validate_flag_e

Enumerates supported validate flag options.

Enumerator
VUI_PARAMS 

VUI parameters.

Function Documentation

◆ capture()

void video::capture ( safe::mail_t mail,
config_t config,
void * channel_data )

Capture and encode video for a streaming session.

Parameters
mailSession mail bus.
configVideo configuration.
channel_dataOpaque channel data passed to packets.

◆ capture_async()

void video::capture_async ( safe::mail_t mail,
config_t & config,
void * channel_data )

Capture and encode video using the asynchronous capture thread.

Parameters
mailSession mail bus.
configVideo configuration.
channel_dataOpaque channel data passed to packets.

◆ captureThread()

void video::captureThread ( std::shared_ptr< safe::queue_t< capture_ctx_t > > capture_ctx_queue,
sync_util::sync_t< std::weak_ptr< platf::display_t > > & display_wp,
safe::signal_t & reinit_event,
const encoder_t & encoder )

Run the shared display capture thread for asynchronous encoding.

Parameters
capture_ctx_queueCapture context queue.
display_wpWeak pointer holder for the active display.
reinit_eventSignal raised while the display is being reinitialized.
encoderSelected encoder.

◆ cuda_init_avcodec_hardware_input_buffer()

util::Either< avcodec_buffer_t, int > video::cuda_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * encode_device)

Create an FFmpeg hardware device buffer for CUDA input.

Initialize AVCodec hardware input buffers for CUDA.

Parameters
encode_deviceEncode device.
Returns
Hardware buffer on success, or an error code on failure.

◆ dxgi_init_avcodec_hardware_input_buffer()

util::Either< avcodec_buffer_t, int > video::dxgi_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * encode_device)

Create an FFmpeg hardware device buffer for D3D11VA input.

Create an FFmpeg D3D11VA hardware device from Sunshine's DXGI device.

Parameters
encode_deviceEncode device.
Returns
Hardware buffer on success, or an error code on failure.

◆ encode()

int video::encode ( int64_t frame_nr,
encode_session_t & session,
safe::mail_raw_t::queue_t< packet_t > & packets,
void * channel_data,
std::optional< std::chrono::steady_clock::time_point > frame_timestamp )

Encode one captured frame and queue packets for transmission.

Parameters
frame_nrFrame nr.
sessionActive streaming or pairing session for the request.
packetsPackets queued or emitted by the stream.
channel_dataChannel data.
frame_timestampFrame timestamp.
Returns
0 when the frame is encoded and queued; nonzero on encoder failure.

◆ encode_avcodec()

int video::encode_avcodec ( int64_t frame_nr,
avcodec_encode_session_t & session,
safe::mail_raw_t::queue_t< packet_t > & packets,
void * channel_data,
std::optional< std::chrono::steady_clock::time_point > frame_timestamp )

Drain encoded packets from an FFmpeg encoder session.

Parameters
frame_nrMonotonic frame index assigned by the video pipeline.
sessionActive FFmpeg encoder session.
packetsOutput queue that receives encoded packets.
channel_dataPlatform or protocol state attached to each packet.
frame_timestampCapture timestamp associated with the encoded frame.
Returns
0 when packets are queued; nonzero when encoding or packetization fails.

◆ encode_nvenc()

int video::encode_nvenc ( int64_t frame_nr,
nvenc_encode_session_t & session,
safe::mail_raw_t::queue_t< packet_t > & packets,
void * channel_data,
std::optional< std::chrono::steady_clock::time_point > frame_timestamp )

Encode one frame through NVENC and queue the resulting packet.

Parameters
frame_nrMonotonic frame index assigned by the video pipeline.
sessionActive NVENC encoder session.
packetsOutput queue that receives the encoded packet.
channel_dataPlatform or protocol state attached to the packet.
frame_timestampCapture timestamp associated with the encoded frame.
Returns
0 when packets are queued; nonzero when NVENC encoding fails.

◆ encode_run()

void video::encode_run ( int & frame_nr,
safe::mail_t mail,
img_event_t images,
config_t config,
std::shared_ptr< platf::display_t > disp,
std::unique_ptr< platf::encode_device_t > encode_device,
safe::signal_t & reinit_event,
const encoder_t & encoder,
void * channel_data )

Run one encode loop for a display capture stream.

Parameters
frame_nrFrame counter updated as frames are encoded.
mailSession mail bus.
imagesCaptured image event source.
configVideo configuration.
dispDisplay being encoded.
encode_devicePlatform encode device.
reinit_eventSignal raised while the encoder/display is reinitializing.
encoderSelected encoder.
channel_dataOpaque channel data passed to packets.

◆ encode_run_sync()

encode_e video::encode_run_sync ( std::vector< std::unique_ptr< sync_session_ctx_t > > & synced_session_ctxs,
encode_session_ctx_queue_t & encode_session_ctx_queue,
std::vector< std::string > & display_names,
int & display_p )

Run synchronized capture and encoding.

Parameters
synced_session_ctxsActive synchronized session contexts.
encode_session_ctx_queuePending synchronized session context queue.
display_namesCached display names.
display_pActive display index.
Returns
Encoder loop result.

◆ end_capture_async()

void video::end_capture_async ( capture_thread_async_ctx_t & ctx)

Stop capture async processing.

Parameters
ctxNative context object used by the operation or callback.

◆ end_capture_sync()

void video::end_capture_sync ( capture_thread_sync_ctx_t & ctx)

Stop capture sync processing.

Parameters
ctxNative context object used by the operation or callback.

◆ free_buffer()

void video::free_buffer ( AVBufferRef * ref)

Release a backend buffer allocated for capture or conversion.

Parameters
refFFmpeg buffer reference to unref and free.

◆ free_ctx()

void video::free_ctx ( AVCodecContext * ctx)

Release context resources.

Release an FFmpeg codec context.

Parameters
ctxCodec context allocated by FFmpeg.

◆ free_frame()

void video::free_frame ( AVFrame * frame)

Release an FFmpeg frame allocated by the capture or conversion backend.

Parameters
frameVideo or graphics frame being processed.

◆ make_avcodec_encode_session()

std::unique_ptr< avcodec_encode_session_t > video::make_avcodec_encode_session ( platf::display_t * disp,
const encoder_t & encoder,
const config_t & config,
int width,
int height,
std::unique_ptr< platf::avcodec_encode_device_t > encode_device )

Create an AVCodec encode session.

Parameters
dispDisplay being encoded.
encoderSelected encoder.
configVideo configuration.
widthEncoded frame width.
heightEncoded frame height.
encode_deviceAVCodec encode device.
Returns
AVCodec encode session, or nullptr on failure.

◆ make_encode_device()

std::unique_ptr< platf::encode_device_t > video::make_encode_device ( platf::display_t & disp,
const encoder_t & encoder,
const config_t & config )

Create encode device.

Parameters
dispDisplay connection or display handle.
encoderEncoder configuration or encoder instance.
configConfiguration values to apply.
Returns
Constructed encode device object.

◆ make_encode_session()

std::unique_ptr< encode_session_t > video::make_encode_session ( platf::display_t * disp,
const encoder_t & encoder,
const config_t & config,
int width,
int height,
std::unique_ptr< platf::encode_device_t > encode_device )

Create encode session.

Parameters
dispDisplay connection or display handle.
encoderEncoder configuration or encoder instance.
configConfiguration values to apply.
widthFrame or display width in pixels.
heightFrame or display height in pixels.
encode_deviceEncode device.
Returns
Constructed encode session object.

◆ make_nvenc_encode_session()

std::unique_ptr< nvenc_encode_session_t > video::make_nvenc_encode_session ( const config_t & client_config,
std::unique_ptr< platf::nvenc_encode_device_t > encode_device )

Create NVENC encode session.

Parameters
client_configClient stream configuration negotiated for this session.
encode_deviceEncode device.
Returns
Constructed NVENC encode session object.

◆ make_port()

input::touch_port_t video::make_port ( platf::display_t * display,
const config_t & config )

Create a port object or message.

Parameters
displayDisplay object or identifier associated with the operation.
configConfiguration values to apply.
Returns
Constructed port object.

◆ make_synced_session()

std::optional< sync_session_t > video::make_synced_session ( platf::display_t * disp,
const encoder_t & encoder,
platf::img_t & img,
sync_session_ctx_t & ctx )

Create synced session.

Parameters
dispDisplay connection or display handle.
encoderEncoder configuration or encoder instance.
imgImage or frame object to read from or populate.
ctxNative context object used by the operation or callback.
Returns
Constructed synced session object.

◆ map_base_dev_type()

platf::mem_type_e video::map_base_dev_type ( AVHWDeviceType type)

Map base dev type values.

Map an FFmpeg hardware device type to Sunshine's memory type.

Parameters
typeFFmpeg hardware device type reported by the encoder backend.
Returns
Sunshine memory type used by the capture and encode pipeline.

◆ map_pix_fmt()

platf::pix_fmt_e video::map_pix_fmt ( AVPixelFormat fmt)

Map pix fmt values.

Map an FFmpeg pixel format to Sunshine's pixel format enum.

Parameters
fmtFFmpeg pixel format to convert.
Returns
Sunshine pixel format used by display and encoder backends.

◆ probe_encoders()

int video::probe_encoders ( )

Probe encoders and select the preferred encoder. This is called once at startup and each time a stream is launched to ensure the best encoder is selected. Encoder availability can change at runtime due to all sorts of things from driver updates to eGPUs.

Warning
This is only safe to call when there is no client actively streaming.
Returns
0 when a usable encoder is selected; nonzero when probing fails.

◆ refresh_displays()

void video::refresh_displays ( platf::mem_type_e dev_type,
std::vector< std::string > & display_names,
int & current_display_index )

Update the list of display names before or during a stream.

This will attempt to keep current_display_index pointing at the same display.

Parameters
dev_typeThe encoder device type used for display lookup.
display_namesThe list of display names to repopulate.
current_display_indexThe current display index or -1 if not yet known.

◆ reset_display()

void video::reset_display ( std::shared_ptr< platf::display_t > & disp,
const platf::mem_type_e & type,
const std::string & display_name,
const config_t & config )

Recreate a display capture object after a capture failure.

Parameters
dispDisplay connection or display handle.
typeProtocol, message, or resource type selector.
display_nameDisplay name.
configConfiguration values to apply.

◆ start_capture_async()

int video::start_capture_async ( capture_thread_async_ctx_t & ctx)

Start the asynchronous capture thread.

Start capture async.

Parameters
ctxNative context object used by the operation or callback.
Returns
0 when the capture thread is started; nonzero on setup failure.

◆ start_capture_sync()

int video::start_capture_sync ( capture_thread_sync_ctx_t & ctx)

Start the synchronous multi-client capture thread.

Start capture sync.

Parameters
ctxNative context object used by the operation or callback.
Returns
0 when the capture thread is started.

◆ vaapi_init_avcodec_hardware_input_buffer()

util::Either< avcodec_buffer_t, int > video::vaapi_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * encode_device)

Create an FFmpeg hardware device buffer for VA-API input.

Initialize AVCodec hardware input buffers for VA-API.

Parameters
encode_deviceEncode device.
Returns
Hardware buffer on success, or an error code on failure.

◆ validate_config()

int video::validate_config ( std::shared_ptr< platf::display_t > disp,
const encoder_t & encoder,
const config_t & config )

Validate config before it is used.

Parameters
dispDisplay connection or display handle.
encoderEncoder configuration or encoder instance.
configConfiguration values to apply.
Returns
0 when the selected encoder/device accepts the configuration; nonzero otherwise.

◆ validate_encoder()

bool video::validate_encoder ( encoder_t & encoder,
bool expect_failure )

Validate encoder before it is used.

Parameters
encoderEncoder configuration or encoder instance.
expect_failureExpect failure.
Returns
True when encoder validation matches expect_failure.

◆ vt_init_avcodec_hardware_input_buffer()

util::Either< avcodec_buffer_t, int > video::vt_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * encode_device)

Create an FFmpeg hardware device buffer for VideoToolbox input.

Initialize AVCodec hardware input buffers for VideoToolbox.

Parameters
encode_deviceEncode device.
Returns
Hardware buffer on success, or an error code on failure.

◆ vulkan_init_avcodec_hardware_input_buffer()

util::Either< avcodec_buffer_t, int > video::vulkan_init_avcodec_hardware_input_buffer ( platf::avcodec_encode_device_t * )

Create an FFmpeg hardware device buffer for Vulkan input.

Returns
Hardware buffer on success, or an error code on failure.