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