gst_client_rs/
gstd_types.rs

1//! [`GStreamer Daemon HTTP`][1] API structures.
2//!
3//! [1]: https://developer.ridgerun.com/wiki/index.php/GStreamer_Daemon_-_HTTP_API
4#![allow(unreachable_pub, missing_docs)]
5
6use derive_more::{Display, Error};
7use serde::{Deserialize, Serialize};
8use serde_repr::{Deserialize_repr, Serialize_repr};
9
10pub const GST_SPLIT_MUX_SINK_FRAGMENT_MESSAGE_CLOSED: &str = "splitmuxsink-fragment-closed";
11pub const GST_SPLIT_MUX_SINK_FRAGMENT_MESSAGE_OPENED: &str = "splitmuxsink-fragment-opened";
12
13/// Response returned by [`GStreamer Daemon`][1] API.
14///
15/// [1]: https://developer.ridgerun.com/wiki/index.php/GStreamer_Daemon
16#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
17pub struct Response {
18    /// Status of response.
19    pub code: ResponseCode,
20    /// Description of command response.
21    /// Same as [`Response::code`] but with text
22    pub description: String,
23    /// The actual response data from the server
24    pub response: ResponseT,
25}
26
27/// Response Codes for [`Response`] of [`GStD`]
28///
29/// [`GStD`]: https://developer.ridgerun.com/wiki/index.php/GStreamer_Daemon
30#[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug, Clone, Copy, Error, Display)]
31#[repr(u8)]
32pub enum ResponseCode {
33    ///Everything went OK
34    Success = 0,
35    /// A mandatory argument was passed NULL
36    NullArgument = 1,
37    /// A bad pipeline description was provided
38    BadDescription = 2,
39    /// The name trying to be used already exists
40    ExistingName = 3,
41    /// Missing initialization
42    MissingInitialization = 4,
43    /// The requested pipeline was not found
44    NoPipeline = 5,
45    /// The requested resource was not found
46    NoResource = 6,
47    /// Cannot create a resource in the given property
48    NoCreate = 7,
49    /// The resource to create already exists
50    ExistingResource = 8,
51    /// Cannot update the given property
52    NoUpdate = 9,
53    /// Unknown command
54    BadCommand = 10,
55    /// Cannot read the given resource
56    NoRead = 11,
57    ///Cannot connect
58    NoConnection = 12,
59    /// The given value is incorrect
60    BadValue = 13,
61    /// Failed to change state of a pipeline
62    StateError = 14,
63    /// Failed to start IPC
64    IpcError = 15,
65    /// Unknown event
66    EventError = 16,
67    /// Incomplete arguments in user input
68    MissingArgument = 17,
69    /// Missing name of the pipeline
70    MissingName = 18,
71}
72
73#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
74#[serde(untagged)]
75pub enum ResponseT {
76    Bus(Option<Bus>),
77    Properties(Properties),
78    Property(Property),
79    GstSplitMuxSinkFragmentOpened(GstSplitMuxSinkFragmentOpened),
80    GstSplitMuxSinkFragmentClosed(GstSplitMuxSinkFragmentClosed),
81}
82
83#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
84pub struct Param {
85    pub description: String,
86    #[serde(rename = "type")]
87    pub _type: String,
88    pub access: String,
89}
90
91/// Possible result in [`Response::response`] after
92/// `GET /pipelines` API request
93#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
94pub struct Properties {
95    pub properties: Vec<Property>,
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub nodes: Option<Vec<Node>>,
98}
99
100#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
101pub struct Node {
102    /// The name of [`GStreamer element`]
103    ///
104    /// [`GStreamer element`]: https://gstreamer.freedesktop.org/documentation/
105    /// application-development/basics/elements.html
106    pub name: String,
107}
108
109/// Possible result in [`Response::response`] after
110/// `GET /pipelines/{pipeline_name}/graph` API request
111#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
112pub struct Property {
113    pub name: String,
114    pub value: PropertyValue,
115    pub param: Param,
116}
117
118#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
119#[serde(untagged)]
120pub enum PropertyValue {
121    String(String),
122    Integer(i32),
123    Bool(bool),
124}
125
126/// Possible result in [`Response::response`] after
127/// `GET /pipelines/{name}/bus/message` API request
128#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
129pub struct Bus {
130    pub r#type: String,
131    pub source: String,
132    pub timestamp: String,
133    pub seqnum: i64,
134    pub message: String,
135    pub debug: String,
136}
137
138#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
139pub struct GstSplitMuxSinkFragmentMessage {
140    pub location: String,
141    #[serde(rename = "running-time")]
142    pub running_time: u64,
143    pub sink: String,
144}
145
146#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
147pub struct GstSplitMuxSinkFragmentOpened {
148    pub r#type: String,
149    pub source: String,
150    pub timestamp: String,
151    pub seqnum: i64,
152    #[serde(rename = "splitmuxsink-fragment-opened")]
153    pub message: GstSplitMuxSinkFragmentMessage,
154}
155
156#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
157pub struct GstSplitMuxSinkFragmentClosed {
158    pub r#type: String,
159    pub source: String,
160    pub timestamp: String,
161    pub seqnum: i64,
162    #[serde(rename = "splitmuxsink-fragment-closed")]
163    pub message: GstSplitMuxSinkFragmentMessage,
164}