Sunshine master
Self-hosted game stream host for Moonlight.
common.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <bitset>
9#include <filesystem>
10#include <functional>
11#include <mutex>
12#include <string>
13
14// lib includes
15#include <boost/core/noncopyable.hpp>
16#ifndef _WIN32
17 #include <boost/asio.hpp>
18 #include <boost/process/v1.hpp>
19#endif
20
21// local includes
22#include "src/config.h"
23#include "src/logging.h"
24#include "src/thread_safe.h"
25#include "src/utility.h"
27
28extern "C" {
29#include <moonlight-common-c/src/Limelight.h>
30}
31
32using namespace std::literals;
33
34struct sockaddr;
35struct AVFrame;
36struct AVBufferRef;
37struct AVHWFramesContext;
38struct AVCodecContext;
39struct AVDictionary;
40
41#ifdef _WIN32
42// Forward declarations of boost classes to avoid having to include boost headers
43// here, which results in issues with Windows.h and WinSock2.h include order.
44namespace boost {
45 namespace asio {
46 namespace ip {
47 class address;
48 } // namespace ip
49 } // namespace asio
50
51 namespace filesystem {
52 class path;
53 }
54
55 namespace process::v1 {
56 class child;
57 class group;
58 template<typename Char>
61 } // namespace process::v1
62} // namespace boost
63#endif
64namespace video {
65 struct config_t;
66} // namespace video
67
68namespace nvenc {
69 class nvenc_base;
70}
71
72namespace platf {
73 // Limited by bits in activeGamepadMask
74 constexpr auto MAX_GAMEPADS = 16;
75
76 constexpr std::uint32_t DPAD_UP = 0x0001;
77 constexpr std::uint32_t DPAD_DOWN = 0x0002;
78 constexpr std::uint32_t DPAD_LEFT = 0x0004;
79 constexpr std::uint32_t DPAD_RIGHT = 0x0008;
80 constexpr std::uint32_t START = 0x0010;
81 constexpr std::uint32_t BACK = 0x0020;
82 constexpr std::uint32_t LEFT_STICK = 0x0040;
83 constexpr std::uint32_t RIGHT_STICK = 0x0080;
84 constexpr std::uint32_t LEFT_BUTTON = 0x0100;
85 constexpr std::uint32_t RIGHT_BUTTON = 0x0200;
86 constexpr std::uint32_t HOME = 0x0400;
87 constexpr std::uint32_t A = 0x1000;
88 constexpr std::uint32_t B = 0x2000;
89 constexpr std::uint32_t X = 0x4000;
90 constexpr std::uint32_t Y = 0x8000;
91 constexpr std::uint32_t PADDLE1 = 0x010000;
92 constexpr std::uint32_t PADDLE2 = 0x020000;
93 constexpr std::uint32_t PADDLE3 = 0x040000;
94 constexpr std::uint32_t PADDLE4 = 0x080000;
95 constexpr std::uint32_t TOUCHPAD_BUTTON = 0x100000;
96 constexpr std::uint32_t MISC_BUTTON = 0x200000;
97
99 std::string name;
100 bool is_enabled;
101 std::string reason_disabled;
102 };
103
111
113 static gamepad_feedback_msg_t make_rumble(std::uint16_t id, std::uint16_t lowfreq, std::uint16_t highfreq) {
115 msg.type = gamepad_feedback_e::rumble;
116 msg.id = id;
117 msg.data.rumble = {lowfreq, highfreq};
118 return msg;
119 }
120
121 static gamepad_feedback_msg_t make_rumble_triggers(std::uint16_t id, std::uint16_t left, std::uint16_t right) {
123 msg.type = gamepad_feedback_e::rumble_triggers;
124 msg.id = id;
125 msg.data.rumble_triggers = {left, right};
126 return msg;
127 }
128
129 static gamepad_feedback_msg_t make_motion_event_state(std::uint16_t id, std::uint8_t motion_type, std::uint16_t report_rate) {
131 msg.type = gamepad_feedback_e::set_motion_event_state;
132 msg.id = id;
133 msg.data.motion_event_state.motion_type = motion_type;
134 msg.data.motion_event_state.report_rate = report_rate;
135 return msg;
136 }
137
138 static gamepad_feedback_msg_t make_rgb_led(std::uint16_t id, std::uint8_t r, std::uint8_t g, std::uint8_t b) {
140 msg.type = gamepad_feedback_e::set_rgb_led;
141 msg.id = id;
142 msg.data.rgb_led = {r, g, b};
143 return msg;
144 }
145
146 static gamepad_feedback_msg_t make_adaptive_triggers(std::uint16_t id, uint8_t event_flags, uint8_t type_left, uint8_t type_right, const std::array<uint8_t, 10> &left, const std::array<uint8_t, 10> &right) {
148 msg.type = gamepad_feedback_e::set_adaptive_triggers;
149 msg.id = id;
150 msg.data.adaptive_triggers = {.event_flags = event_flags, .type_left = type_left, .type_right = type_right, .left = left, .right = right};
151 return msg;
152 }
153
155 std::uint16_t id;
156
157 union {
158 struct {
159 std::uint16_t lowfreq;
160 std::uint16_t highfreq;
161 } rumble;
162
163 struct {
164 std::uint16_t left_trigger;
165 std::uint16_t right_trigger;
166 } rumble_triggers;
167
168 struct {
169 std::uint16_t report_rate;
170 std::uint8_t motion_type;
171 } motion_event_state;
172
173 struct {
174 std::uint8_t r;
175 std::uint8_t g;
176 std::uint8_t b;
177 } rgb_led;
178
179 struct {
180 uint16_t controllerNumber;
181 uint8_t event_flags;
182 uint8_t type_left;
183 uint8_t type_right;
184 std::array<uint8_t, 10> left;
185 std::array<uint8_t, 10> right;
186 } adaptive_triggers;
187 } data;
188 };
189
190 using feedback_queue_t = safe::mail_raw_t::queue_t<gamepad_feedback_msg_t>;
191
192 namespace speaker {
204
205 constexpr std::uint8_t map_stereo[] {
206 FRONT_LEFT,
207 FRONT_RIGHT
208 };
209 constexpr std::uint8_t map_surround51[] {
210 FRONT_LEFT,
211 FRONT_RIGHT,
212 FRONT_CENTER,
213 LOW_FREQUENCY,
214 BACK_LEFT,
215 BACK_RIGHT,
216 };
217 constexpr std::uint8_t map_surround71[] {
222 BACK_LEFT,
224 SIDE_LEFT,
226 };
227 } // namespace speaker
228
229 enum class mem_type_e {
230 system,
231 vaapi,
232 dxgi,
233 cuda,
234 videotoolbox,
235 vulkan,
236 unknown
237 };
238
239 enum class pix_fmt_e {
240 yuv420p,
241 yuv420p10,
242 nv12,
243 p010,
244 ayuv,
245 yuv444p16,
246 y410,
247 unknown
248 };
249
250 inline std::string_view from_pix_fmt(pix_fmt_e pix_fmt) {
251 using namespace std::literals;
252#define _CONVERT(x) \
253 case pix_fmt_e::x: \
254 return #x##sv
255 switch (pix_fmt) {
256 _CONVERT(yuv420p);
257 _CONVERT(yuv420p10);
258 _CONVERT(nv12);
259 _CONVERT(p010);
260 _CONVERT(ayuv);
261 _CONVERT(yuv444p16);
262 _CONVERT(y410);
263 _CONVERT(unknown);
264 }
265#undef _CONVERT
266
267 return "unknown"sv;
268 }
269
270 // Dimensions for touchscreen input
272 int offset_x;
273 int offset_y;
274 int width;
275 int height;
276 int logical_width;
277 int logical_height;
278 };
279
280 // These values must match Limelight-internal.h's SS_FF_* constants!
281 namespace platform_caps {
282 typedef uint32_t caps_t;
283
284 constexpr caps_t pen_touch = 0x01; // Pen and touch events
285 constexpr caps_t controller_touch = 0x02; // Controller touch events
286 }; // namespace platform_caps
287
289 std::uint32_t buttonFlags;
290 std::uint8_t lt;
291 std::uint8_t rt;
292 std::int16_t lsX;
293 std::int16_t lsY;
294 std::int16_t rsX;
295 std::int16_t rsY;
296 };
297
299 // The global index is used when looking up gamepads in the platform's
300 // gamepad array. It identifies gamepads uniquely among all clients.
301 int globalIndex;
302
303 // The client-relative index is the controller number as reported by the
304 // client. It must be used when communicating back to the client via
305 // the input feedback queue.
306 std::uint8_t clientRelativeIndex;
307 };
308
310 std::uint8_t type;
311 std::uint16_t capabilities;
312 std::uint32_t supportedButtons;
313 };
314
316 gamepad_id_t id;
317 std::uint8_t eventType;
318 std::uint32_t pointerId;
319 float x;
320 float y;
321 float pressure;
322 };
323
325 gamepad_id_t id;
326 std::uint8_t motionType;
327
328 // Accel: m/s^2
329 // Gyro: deg/s
330 float x;
331 float y;
332 float z;
333 };
334
336 gamepad_id_t id;
337 std::uint8_t state;
338 std::uint8_t percentage;
339 };
340
342 std::uint8_t eventType;
343 std::uint16_t rotation; // Degrees (0..360) or LI_ROT_UNKNOWN
344 std::uint32_t pointerId;
345 float x;
346 float y;
347 float pressureOrDistance; // Distance for hover and pressure for contact
348 float contactAreaMajor;
349 float contactAreaMinor;
350 };
351
352 struct pen_input_t {
353 std::uint8_t eventType;
354 std::uint8_t toolType;
355 std::uint8_t penButtons;
356 std::uint8_t tilt; // Degrees (0..90) or LI_TILT_UNKNOWN
357 std::uint16_t rotation; // Degrees (0..360) or LI_ROT_UNKNOWN
358 float x;
359 float y;
360 float pressureOrDistance; // Distance for hover and pressure for contact
361 float contactAreaMajor;
362 float contactAreaMinor;
363 };
364
365 class deinit_t {
366 public:
367 virtual ~deinit_t() = default;
368 };
369
370 struct img_t: std::enable_shared_from_this<img_t> {
371 public:
372 img_t() = default;
373
374 img_t(img_t &&) = delete;
375 img_t(const img_t &) = delete;
376 img_t &operator=(img_t &&) = delete;
377 img_t &operator=(const img_t &) = delete;
378
379 std::uint8_t *data {};
380 std::int32_t width {};
381 std::int32_t height {};
382 std::int32_t pixel_pitch {};
383 std::int32_t row_pitch {};
384
385 std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
386
387 virtual ~img_t() = default;
388 };
389
390 struct sink_t {
391 // Play on host PC
392 std::string host;
393
394 // On macOS and Windows, it is not possible to create a virtual sink
395 // Therefore, it is optional
396 struct null_t {
397 std::string stereo;
398 std::string surround51;
399 std::string surround71;
400 };
401
402 std::optional<null_t> null;
403 };
404
406 virtual ~encode_device_t() = default;
407
408 virtual int convert(platf::img_t &img) = 0;
409
411 };
412
414 void *data {};
415 AVFrame *frame {};
416
417 int convert(platf::img_t &img) override {
418 return -1;
419 }
420
421 virtual void apply_colorspace() {
422 }
423
428 virtual int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) {
429 BOOST_LOG(error) << "Illegal call to hwdevice_t::set_frame(). Did you forget to override it?";
430 return -1;
431 };
432
437 virtual void init_hwframes(AVHWFramesContext *frames) {};
438
443 virtual void init_codec_options(AVCodecContext *ctx, AVDictionary **options) {};
444
449 virtual int prepare_to_derive_context(int hw_device_type) {
450 return 0;
451 };
452 };
453
455 virtual bool init_encoder(const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace) = 0;
456
457 nvenc::nvenc_base *nvenc = nullptr;
458 };
459
460 enum class capture_e : int {
461 ok,
462 reinit,
463 timeout,
465 error
466 };
467
468 class display_t {
469 public:
477 using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>;
478
486 using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>;
487
488 display_t() noexcept = default;
489
502 virtual capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) = 0;
503
504 virtual std::shared_ptr<img_t> alloc_img() = 0;
505
506 virtual int dummy_img(img_t *img) = 0;
507
508 virtual std::unique_ptr<avcodec_encode_device_t> make_avcodec_encode_device(pix_fmt_e pix_fmt) {
509 return nullptr;
510 }
511
512 virtual std::unique_ptr<nvenc_encode_device_t> make_nvenc_encode_device(pix_fmt_e pix_fmt) {
513 return nullptr;
514 }
515
516 virtual bool is_hdr() {
517 return false;
518 }
519
520 virtual bool get_hdr_metadata(SS_HDR_METADATA &metadata) {
521 std::memset(&metadata, 0, sizeof(metadata));
522 return false;
523 }
524
531 virtual bool is_codec_supported(std::string_view name, const ::video::config_t &config) {
532 return true;
533 }
534
535 virtual ~display_t() = default;
536
537 // Offsets for when streaming a specific monitor. By default, they are 0.
538 int offset_x {0};
539 int offset_y {0};
540 int env_width {0};
541 int env_height {0};
542 int env_logical_width {0};
543 int env_logical_height {0};
544 int width {0};
545 int height {0};
546 int logical_width {0};
547 int logical_height {0};
548
549 protected:
550 // collect capture timing data (at loglevel debug)
551 logging::time_delta_periodic_logger sleep_overshoot_logger = {debug, "Frame capture sleep overshoot"};
552 };
553
554 class mic_t {
555 public:
556 virtual capture_e sample(std::vector<float> &frame_buffer) = 0;
557
558 virtual ~mic_t() = default;
559 };
560
562 public:
563 virtual int set_sink(const std::string &sink) = 0;
564
565 virtual std::unique_ptr<mic_t> microphone(const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size, bool continuous, [[maybe_unused]] bool host_audio_enabled) = 0;
566
572 virtual bool is_sink_available(const std::string &sink) = 0;
573
574 virtual std::optional<sink_t> sink_info() = 0;
575
576 virtual ~audio_control_t() = default;
577 };
578
579 void freeInput(void *);
580
582
583 std::filesystem::path appdata();
584
585 std::string get_mac_address(const std::string_view &address);
586
587 std::string from_sockaddr(const sockaddr *const);
588 std::pair<std::uint16_t, std::string> from_sockaddr_ex(const sockaddr *const);
589
590 std::unique_ptr<audio_control_t> audio_control();
591
600 std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
601
602 // A list of names of displays accepted as display_name with the mem_type_e
603 std::vector<std::string> display_names(mem_type_e hwdevice_type);
604
610
611 boost::process::v1::child run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group);
612
613 enum class thread_priority_e : int {
614 low,
615 normal,
616 high,
617 critical
618 };
619 void adjust_thread_priority(thread_priority_e priority);
620
625 void set_thread_name(const std::string &name);
626
627 void enable_mouse_keys();
628
629 // Allow OS-specific actions to be taken to prepare for streaming
630 void streaming_will_start();
631 void streaming_will_stop();
632
633 void restart();
634
641 int set_env(const std::string &name, const std::string &value);
642
648 int unset_env(const std::string &name);
649
651 const char *buffer;
652 size_t size;
653
654 // Constructors required for emplace_back() prior to C++20
655 buffer_descriptor_t(const char *buffer, size_t size):
656 buffer(buffer),
657 size(size) {
658 }
659
661 buffer(nullptr),
662 size(0) {
663 }
664 };
665
667 // Optional headers to be prepended to each packet
668 const char *headers;
669 size_t header_size;
670
671 // One or more data buffers to use for the payloads
672 //
673 // NB: Data buffers must be aligned to payload size!
674 std::vector<buffer_descriptor_t> &payload_buffers;
675 size_t payload_size;
676
677 // The offset (in header+payload message blocks) in the header and payload
678 // buffers to begin sending messages from
679 size_t block_offset;
680
681 // The number of header+payload message blocks to send
682 size_t block_count;
683
684 std::uintptr_t native_socket;
685 boost::asio::ip::address &target_address;
686 uint16_t target_port;
687 boost::asio::ip::address &source_address;
688
695 for (const auto &desc : payload_buffers) {
696 if (offset < desc.size) {
697 return {
698 desc.buffer + offset,
699 desc.size - offset,
700 };
701 } else {
702 offset -= desc.size;
703 }
704 }
705 return {};
706 }
707 };
708
709 bool send_batch(batched_send_info_t &send_info);
710
711 struct send_info_t {
712 const char *header;
713 size_t header_size;
714 const char *payload;
715 size_t payload_size;
716
717 std::uintptr_t native_socket;
718 boost::asio::ip::address &target_address;
719 uint16_t target_port;
720 boost::asio::ip::address &source_address;
721 };
722
723 bool send(send_info_t &send_info);
724
725 enum class qos_data_type_e : int {
726 audio,
727 video
728 };
729
738 std::unique_ptr<deinit_t> enable_socket_qos(uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type, bool dscp_tagging);
739
744 void open_url(const std::string &url);
745
751 bool request_process_group_exit(std::uintptr_t native_handle);
752
758 bool process_group_running(std::uintptr_t native_handle);
759
760 input_t input();
769 util::point_t get_mouse_loc(input_t &input);
770 void move_mouse(input_t &input, int deltaX, int deltaY);
771 void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y);
772 void button_mouse(input_t &input, int button, bool release);
773 void scroll(input_t &input, int distance);
774 void hscroll(input_t &input, int distance);
775 void keyboard_update(input_t &input, uint16_t modcode, bool release, uint8_t flags);
776 void gamepad_update(input_t &input, int nr, const gamepad_state_t &gamepad_state);
777 void unicode(input_t &input, char *utf8, int size);
778
779 typedef deinit_t client_input_t;
780
786 std::unique_ptr<client_input_t> allocate_client_input_context(input_t &input);
787
794 void touch_update(client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch);
795
802 void pen_update(client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen);
803
809 void gamepad_touch(input_t &input, const gamepad_touch_t &touch);
810
816 void gamepad_motion(input_t &input, const gamepad_motion_t &motion);
817
823 void gamepad_battery(input_t &input, const gamepad_battery_t &battery);
824
833 int alloc_gamepad(input_t &input, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue);
834 void free_gamepad(input_t &input, int nr);
835
840 platform_caps::caps_t get_capabilities();
841
842 constexpr auto SERVICE_NAME = "Sunshine";
843 constexpr auto SERVICE_TYPE = "_nvstream._tcp";
844
845 namespace publish {
846 [[nodiscard]] std::unique_ptr<deinit_t> start();
847 }
848
849 [[nodiscard]] std::unique_ptr<deinit_t> init();
850
855 std::string get_host_name();
856
864 std::string resolve_render_device();
865
872 std::vector<supported_gamepad_t> &supported_gamepads(input_t *input);
873
874 struct high_precision_timer: private boost::noncopyable {
875 virtual ~high_precision_timer() = default;
876
881 virtual void sleep_for(const std::chrono::nanoseconds &duration) = 0;
882
887 virtual operator bool() = 0;
888 };
889
894 std::unique_ptr<high_precision_timer> create_high_precision_timer();
895
901 bool has_elevated_privileges(bool all_caps);
902
907 void drop_elevated_privileges(bool all_caps);
908
909} // namespace platf
A helper class for tracking and logging short time intervals across a period of time.
Definition logging.h:166
Abstract platform-agnostic base of standalone NVENC encoder. Derived classes perform platform-specifi...
Definition nvenc_base.h:26
Definition common.h:561
virtual bool is_sink_available(const std::string &sink)=0
Check if the audio sink is available in the system.
Definition common.h:365
Definition common.h:468
virtual bool is_codec_supported(std::string_view name, const ::video::config_t &config)
Check that a given codec is supported by the display device.
Definition common.h:531
std::function< bool(std::shared_ptr< img_t > &&img, bool frame_captured)> push_captured_image_cb_t
Callback for when a new image is ready. When display has a new image ready or a timeout occurs,...
Definition common.h:477
std::function< bool(std::shared_ptr< img_t > &img_out)> pull_free_image_cb_t
Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or...
Definition common.h:486
virtual capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor)=0
Capture a frame.
Definition common.h:554
Definition utility.h:530
mem_type_e
Definition common.h:229
@ system
System memory.
speaker_e
Definition common.h:193
@ BACK_LEFT
Back left.
Definition common.h:198
@ LOW_FREQUENCY
Low frequency.
Definition common.h:197
@ SIDE_RIGHT
Side right.
Definition common.h:201
@ MAX_SPEAKERS
Maximum number of speakers.
Definition common.h:202
@ FRONT_LEFT
Front left.
Definition common.h:194
@ SIDE_LEFT
Side left.
Definition common.h:200
@ FRONT_CENTER
Front center.
Definition common.h:196
@ BACK_RIGHT
Back right.
Definition common.h:199
@ FRONT_RIGHT
Front right.
Definition common.h:195
std::vector< supported_gamepad_t > & supported_gamepads(input_t *input)
Gets the supported gamepads for this platform backend.
Definition inputtino.cpp:130
std::shared_ptr< display_t > display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config)
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monit...
Definition misc.cpp:1092
pix_fmt_e
Definition common.h:239
@ yuv420p10
YUV 4:2:0 10-bit.
@ yuv444p16
Planar 10-bit (shifted to 16-bit) YUV 4:4:4.
@ yuv420p
YUV 4:2:0.
bool has_elevated_privileges(bool all_caps)
Check is the current process is running with elevated privileges (e.g. system admin/etc....
Definition misc.cpp:1294
std::filesystem::path appdata()
Performs migration if necessary, then returns the appdata directory.
Definition misc.cpp:140
qos_data_type_e
Definition common.h:725
std::unique_ptr< high_precision_timer > create_high_precision_timer()
Create platform-specific timer capable of high-precision sleep.
Definition misc.cpp:1226
bool needs_encoder_reenumeration()
Check if GPUs/drivers have changed since the last call to this function.
Definition misc.cpp:1087
gamepad_feedback_e
Definition common.h:104
@ rumble_triggers
Rumble triggers.
@ set_adaptive_triggers
Set adaptive triggers.
@ set_motion_event_state
Set motion event state.
thread_priority_e
Definition common.h:613
@ critical
Critical priority.
@ high
High priority.
@ normal
Normal priority.
void drop_elevated_privileges(bool all_caps)
Drop elevated privileges (e.g. system admin/nice etc.)
Definition misc.cpp:1323
std::string get_host_name()
Returns the current computer name in UTF-8.
Definition misc.cpp:957
std::string resolve_render_device()
Resolves the render device path to use for hardware encoding.
Definition misc.cpp:1278
capture_e
Definition common.h:460
@ timeout
Timeout.
@ reinit
Need to reinitialize.
@ interrupted
Capture was interrupted.
Declarations for the configuration of Sunshine.
std::unique_ptr< platf::deinit_t > init(const std::filesystem::path &persistence_filepath, const config::video_t &video_config)
Initialize the implementation and perform the initial state recovery (if needed).
Definition display_device.cpp:704
Declarations for logging related functions.
Standalone NVENC encoder.
Definition nvenc_base.cpp:90
Definition common.h:413
virtual int prepare_to_derive_context(int hw_device_type)
Prepare to derive a context.
Definition common.h:449
virtual void init_codec_options(AVCodecContext *ctx, AVDictionary **options)
Provides a hook for allow platform-specific code to adjust codec options.
Definition common.h:443
virtual int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx)
Set the frame to be encoded.
Definition common.h:428
virtual void init_hwframes(AVHWFramesContext *frames)
Initialize the hwframes context.
Definition common.h:437
Definition common.h:666
buffer_descriptor_t buffer_for_payload_offset(ptrdiff_t offset)
Returns a payload buffer descriptor for the given payload offset.
Definition common.h:694
Definition common.h:650
Definition common.h:405
Definition common.h:309
Definition common.h:335
Definition common.h:112
Definition common.h:298
Definition common.h:324
Definition common.h:288
Definition common.h:315
Definition common.h:874
virtual void sleep_for(const std::chrono::nanoseconds &duration)=0
Sleep for the duration.
Definition common.h:370
Definition common.h:454
Definition common.h:352
Definition common.h:711
Definition common.h:396
Definition common.h:390
Definition common.h:98
Definition common.h:341
Definition common.h:271
Definition utility.h:966
Definition video.h:23
Definition video_colorspace.h:20
Declarations for thread-safe data structures.
Declarations for utility functions.
Declarations for colorspace functions.