60 extern const std::array<opus_stream_config_t, MAX_STREAM_CONFIG>
stream_configs;
97 std::unique_ptr<platf::audio_control_t>
control;
110 using packet_t = std::pair<stream::session_t *, buffer_t>;
185 dolby_codec_e configure_dolby_audio(
187 std::string_view offered,
188 std::string_view accepted,
189 bool ac3_encoder_available,
190 bool eac3_encoder_available,
199 std::string_view dolby_codec_name(dolby_codec_e codec);
211 int encode_dolby_frame_for_testing(
215 const std::vector<float> &interleaved,
228 int dolby_bitrate_kbps(
bool eac3,
bool high_quality,
int channels);
bool ac3_available()
Check whether the linked FFmpeg build provides the AC-3 encoder.
Definition audio.cpp:482
bool eac3_available()
Check whether the linked FFmpeg build provides the E-AC-3 encoder.
Definition audio.cpp:490
bool is_audio_ctx_sink_available(const audio_ctx_t &ctx)
Check if the audio sink held by audio context is available.
Definition audio.cpp:552
const std::array< opus_stream_config_t, MAX_STREAM_CONFIG > stream_configs
Opus stream layouts and bitrates advertised to clients.
Definition audio.cpp:61
void capture(safe::mail_t mail, config_t config, stream::session_t *channel_data)
Run the capture loop for this backend.
Definition audio.cpp:354
audio_ctx_ref_t get_audio_ctx_ref()
Get the reference to the audio context.
Definition audio.cpp:473
dolby_codec_e
Audio codec selected by RTSP Dolby offer/accept negotiation.
Definition audio.h:169
@ ac3
Dolby Digital AC-3 bitstream.
Definition audio.h:171
@ eac3
Dolby Digital Plus E-AC-3 bitstream.
Definition audio.h:172
@ opus
Existing Opus audio path.
Definition audio.h:170
util::buffer_t< std::uint8_t > buffer_t
Byte buffer used for encoded audio packet payloads.
Definition audio.h:106
std::pair< stream::session_t *, buffer_t > packet_t
Encoded audio packet paired with its owning stream session.
Definition audio.h:110
safe::shared_t< audio_ctx_t >::ptr_t audio_ctx_ref_t
Shared mailbox reference to the global audio context.
Definition audio.h:114
stream_config_e
Supported Opus channel layouts advertised to Moonlight clients.
Definition audio.h:25
@ HIGH_STEREO
High stereo.
Definition audio.h:27
@ SURROUND51
Surround 5.1.
Definition audio.h:28
@ STEREO
Stereo.
Definition audio.h:26
@ HIGH_SURROUND71
High surround 7.1.
Definition audio.h:31
@ HIGH_SURROUND51
High surround 5.1.
Definition audio.h:29
@ SURROUND71
Surround 7.1.
Definition audio.h:30
@ MAX_STREAM_CONFIG
Maximum audio stream configuration.
Definition audio.h:32
Owning contiguous buffer with an explicit logical element count.
Definition utility.h:1398
Declarations for common platform specific utilities.
Handles process-wide communication.
Definition globals.h:34
Shared audio device state used while streams are active.
Definition audio.h:93
std::unique_ptr< platf::audio_control_t > control
Platform audio-control implementation.
Definition audio.h:97
bool restore_sink
Whether Sunshine should restore the original sink when capture ends.
Definition audio.h:99
platf::sink_t sink
Original sink captured before Sunshine switched devices.
Definition audio.h:100
std::unique_ptr< std::atomic_bool > sink_flag
Tracks whether the capture sink was already switched.
Definition audio.h:95
Audio capture and encoder settings for a stream.
Definition audio.h:65
flags_e
Boolean audio feature flags.
Definition audio.h:69
@ HIGH_QUALITY
High quality audio.
Definition audio.h:70
@ MAX_FLAGS
Maximum number of flags.
Definition audio.h:74
@ CONTINUOUS_AUDIO
Continuous audio.
Definition audio.h:73
@ CUSTOM_SURROUND_PARAMS
Custom surround parameters.
Definition audio.h:72
@ HOST_AUDIO
Host audio.
Definition audio.h:71
int packetDuration
Packet duration in milliseconds requested by the client.
Definition audio.h:77
stream_params_t customStreamParams
Custom Opus layout used when CUSTOM_SURROUND_PARAMS is enabled.
Definition audio.h:81
bool high_quality_dolby
Higher bitrate for Dolby only; ignored for Opus.
Definition audio.h:87
int channels
Number of audio channels requested by the client.
Definition audio.h:78
int mask
Speaker mask describing the requested channel layout.
Definition audio.h:79
bool use_eac3
Encode audio as E-AC-3 instead of Opus for this streaming session.
Definition audio.h:86
std::bitset< MAX_FLAGS > flags
Enabled audio feature flags.
Definition audio.h:83
bool use_ac3
Encode audio as AC-3 instead of Opus for this streaming session.
Definition audio.h:85
Static Opus encoder layout for one advertised audio mode.
Definition audio.h:38
std::int32_t sampleRate
Opus sample rate in hertz.
Definition audio.h:39
int streams
Number of Opus streams in the layout.
Definition audio.h:41
int channelCount
Number of audio channels in the Opus layout.
Definition audio.h:40
int coupledStreams
Number of stereo-coupled Opus streams.
Definition audio.h:42
const std::uint8_t * mapping
Channel mapping table passed to the Opus encoder.
Definition audio.h:43
int bitrate
Target bitrate in bits per second.
Definition audio.h:44
Custom Opus channel layout supplied by configuration.
Definition audio.h:50
int streams
Number of Opus streams in the custom layout.
Definition audio.h:52
int channelCount
Number of audio channels in the Opus layout.
Definition audio.h:51
int coupledStreams
Number of stereo-coupled Opus streams.
Definition audio.h:53
std::array< std::uint8_t, 8 > mapping
Channel mapping table for up to eight speakers.
Definition audio.h:54
Host and virtual audio sink names for audio routing.
Definition common.h:556
Pointer wrapper state protected by synchronization.
Definition thread_safe.h:568
Runtime state for one audio/video streaming session.
Definition stream.cpp:503
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
Declarations for utility functions.