Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <chrono>
9#include <string_view>
10
11// local includes
12#include "input.h"
13#include "platform/common.h"
14#include "thread_safe.h"
15#include "video_colorspace.h"
16
17extern "C" {
18#include <libavcodec/avcodec.h>
19#include <libswscale/swscale.h>
20}
21
22struct AVPacket;
23
24namespace stream {
25 struct session_t;
26}
27
28namespace video {
29
47
48 namespace amf {
49
53 enum class coder_e : int {
54 auto_ = 0,
55 cabac = 1,
56 cavlc = 2,
57 };
58
59 } // namespace amf
60
69 int select_h264_profile(std::string_view encoder_name, const config_t &config, int amd_coder);
70
77 platf::mem_type_e map_base_dev_type(AVHWDeviceType type);
84 platf::pix_fmt_e map_pix_fmt(AVPixelFormat fmt);
85
91 void free_ctx(AVCodecContext *ctx);
97 void free_frame(AVFrame *frame);
103 void free_buffer(AVBufferRef *ref);
104
124 using img_event_t = std::shared_ptr<safe::event_t<std::shared_ptr<platf::img_t>>>;
125
130 public:
137 int convert(platf::img_t &img) override;
138
147 int set_frame(AVFrame *in_frame, AVBufferRef *hw_frames_ctx) override;
148
152 void apply_colorspace() override;
153
164 int init(int in_width, int in_height, AVFrame *in_frame, AVPixelFormat format, bool hardware);
165
166 private:
170 void prefill();
171
178 int reinit_sws(AVPixelFormat src_format);
179
180 // Store ownership when frame is hw_frame
181 avcodec_frame_t hw_frame;
182
183 avcodec_frame_t sw_frame;
184 avcodec_frame_t sws_input_frame;
185 avcodec_frame_t sws_output_frame;
186 sws_t sws;
187 AVPixelFormat sws_src_format {AV_PIX_FMT_BGR0};
188
189 // Offset of input image to output frame in pixels
190 int offsetW;
191 int offsetH;
192 };
193
205
213 using init_buffer_function_t = std::function<util::Either<avcodec_buffer_t, int>(platf::avcodec_encode_device_t *)>;
214
251
252 AVHWDeviceType avcodec_base_dev_type;
254 AVPixelFormat avcodec_dev_pix_fmt;
255 AVPixelFormat avcodec_pix_fmt_8bit;
256 AVPixelFormat avcodec_pix_fmt_10bit;
259
261 };
262
277 const platf::mem_type_e &device_type,
278 const platf::pix_fmt_e &format_8bit,
279 const platf::pix_fmt_e &format_10bit,
280 const platf::pix_fmt_e &format_yuv444_8bit,
281 const platf::pix_fmt_e &format_yuv444_10bit
282 ) {
288 }
289 };
290
294 struct encoder_t {
295 std::string_view name;
296
309
316 static std::string_view from_flag(flag_e flag) {
317#ifndef DOXYGEN
318 #define _CONVERT(x) \
319 case flag_e::x: \
320 return std::string_view(#x)
321#endif
322 switch (flag) {
323 _CONVERT(PASSED);
324 _CONVERT(REF_FRAMES_RESTRICT);
325 _CONVERT(DYNAMIC_RANGE);
326 _CONVERT(YUV444);
327 _CONVERT(DYNAMIC_RANGE_YUV444);
328 _CONVERT(VUI_PARAMETERS);
329 _CONVERT(MAX_FLAGS);
330 }
331#undef _CONVERT
332
333 return {"unknown"};
334 }
335
339 struct option_t {
344 option_t(const option_t &) = default;
345
346 std::string name;
347 std::variant<int, int *, std::optional<int> *, std::function<int()>, std::string, std::string *, std::function<const std::string(const config_t &)>> value;
348
355 option_t(std::string &&name, decltype(value) &&value):
356 name {std::move(name)},
357 value {std::move(value)} {
358 }
359 };
360
361 const std::unique_ptr<const encoder_platform_formats_t> platform_formats;
362
366 struct codec_t {
367 std::vector<option_t> common_options;
368 std::vector<option_t> sdr_options;
369 std::vector<option_t> hdr_options;
370 std::vector<option_t> sdr444_options;
371 std::vector<option_t> hdr444_options;
372 std::vector<option_t> fallback_options;
373
374 std::string name;
375 std::bitset<MAX_FLAGS> capabilities;
376
383 bool operator[](flag_e flag) const {
384 return capabilities[(std::size_t) flag];
385 }
386
393 std::bitset<MAX_FLAGS>::reference operator[](flag_e flag) {
394 return capabilities[(std::size_t) flag];
395 }
396 };
397
401
408 const codec_t &codec_from_config(const config_t &config) const {
409 switch (config.videoFormat) {
410 default:
411 BOOST_LOG(error) << "Unknown video format " << config.videoFormat << ", falling back to H.264";
412 // fallthrough
413 case 0:
414 return h264;
415 case 1:
416 return hevc;
417 case 2:
418 return av1;
419 }
420 }
421
422 uint32_t flags;
423 };
424
429 virtual ~encode_session_t() = default;
430
437 virtual int convert(platf::img_t &img) = 0;
438
442 virtual void request_idr_frame() = 0;
443
447 virtual void request_normal_frame() = 0;
448
455 virtual void invalidate_ref_frames(int64_t first_frame, int64_t last_frame) = 0;
456 };
457
458 // encoders
459 extern encoder_t software;
460
461#if !defined(__APPLE__)
462 extern encoder_t nvenc; // available for windows and linux
463#endif
464
465#ifdef _WIN32
466 extern encoder_t amdvce;
467 extern encoder_t quicksync;
469#endif
470
471#if defined(__linux__) || defined(linux) || defined(__linux) || defined(__FreeBSD__)
472 extern encoder_t vaapi;
473#endif
474
475#ifdef __APPLE__
476 extern encoder_t videotoolbox;
477#endif
478
483 virtual ~packet_raw_t() = default;
484
490 virtual bool is_idr() = 0;
491
497 virtual int64_t frame_index() = 0;
498
504 virtual uint8_t *data() = 0;
505
511 virtual size_t data_size() = 0;
512
516 struct replace_t {
517 std::string_view old;
518 std::string_view _new;
519
521
522
528 replace_t(std::string_view old, std::string_view _new) noexcept:
529 old {std::move(old)},
530 _new {std::move(_new)} {
531 }
532 };
533
534 std::vector<replace_t> *replacements = nullptr;
537 std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
538 };
539
543 struct packet_raw_avcodec: packet_raw_t {
544 packet_raw_avcodec() {
545 av_packet = av_packet_alloc();
546 }
547
548 ~packet_raw_avcodec() {
549 av_packet_free(&this->av_packet);
550 }
551
557 bool is_idr() override {
558 return av_packet->flags & AV_PKT_FLAG_KEY;
559 }
560
566 int64_t frame_index() override {
567 return av_packet->pts;
568 }
569
575 uint8_t *data() override {
576 return av_packet->data;
577 }
578
584 size_t data_size() override {
585 return av_packet->size;
586 }
587
588 AVPacket *av_packet;
589 };
590
602 packet_raw_generic(std::vector<uint8_t> &&frame_data, int64_t frame_index, bool idr):
603 frame_data {std::move(frame_data)},
605 idr {idr} {
606 }
607
613 bool is_idr() override {
614 return idr;
615 }
616
622 int64_t frame_index() override {
623 return index;
624 }
625
631 uint8_t *data() override {
632 return frame_data.data();
633 }
634
640 size_t data_size() override {
641 return frame_data.size();
642 }
643
644 std::vector<uint8_t> frame_data;
645 int64_t index;
646 bool idr;
647 };
648
652 using packet_t = std::unique_ptr<packet_raw_t>;
653
663 explicit hdr_info_raw_t(bool enabled):
665 metadata {} {};
666
672 explicit hdr_info_raw_t(bool enabled, const SS_HDR_METADATA &metadata):
674 metadata {metadata} {};
675
676 bool enabled;
677 SS_HDR_METADATA metadata;
678 };
679
683 using hdr_info_t = std::unique_ptr<hdr_info_raw_t>;
684
685 extern int active_hevc_mode;
686 extern int active_av1_mode;
688 extern std::array<bool, 3> last_encoder_probe_supported_yuv444_for_codec; // 0 - H.264, 1 - HEVC, 2 - AV1
689
697 config_t resolve_dynamic_range(const encoder_t &encoder, config_t config);
698
706 void capture(
708 config_t config,
709 stream::session_t *channel_data
710 );
711
719 bool validate_encoder(encoder_t &encoder, bool expect_failure);
720
730 int probe_encoders();
731
732 // Several NTSC standard refresh rates are hardcoded here, because their
733 // true rate requires a denominator of 1001. ffmpeg's av_d2q() would assume it could
734 // reduce 29.97 to 2997/100 but this would be slightly wrong. We also include
735 // support for 23.976 film in case someone wants to stream a film at the perfect
736 // framerate.
743 inline AVRational framerateX100_to_rational(const int framerateX100) {
744 if (framerateX100 % 2997 == 0) {
745 // Multiples of NTSC 29.97 e.g. 59.94, 119.88
746 return AVRational {(framerateX100 / 2997) * 30000, 1001};
747 }
748 switch (framerateX100) {
749 case 2397: // the other weird NTSC framerate, assume these want 23.976 film
750 case 2398:
751 return AVRational {24000, 1001};
752 default:
753 // any other fractional rate can be reduced by ffmpeg. Max is set to 1 << 26 based on docs:
754 // "rational numbers with |num| <= 1<<26 && |den| <= 1<<26 can be recovered exactly from their double representation"
755 return av_d2q((double) framerateX100 / 100.0f, 1 << 26);
756 }
757 }
758
767 inline AVRational framerate_to_rational(const config_t &config) {
768 if (config.framerateX100 > 0) {
769 return framerateX100_to_rational(config.framerateX100);
770 }
771 return AVRational {config.framerate, 1};
772 }
773
781 inline std::chrono::nanoseconds capture_frame_interval(const config_t &config) {
782 const AVRational fps = framerate_to_rational(config);
783 return std::chrono::nanoseconds {(static_cast<int64_t>(fps.den) * 1'000'000'000LL) / fps.num};
784 }
785} // namespace video
FFmpeg software encode device used when no hardware frames are required.
Definition video.h:129
int init(int in_width, int in_height, AVFrame *in_frame, AVPixelFormat format, bool hardware)
Initialize FFmpeg software encoding for the requested codec.
Definition video.cpp:330
int convert(platf::img_t &img) override
Convert a captured image into the encoder input representation.
Definition video.cpp:224
void apply_colorspace() override
Apply the configured colorspace metadata to the active frame.
Definition video.cpp:317
int set_frame(AVFrame *in_frame, AVBufferRef *hw_frames_ctx) override
Attach frame resources used by the next conversion or encode operation.
Definition video.cpp:300
Declarations for common platform specific utilities.
mem_type_e
Enumerates supported mem type options.
Definition common.h:329
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:342
void free_frame(AVFrame *frame)
Release an FFmpeg frame allocated by the capture or conversion backend.
Definition graphics.cpp:1539
Declarations for gamepad, keyboard, and mouse input handling.
bl::sources::severity_logger< int > error
Recoverable errors.
Definition logging.cpp:46
Handles process-wide communication.
Definition globals.h:34
Standalone NVENC encoder.
Definition nvenc_base.cpp:185
AVCodec-backed encode device and frame state.
Definition common.h:594
bool hardware
Whether this device supplies hardware frames instead of software conversion.
Definition common.h:595
Captured frame buffer shared between capture and encode stages.
Definition common.h:530
Runtime state for one audio/video streaming session.
Definition stream.cpp:503
Encoding configuration requested by a remote client.
Definition video.h:33
int encoderCscMode
Requested color range and SDR colorspace; HDR always uses BT.2020 and ST2084.
Definition video.h:41
int enableIntraRefresh
Intra refresh setting: 0 = disabled, 1 = enabled.
Definition video.h:45
int framerateX100
Optional NTSC-style framerate value, e.g. 59.94 as 5994.
Definition video.h:37
int videoFormat
Video codec format: 0 = H.264, 1 = HEVC, 2 = AV1.
Definition video.h:42
int width
Video width in pixels.
Definition video.h:34
int bitrate
Video bitrate in kilobits for the requested framerate.
Definition video.h:38
int numRefFrames
Maximum number of reference frames.
Definition video.h:40
int height
Video height in pixels.
Definition video.h:35
int slicesPerFrame
Number of slices per frame.
Definition video.h:39
int framerate
Requested framerate used in the per-frame bitrate budget.
Definition video.h:36
int dynamicRange
Encoding color depth: 0 = 8-bit, 1 = 10-bit.
Definition video.h:43
int chromaSamplingType
Chroma sampling type: 0 = 4:2:0, 1 = 4:4:4.
Definition video.h:44
Encoder session state shared by capture and encoding threads.
Definition video.h:428
virtual int convert(platf::img_t &img)=0
Convert a captured frame into the encoder's required input representation.
virtual void request_idr_frame()=0
Mark the frame as a request for an IDR frame.
virtual void request_normal_frame()=0
Mark the frame as a request for a normal inter frame.
virtual void invalidate_ref_frames(int64_t first_frame, int64_t last_frame)=0
Mark the frame range whose references must be invalidated.
AVPixelFormat avcodec_pix_fmt_8bit
FFmpeg 8-bit 4:2:0 software pixel format for this encoder.
Definition video.h:255
encoder_platform_formats_avcodec(const AVHWDeviceType &avcodec_base_dev_type, const AVHWDeviceType &avcodec_derived_dev_type, const AVPixelFormat &avcodec_dev_pix_fmt, const AVPixelFormat &avcodec_pix_fmt_8bit, const AVPixelFormat &avcodec_pix_fmt_10bit, const AVPixelFormat &avcodec_pix_fmt_yuv444_8bit, const AVPixelFormat &avcodec_pix_fmt_yuv444_10bit, const init_buffer_function_t &init_avcodec_hardware_input_buffer_function)
Construct AVCodec platform format mappings.
Definition video.h:227
AVPixelFormat avcodec_pix_fmt_10bit
FFmpeg 10-bit 4:2:0 software pixel format for this encoder.
Definition video.h:256
AVHWDeviceType avcodec_derived_dev_type
FFmpeg device type derived from the primary hardware context.
Definition video.h:253
AVPixelFormat avcodec_pix_fmt_yuv444_8bit
FFmpeg 8-bit 4:4:4 software pixel format for this encoder.
Definition video.h:257
std::function< util::Either< avcodec_buffer_t, int >(platf::avcodec_encode_device_t *)> init_buffer_function_t
Callback that prepares an FFmpeg hardware input buffer for the encode device.
Definition video.h:213
AVPixelFormat avcodec_pix_fmt_yuv444_10bit
FFmpeg 10-bit 4:4:4 software pixel format for this encoder.
Definition video.h:258
init_buffer_function_t init_avcodec_hardware_input_buffer
Backend hook that allocates or imports hardware frames for FFmpeg.
Definition video.h:260
AVPixelFormat avcodec_dev_pix_fmt
FFmpeg hardware-device pixel format for frames handed to the encoder.
Definition video.h:254
AVHWDeviceType avcodec_base_dev_type
FFmpeg device type used to create the primary hardware context.
Definition video.h:252
encoder_platform_formats_nvenc(const platf::mem_type_e &device_type, const platf::pix_fmt_e &format_8bit, const platf::pix_fmt_e &format_10bit, const platf::pix_fmt_e &format_yuv444_8bit, const platf::pix_fmt_e &format_yuv444_10bit)
Construct NVENC platform format mappings.
Definition video.h:276
Pixel formats supported by one encoder backend.
Definition video.h:197
platf::mem_type_e dev_type
Platform memory type required by this encoder.
Definition video.h:199
platf::pix_fmt_e pix_fmt_10bit
10-bit 4:2:0 input format accepted by this encoder.
Definition video.h:201
platf::pix_fmt_e pix_fmt_yuv444_8bit
8-bit 4:4:4 input format accepted by this encoder.
Definition video.h:202
platf::pix_fmt_e pix_fmt_8bit
8-bit 4:2:0 input format accepted by this encoder.
Definition video.h:200
platf::pix_fmt_e pix_fmt_yuv444_10bit
10-bit 4:4:4 input format accepted by this encoder.
Definition video.h:203
Codec capabilities for AV1, HEVC, or H.264.
Definition video.h:366
std::bitset< MAX_FLAGS > capabilities
Capability flags supported by this codec on the encoder.
Definition video.h:375
std::vector< option_t > sdr_options
Options applied to SDR 4:2:0 streams.
Definition video.h:368
std::string name
Codec name passed to the encoder backend.
Definition video.h:374
std::vector< option_t > sdr444_options
Options applied to SDR 4:4:4 streams.
Definition video.h:370
std::vector< option_t > common_options
Options applied to every encode mode for this codec.
Definition video.h:367
std::bitset< MAX_FLAGS >::reference operator[](flag_e flag)
Return a mutable reference to a codec capability flag.
Definition video.h:393
std::vector< option_t > hdr_options
Options applied to HDR 4:2:0 streams.
Definition video.h:369
bool operator[](flag_e flag) const
Test whether a codec capability is enabled.
Definition video.h:383
std::vector< option_t > fallback_options
Options used when the preferred mode cannot be selected.
Definition video.h:372
std::vector< option_t > hdr444_options
Options applied to HDR 4:4:4 streams.
Definition video.h:371
std::variant< int, int *, std::optional< int > *, std::function< int()>, std::string, std::string *, std::function< const std::string(const config_t &)> > value
Literal, pointer, or callback that supplies the option value.
Definition video.h:347
option_t(option_t &&) noexcept=default
Defaulted move constructor for the generated type.
std::string name
Encoder command-line option name.
Definition video.h:346
Encoder name and feature flags advertised by Sunshine.
Definition video.h:294
codec_t av1
AV1 codec capability and option set.
Definition video.h:398
codec_t hevc
HEVC codec capability and option set.
Definition video.h:399
static std::string_view from_flag(flag_e flag)
Convert an encoder capability flag to its diagnostic string.
Definition video.h:316
const std::unique_ptr< const encoder_platform_formats_t > platform_formats
Platform-specific memory and pixel formats accepted by the encoder.
Definition video.h:361
const codec_t & codec_from_config(const config_t &config) const
Select the codec descriptor requested by a stream configuration.
Definition video.h:408
std::string_view name
Encoder name used in logs, configuration, and capability probes.
Definition video.h:295
flag_e
Capability flags that describe which stream modes an encoder supports.
Definition video.h:300
@ DYNAMIC_RANGE
HDR support.
Definition video.h:303
@ DYNAMIC_RANGE_YUV444
YUV 4:4:4 HDR support.
Definition video.h:305
@ VUI_PARAMETERS
AMD encoder with VAAPI doesn't add VUI parameters to SPS.
Definition video.h:306
@ PASSED
Indicates the encoder is supported.
Definition video.h:301
@ REF_FRAMES_RESTRICT
Set maximum reference frames.
Definition video.h:302
@ YUV444
YUV 4:4:4 support.
Definition video.h:304
@ MAX_FLAGS
Maximum number of flags.
Definition video.h:307
uint32_t flags
Encoder flags advertised to clients through GameStream capability responses.
Definition video.h:422
codec_t h264
H.264 codec capability and option set.
Definition video.h:400
bool enabled
Whether HDR mode should be enabled.
Definition video.h:676
SS_HDR_METADATA metadata
Display HDR metadata forwarded to the encoder and client.
Definition video.h:677
hdr_info_raw_t(bool enabled, const SS_HDR_METADATA &metadata)
Initialize HDR metadata with display metadata from the backend.
Definition video.h:672
hdr_info_raw_t(bool enabled)
Initialize HDR metadata with only the enabled state.
Definition video.h:663
uint8_t * data() override
Return writable access to the FFmpeg packet payload.
Definition video.h:575
size_t data_size() override
Return the FFmpeg packet payload length.
Definition video.h:584
AVPacket * av_packet
FFmpeg packet that owns encoded data and frame metadata.
Definition video.h:588
bool is_idr() override
Report whether the FFmpeg packet is marked as a key frame.
Definition video.h:557
int64_t frame_index() override
Return the FFmpeg packet PTS used as Sunshine's frame index.
Definition video.h:566
uint8_t * data() override
Return writable access to the generic packet payload.
Definition video.h:631
bool is_idr() override
Report whether the generic packet starts an IDR frame.
Definition video.h:613
std::vector< uint8_t > frame_data
Encoded frame bytes owned by this packet.
Definition video.h:644
int64_t frame_index() override
Return the stored frame index for this generic packet.
Definition video.h:622
int64_t index
Monotonic frame index assigned to this packet.
Definition video.h:645
packet_raw_generic(std::vector< uint8_t > &&frame_data, int64_t frame_index, bool idr)
Wrap generic encoded frame bytes in Sunshine packet metadata.
Definition video.h:602
bool idr
Whether the packet belongs to an IDR frame.
Definition video.h:646
size_t data_size() override
Return the generic packet payload length.
Definition video.h:640
replace_t(replace_t &&) noexcept=default
Defaulted move constructor for the generated type.
std::string_view _new
Byte sequence that replaces old before transmission.
Definition video.h:518
std::string_view old
Byte sequence to find in the encoded packet.
Definition video.h:517
Encoded packet wrapper used by the streaming pipeline.
Definition video.h:482
virtual size_t data_size()=0
Return the encoded payload length.
virtual bool is_idr()=0
Report whether this packet starts an IDR frame.
std::vector< replace_t > * replacements
Optional encoded-byte substitutions applied before packetization.
Definition video.h:534
stream::session_t * channel_data
Stream session that receives this packet.
Definition video.h:535
virtual int64_t frame_index()=0
Return the frame index associated with this encoded packet.
bool after_ref_frame_invalidation
Whether the frame follows reference-frame invalidation.
Definition video.h:536
virtual uint8_t * data()=0
Return writable access to the encoded packet bytes.
std::optional< std::chrono::steady_clock::time_point > frame_timestamp
Capture timestamp associated with the frame.
Definition video.h:537
Declarations for thread-safe data structures.
std::shared_ptr< mail_raw_t > mail_t
Shared mailbox handle used by event and queue wrappers.
Definition thread_safe.h:753
uniq_ptr< T, Destroy< T *, void, function > > safe_ptr
Unique pointer using a compile-time C-style destroy function.
Definition utility.h:1590
#define KITTY_DEFAULT_CONSTR_MOVE(x)
Declare defaulted noexcept move construction and assignment for a type.
Definition utility.h:123
encoder_t vaapi
VA-API.
Definition video.cpp:1234
config_t resolve_dynamic_range(const encoder_t &encoder, config_t config)
Resolve a client-requested dynamic range against probed encoder capabilities.
Definition video.cpp:170
platf::mem_type_e map_base_dev_type(AVHWDeviceType type)
Map an FFmpeg hardware device type to Sunshine's capture memory type.
Definition video.cpp:3688
bool validate_encoder(encoder_t &encoder, bool expect_failure)
Validate encoder before it is used.
Definition video.cpp:3066
encoder_t mediafoundation
Mediafoundation.
Definition video.cpp:1093
int active_hevc_mode
HEVC mode selected by the most recent encoder probe.
Definition video.cpp:1472
void capture(safe::mail_t mail, config_t config, stream::session_t *channel_data)
Capture and encode video for a streaming session.
Definition video.cpp:2964
int active_av1_mode
AV1 mode selected by the most recent encoder probe.
Definition video.cpp:1473
std::array< bool, 3 > last_encoder_probe_supported_yuv444_for_codec
YUV444 support discovered for each probed codec.
Definition video.cpp:1475
encoder_t amdvce
Amdvce.
Definition video.cpp:979
int probe_encoders()
Probe encoders and select the preferred encoder. This is called once at startup and each time a strea...
Definition video.cpp:3264
encoder_t quicksync
Quicksync.
Definition video.cpp:865
bool last_encoder_probe_supported_ref_frames_invalidation
Whether the last probe found reference-frame invalidation support.
Definition video.cpp:1474
platf::pix_fmt_e map_pix_fmt(AVPixelFormat fmt)
Map an FFmpeg pixel format to Sunshine's pixel format.
Definition video.cpp:3715
encoder_t videotoolbox
Videotoolbox.
Definition video.cpp:1376
encoder_t software
Software.
Definition video.cpp:1157
AVRational framerateX100_to_rational(const int framerateX100)
Convert a framerate stored as hundredths of Hz to an FFmpeg rational.
Definition video.h:743
coder_e
Enumerates supported coder options for the AMF encoder.
Definition video.h:53
@ auto_
Select the coder based on the H.264 profile.
Definition video.h:54
util::safe_ptr< AVCodecContext, &free_ctx > avcodec_ctx_t
Owning pointer for an FFmpeg codec context released with free_ctx().
Definition video.h:108
std::chrono::nanoseconds capture_frame_interval(const config_t &config)
Capture frame interval for the requested framerate. Uses the exact fractional rate when the client pr...
Definition video.h:781
std::unique_ptr< packet_raw_t > packet_t
Owning pointer to an encoded packet abstraction.
Definition video.h:652
std::shared_ptr< safe::event_t< std::shared_ptr< platf::img_t > > > img_event_t
Shared event that transports captured images between capture and encode threads.
Definition video.h:124
AVRational framerate_to_rational(const config_t &config)
Requested framerate as an exact rational. Uses the exact fractional rate when the client provided an ...
Definition video.h:767
util::safe_ptr< AVFrame, &free_frame > avcodec_frame_t
Owning pointer for an FFmpeg frame released with free_frame().
Definition video.h:112
util::safe_ptr< SwsContext, &sws_freeContext > sws_t
Owning pointer for an FFmpeg software-scaling context released with sws_freeContext().
Definition video.h:120
std::unique_ptr< hdr_info_raw_t > hdr_info_t
Owning pointer to optional HDR metadata for a captured display.
Definition video.h:683
util::safe_ptr< AVBufferRef, &free_buffer > avcodec_buffer_t
Owning pointer for an FFmpeg buffer reference released with free_buffer().
Definition video.h:116
Declarations for colorspace functions.