scuffle_rtmp/command_messages/netstream/
mod.rs

1//! NetStream command messages.
2
3use scuffle_amf0::{Amf0Object, Amf0Value};
4use scuffle_bytes_util::StringCow;
5use serde_derive::{Deserialize, Serialize};
6
7pub mod reader;
8
9/// NetStream commands as defined in 7.2.2.
10#[derive(Debug, Clone, PartialEq)]
11pub enum NetStreamCommand<'a> {
12    /// Play command.
13    Play {
14        /// All values in the command.
15        ///
16        /// See the legacy RTMP spec for details.
17        values: Vec<Amf0Value<'static>>,
18    },
19    /// Play2 command.
20    Play2 {
21        /// All values in the command.
22        ///
23        /// See the legacy RTMP spec for details.
24        parameters: Amf0Object<'static>,
25    },
26    /// Delete stream command.
27    DeleteStream {
28        /// ID of the stream to delete.
29        stream_id: f64,
30    },
31    /// Close stream command.
32    CloseStream,
33    /// Receive audio command.
34    ReceiveAudio {
35        /// true or false to indicate whether to receive audio or not.
36        receive_audio: bool,
37    },
38    /// Receive video command.
39    ReceiveVideo {
40        /// true or false to indicate whether to receive video or not.
41        receive_video: bool,
42    },
43    /// Publish command.
44    Publish {
45        /// Name with which the stream is published.
46        publishing_name: StringCow<'a>,
47        /// Type of publishing.
48        publishing_type: NetStreamCommandPublishPublishingType<'a>,
49    },
50    /// Seek command.
51    Seek {
52        /// Number of milliseconds to seek into the playlist.
53        milliseconds: f64,
54    },
55    /// Pause command.
56    Pause {
57        /// true or false, to indicate pausing or resuming play.
58        pause: bool,
59        /// Number of milliseconds at which the
60        /// the stream is paused or play resumed.
61        /// This is the current stream time at the
62        /// Client when stream was paused. When the
63        /// playback is resumed, the server will
64        /// only send messages with timestamps
65        /// greater than this value.
66        milliseconds: f64,
67    },
68}
69
70/// Type of publishing.
71///
72/// Appears as part of the [`NetStreamCommand::Publish`] command.
73#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
74#[serde(rename_all = "camelCase")]
75pub enum NetStreamCommandPublishPublishingType<'a> {
76    /// Citing the legacy RTMP spec, page 46:
77    /// Live data is published without recording it in a file.
78    Live,
79    /// Citing the legacy RTMP spec, page 46:
80    /// > The stream is published and the
81    /// > data is recorded to a new file. The file
82    /// > is stored on the server in a
83    /// > subdirectory within the directory that
84    /// > contains the server application. If the
85    /// > file already exists, it is overwritten.
86    Record,
87    /// Citing the legacy RTMP spec, page 46:
88    /// The stream is published and the
89    /// data is appended to a file. If no file
90    /// is found, it is created.
91    Append,
92    /// Any other value.
93    #[serde(untagged, borrow)]
94    Unknown(StringCow<'a>),
95}