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

macOS zero-copy encode device that forwards NV12 frames from AVFoundation to FFmpeg. More...

#include <src/platform/macos/nv12_zero_device.h>

Inheritance diagram for platf::nv12_zero_device:
Collaboration diagram for platf::nv12_zero_device:

Public Types

using pixel_format_fn_t = std::function<void(AVVideo *display, int pixelFormat)>
 Callback signature used to update the opaque AVFoundation pixel format.
using resolution_fn_t = std::function<void(AVVideo *display, int width, int height)>
 Callback signature used to update the opaque AVFoundation display resolution.
Public Types inherited from platf::avcodec_encode_device_t
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

int convert (img_t &img) override
 Forward a captured AVFoundation frame to FFmpeg without copying.
int init (AVVideo *capture_display, pix_fmt_e pix_fmt, resolution_fn_t set_resolution, const pixel_format_fn_t &pixel_format_fn)
 Initialize zero-copy NV12 encoding for an AVFoundation display.
int set_frame (AVFrame *new_frame, AVBufferRef *hw_frames_ctx) override
 Attach frame resources used by the next conversion or encode operation.
Public Member Functions inherited from platf::avcodec_encode_device_t
virtual void apply_colorspace ()
 Apply the configured colorspace metadata to the active frame.
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.

Public Attributes

resolution_fn_t resolution_fn
 Callback stored for later AVFoundation resolution updates.
Public Attributes inherited from platf::avcodec_encode_device_t
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

macOS zero-copy encode device that forwards NV12 frames from AVFoundation to FFmpeg.

Member Function Documentation

◆ convert()

int platf::nv12_zero_device::convert ( platf::img_t & img)
overridevirtual

Forward a captured AVFoundation frame to FFmpeg without copying.

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

Reimplemented from platf::avcodec_encode_device_t.

◆ init()

int platf::nv12_zero_device::init ( AVVideo * capture_display,
pix_fmt_e pix_fmt,
resolution_fn_t set_resolution,
const pixel_format_fn_t & pixel_format_fn )

Initialize zero-copy NV12 encoding for an AVFoundation display.

Parameters
capture_displayDisplay object or identifier associated with the operation.
pix_fmtSunshine pixel format to convert or allocate for.
set_resolutionCallback used to resize the AVFoundation capture output.
pixel_format_fnPixel format.
Returns
0 on success; nonzero or negative platform status on failure.

◆ set_frame()

int platf::nv12_zero_device::set_frame ( AVFrame * new_frame,
AVBufferRef * hw_frames_ctx )
overridevirtual

Attach frame resources used by the next conversion or encode operation.

Parameters
new_frameVideo or graphics frame being processed.
hw_frames_ctxFFmpeg hardware frames context associated with the frame.
Returns
Status from updating frame.

Reimplemented from platf::avcodec_encode_device_t.


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