Declarations for video.
More...
#include <chrono>
#include <string_view>
#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 released with free_buffer().
|
|
using | video::avcodec_ctx_t = util::safe_ptr<AVCodecContext, &free_ctx> |
| | Owning pointer for an FFmpeg codec context released with free_ctx().
|
|
using | video::avcodec_frame_t = util::safe_ptr<AVFrame, &free_frame> |
| | Owning pointer for an FFmpeg frame released with free_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 released with sws_freeContext().
|
◆ coder_e
Enumerates supported coder options for the AMF encoder.
| Enumerator |
|---|
| auto_ | Select the coder based on the H.264 profile.
|
| cabac | CABAC entropy coding.
|
| cavlc | CAVLC entropy coding.
|
◆ capture()
Capture and encode video for a streaming session.
- Parameters
-
| mail | Session mail bus. |
| config | Client-requested video configuration, normalized before capture begins. |
| channel_data | Stream session carried with each encoded packet. |
◆ 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 an FFmpeg hardware device type to Sunshine's capture memory type.
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 an FFmpeg pixel format to Sunshine's pixel format.
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.
◆ resolve_dynamic_range()
Resolve a client-requested dynamic range against probed encoder capabilities.
- Parameters
-
| encoder | Selected encoder and its probed codec capabilities. |
| config | Client-requested stream configuration. |
- Returns
- Effective stream configuration, downgraded to SDR when HDR is unsupported.
◆ select_h264_profile()
| int video::select_h264_profile |
( |
std::string_view | encoder_name, |
|
|
const config_t & | config, |
|
|
int | amd_coder ) |
Select the effective FFmpeg H.264 profile for an encoder configuration.
- Parameters
-
| encoder_name | FFmpeg encoder name selected for the stream. |
| config | Encoding configuration requested by the remote client. |
| amd_coder | Configured AMF entropy-coder value. |
- Returns
- FFmpeg H.264 profile applied to the codec context.
◆ 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.