songbird/driver/tasks/message/
mixer.rs

1#![allow(missing_docs)]
2
3#[cfg(feature = "receive")]
4use super::UdpRxMessage;
5use super::{Interconnect, TrackContext, WsMessage};
6
7use crate::{
8    driver::{crypto::Cipher, Bitrate, Config, CryptoState},
9    input::{AudioStreamError, Compose, Parsed},
10};
11use flume::Sender;
12use std::{net::UdpSocket, sync::Arc};
13use symphonia_core::{errors::Error as SymphoniaError, formats::SeekedTo};
14
15pub struct MixerConnection {
16    pub cipher: Cipher,
17    pub crypto_state: CryptoState,
18    #[cfg(feature = "receive")]
19    pub udp_rx: Sender<UdpRxMessage>,
20    pub udp_tx: UdpSocket,
21}
22
23pub enum MixerMessage {
24    AddTrack(TrackContext),
25    SetTrack(Option<TrackContext>),
26
27    SetBitrate(Bitrate),
28    SetConfig(Config),
29    SetMute(bool),
30
31    SetConn(MixerConnection, u32),
32    Ws(Option<Sender<WsMessage>>),
33    DropConn,
34
35    ReplaceInterconnect(Interconnect),
36    RebuildEncoder,
37
38    Poison,
39}
40
41impl MixerMessage {
42    #[must_use]
43    pub fn is_mixer_maybe_live(&self) -> bool {
44        matches!(
45            self,
46            Self::AddTrack(_) | Self::SetTrack(Some(_)) | Self::SetConn(..)
47        )
48    }
49}
50
51pub enum MixerInputResultMessage {
52    CreateErr(Arc<AudioStreamError>),
53    ParseErr(Arc<SymphoniaError>),
54    Seek(
55        Parsed,
56        Option<Box<dyn Compose>>,
57        Result<SeekedTo, Arc<SymphoniaError>>,
58    ),
59    Built(Parsed, Option<Box<dyn Compose>>),
60}