Declarations for video.
More...
#include <chrono>
#include "input.h"
#include "platform/common.h"
#include "thread_safe.h"
#include "video_colorspace.h"
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
Go to the source code of this file.
|
|
using | video::avcodec_buffer_t = util::safe_ptr<AVBufferRef, free_buffer> |
| | Owning pointer for an FFmpeg buffer reference.
|
| |
|
using | video::avcodec_ctx_t = util::safe_ptr<AVCodecContext, free_ctx> |
| | Owning pointer for an FFmpeg codec context.
|
| |
|
using | video::avcodec_frame_t = util::safe_ptr<AVFrame, free_frame> |
| | Owning pointer for an FFmpeg frame.
|
| |
|
using | video::hdr_info_t = std::unique_ptr<hdr_info_raw_t> |
| | Owning pointer to optional HDR metadata for a captured display.
|
| |
|
using | video::img_event_t = std::shared_ptr<safe::event_t<std::shared_ptr<platf::img_t>>> |
| | Shared event that transports captured images between capture and encode threads.
|
| |
|
using | video::packet_t = std::unique_ptr<packet_raw_t> |
| | Owning pointer to an encoded packet abstraction.
|
| |
|
using | video::sws_t = util::safe_ptr<SwsContext, sws_freeContext> |
| | Owning pointer for an FFmpeg software-scaling context.
|
| |
◆ capture()
Capture and encode video for a streaming session.
- Parameters
-
| mail | Session mail bus. |
| config | Video configuration. |
| channel_data | Opaque channel data passed to packets. |
◆ capture_frame_interval()
| std::chrono::nanoseconds video::capture_frame_interval |
( |
const config_t & | config | ) |
|
|
inline |
Capture frame interval for the requested framerate. Uses the exact fractional rate when the client provided an X100 value.
- Parameters
-
| config | Stream configuration carrying the requested framerate. |
- Returns
- Duration of a single frame interval in nanoseconds.
◆ framerate_to_rational()
| AVRational video::framerate_to_rational |
( |
const config_t & | config | ) |
|
|
inline |
Requested framerate as an exact rational. Uses the exact fractional rate when the client provided an X100 value, otherwise the integer framerate over 1.
- Parameters
-
| config | Stream configuration carrying the requested framerate. |
- Returns
- Requested frame rate as a rational.
◆ framerateX100_to_rational()
| AVRational video::framerateX100_to_rational |
( |
const int | framerateX100 | ) |
|
|
inline |
Convert a framerate stored as hundredths of Hz to an FFmpeg rational.
- Parameters
-
| framerateX100 | Framerate multiplied by 100, such as 5994 for 59.94 Hz. |
- Returns
- Rational frame rate preserving NTSC fractional rates when applicable.
◆ free_buffer()
| void video::free_buffer |
( |
AVBufferRef * | ref | ) |
|
Release a backend buffer allocated for capture or conversion.
- Parameters
-
| ref | FFmpeg buffer reference to unref and free. |
◆ free_ctx()
| void video::free_ctx |
( |
AVCodecContext * | ctx | ) |
|
Release context resources.
Release an FFmpeg codec context.
- Parameters
-
| ctx | Codec context allocated by FFmpeg. |
◆ free_frame()
| void video::free_frame |
( |
AVFrame * | frame | ) |
|
Release an FFmpeg frame allocated by the capture or conversion backend.
- Parameters
-
| frame | Video or graphics frame being processed. |
◆ map_base_dev_type()
Map base dev type values.
Map an FFmpeg hardware device type to Sunshine's memory type.
- Parameters
-
| type | FFmpeg hardware device type reported by the encoder backend. |
- Returns
- Sunshine memory type used by the capture and encode pipeline.
◆ map_pix_fmt()
Map pix fmt values.
Map an FFmpeg pixel format to Sunshine's pixel format enum.
- Parameters
-
| fmt | FFmpeg 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.
◆ validate_encoder()
| bool video::validate_encoder |
( |
encoder_t & | encoder, |
|
|
bool | expect_failure ) |
Validate encoder before it is used.
- Parameters
-
| encoder | Encoder configuration or encoder instance. |
| expect_failure | Expect failure. |
- Returns
- True when encoder validation matches
expect_failure.