Skip to main content

arcly_stream/bus/
events.rs

1//! Stream lifecycle events.
2
3use crate::{AppName, StreamId};
4
5/// A lifecycle event emitted by an [`Application`](super::Application).
6#[derive(Debug, Clone)]
7pub struct StreamEvent {
8    /// Application the event belongs to.
9    pub app: AppName,
10    /// Stream the event concerns.
11    pub stream_id: StreamId,
12    /// What happened.
13    pub kind: StreamEventKind,
14}
15
16/// The kind of a [`StreamEvent`]. `#[non_exhaustive]` — match with a wildcard.
17#[derive(Debug, Clone, PartialEq, Eq)]
18#[non_exhaustive]
19pub enum StreamEventKind {
20    /// A publisher claimed the stream and began publishing.
21    PublishStarted,
22    /// The publisher released the stream.
23    PublishEnded,
24    /// A subscriber connected.
25    SubscriberJoined {
26        /// Name of the subscriber's protocol (e.g. `"rtmp"`).
27        protocol: String,
28    },
29    /// A subscriber disconnected.
30    SubscriberLeft {
31        /// Name of the subscriber's protocol.
32        protocol: String,
33    },
34    /// Recording of the stream began.
35    RecordingStarted,
36    /// Recording of the stream ended.
37    RecordingEnded,
38    /// Transcoding of the stream began.
39    TranscodeStarted,
40    /// Transcoding of the stream ended.
41    TranscodeEnded,
42    /// An error occurred for the stream.
43    Error {
44        /// Human-readable error detail.
45        message: String,
46    },
47}