scuffle_rtmp/command_messages/on_status/mod.rs
1//! Types and functions for processing the `onStatus` command.
2//!
3//! It is not very clear if the onStatus command should be part of the NetConnection or NetStream set of commands.
4//! The legacy RTMP spec makes it look like it should be part of the NetStream commands while the enhanced-rtmp-v2 spec
5//! is very clear that it should be part of the NetConnection commands.
6//! In reality, it is used as a response message to both NetConnection and NetStream commands received from the client.
7//! This is why we have decided to put it in its own module.
8
9use nutype_enum::nutype_enum;
10use scuffle_amf0::Amf0Object;
11use scuffle_bytes_util::StringCow;
12use serde_derive::Serialize;
13
14use crate::command_messages::CommandResultLevel;
15
16pub mod writer;
17
18/// The `onStatus` command is used to send status information from the server to the client.
19#[derive(Debug, Clone, PartialEq, Serialize)]
20#[serde(rename_all = "camelCase")]
21pub struct OnStatus<'a> {
22 /// The status code.
23 ///
24 /// Refer to the [`OnStatusCode`] enum for a list of common status codes.
25 pub code: OnStatusCode,
26 /// The description of the status update.
27 pub description: Option<StringCow<'a>>,
28 /// The level of the status update.
29 pub level: CommandResultLevel,
30 /// Any other additional information that should be sent as part of the object.
31 #[serde(flatten)]
32 pub others: Option<Amf0Object<'a>>,
33}
34
35nutype_enum! {
36 /// Common status codes used in the `onStatus` command.
37 #[derive(Serialize)]
38 #[serde(transparent)]
39 pub enum OnStatusCode(&'static str) {
40 /// The `NetConnection.call()` method was not able to invoke the server-side method or command.
41 NET_CONNECTION_CALL_FAILED = "NetConnection.Call.Failed",
42 /// The application has been shut down (for example, if the application is out of memory resources
43 /// and must shut down to prevent the server from crashing) or the server has shut down.
44 NET_CONNECTION_CONNECT_APP_SHUTDOWN = "NetConnection.Connect.AppShutdown",
45 /// The connection was closed successfully.
46 NET_CONNECTION_CONNECT_CLOSED = "NetConnection.Connect.Closed",
47 /// The connection attempt failed.
48 NET_CONNECTION_CONNECT_FAILED = "NetConnection.Connect.Failed",
49 /// The client does not have permission to connect to the application.
50 NET_CONNECTION_CONNECT_REJECTED = "NetConnection.Connect.Rejected",
51 /// The connection attempt succeeded.
52 NET_CONNECTION_CONNECT_SUCCESS = "NetConnection.Connect.Success",
53 /// The server is requesting the client to reconnect.
54 NET_CONNECTION_CONNECT_RECONNECT_REQUEST = "NetConnection.Connect.ReconnectRequest",
55 /// The proxy server is not responding. See the ProxyStream class.
56 NET_CONNECTION_PROXY_NOT_RESPONDING = "NetConnection.Proxy.NotResponding",
57
58 /// Publishing has started.
59 NET_STREAM_PUBLISH_START = "NetStream.Publish.Start",
60 /// Stream was successfully deleted.
61 NET_STREAM_DELETE_STREAM_SUCCESS = "NetStream.DeleteStream.Suceess",
62 }
63}