Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
nv12_zero_device.h
Go to the documentation of this file.
1
5#pragma once
6
7// local includes
9
10struct AVFrame;
11
12#ifdef __OBJC__
13@class AVVideo;
14#else
18struct AVVideo;
19#endif
20
21namespace platf {
27 void free_frame(AVFrame *frame);
28
33 AVVideo *display = nullptr;
34
35 public:
36 // this function is used to set the resolution on an av_video object that we cannot
37 // call directly because of namespace collisions between AVFoundation and FFMPEG
41 using resolution_fn_t = std::function<void(AVVideo *display, int width, int height)>;
46 using pixel_format_fn_t = std::function<void(AVVideo *display, int pixelFormat)>;
47
57 int init(AVVideo *capture_display, pix_fmt_e pix_fmt, resolution_fn_t set_resolution, const pixel_format_fn_t &pixel_format_fn);
58
65 int convert(img_t &img) override;
73 int set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx) override;
74
75 private:
77 };
78
79} // namespace platf
macOS zero-copy encode device that forwards NV12 frames from AVFoundation to FFmpeg.
Definition nv12_zero_device.h:32
int convert(img_t &img) override
Forward a captured AVFoundation frame to FFmpeg without copying.
Definition nv12_zero_device.cpp:38
int set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx) override
Attach frame resources used by the next conversion or encode operation.
Definition nv12_zero_device.cpp:57
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.
Definition nv12_zero_device.cpp:67
std::function< void(AVVideo *display, int width, int height)> resolution_fn_t
Callback signature used to update the opaque AVFoundation display resolution.
Definition nv12_zero_device.h:41
resolution_fn_t resolution_fn
Callback stored for later AVFoundation resolution updates.
Definition nv12_zero_device.h:42
std::function< void(AVVideo *display, int pixelFormat)> pixel_format_fn_t
Callback signature used to update the opaque AVFoundation pixel format.
Definition nv12_zero_device.h:46
Declarations for common platform specific utilities.
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:342
AVFoundation video capture controller used by the macOS backend.
Definition av_video.h:23
void free_frame(AVFrame *frame)
Release an FFmpeg frame allocated by the capture or conversion backend.
Definition nv12_zero_device.cpp:22
AVCodec-backed encode device and frame state.
Definition common.h:594
Captured frame buffer shared between capture and encode stages.
Definition common.h:530
uniq_ptr< T, Destroy< T *, void, function > > safe_ptr
Unique pointer using a compile-time C-style destroy function.
Definition utility.h:1590