medea_control_api_proto/grpc/
api.rs

1// This file is @generated by prost-build.
2/// Request for creating a new `Element` on a media server.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct CreateRequest {
5    /// FID (Full ID) of the parent `Element` to create the provided `Element` in.
6    #[prost(string, tag = "1")]
7    pub parent_fid: ::prost::alloc::string::String,
8    /// Spec of the created `Element`.
9    #[prost(oneof = "create_request::El", tags = "2, 3, 4, 5")]
10    pub el: ::core::option::Option<create_request::El>,
11}
12/// Nested message and enum types in `CreateRequest`.
13pub mod create_request {
14    /// Spec of the created `Element`.
15    #[derive(Clone, PartialEq, ::prost::Oneof)]
16    pub enum El {
17        #[prost(message, tag = "2")]
18        Member(super::Member),
19        #[prost(message, tag = "3")]
20        Room(super::Room),
21        #[prost(message, tag = "4")]
22        WebrtcPlay(super::WebRtcPlayEndpoint),
23        #[prost(message, tag = "5")]
24        WebrtcPub(super::WebRtcPublishEndpoint),
25    }
26}
27/// Request with many FIDs (Full IDs) of `Element`s.
28#[derive(Clone, PartialEq, ::prost::Message)]
29pub struct IdRequest {
30    /// List of `Element`s FIDs.
31    #[prost(string, repeated, tag = "1")]
32    pub fid: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
33}
34/// Request for applying a spec to an exiting `Element` on a media server.
35#[derive(Clone, PartialEq, ::prost::Message)]
36pub struct ApplyRequest {
37    /// FID (full ID) of the parent `Element` to apply the provided spec to.
38    #[prost(string, tag = "1")]
39    pub parent_fid: ::prost::alloc::string::String,
40    /// Spec of the `Element` to be applied.
41    #[prost(oneof = "apply_request::El", tags = "2, 3, 4, 5")]
42    pub el: ::core::option::Option<apply_request::El>,
43}
44/// Nested message and enum types in `ApplyRequest`.
45pub mod apply_request {
46    /// Spec of the `Element` to be applied.
47    #[derive(Clone, PartialEq, ::prost::Oneof)]
48    pub enum El {
49        #[prost(message, tag = "2")]
50        Member(super::Member),
51        #[prost(message, tag = "3")]
52        Room(super::Room),
53        #[prost(message, tag = "4")]
54        WebrtcPlay(super::WebRtcPlayEndpoint),
55        #[prost(message, tag = "5")]
56        WebrtcPub(super::WebRtcPublishEndpoint),
57    }
58}
59/// Response which doesn't return anything on success, but is fallible with an
60/// `Error`.
61///
62/// If operation fails then an `Error` will be returned.
63/// The response is considered successful only if it doesn't contain an `Error`.
64#[derive(Clone, PartialEq, ::prost::Message)]
65pub struct Response {
66    /// Error of this `Response`.
67    #[prost(message, optional, tag = "1")]
68    pub error: ::core::option::Option<Error>,
69}
70/// Response of `ControlApi.Create` RPC method.
71///
72/// If operation fails then an `Error` will be returned.
73/// The response is considered successful only if it doesn't contain an `Error`.
74#[derive(Clone, PartialEq, ::prost::Message)]
75pub struct CreateResponse {
76    /// Hashmap with IDs (key) and URIs (value) of `Element`s, which should be used
77    /// by clients to connect to a media server via Client API.
78    ///
79    /// Returned only if this `CreateResponse` is successful.
80    #[prost(map = "string, string", tag = "1")]
81    pub sid: ::std::collections::HashMap<
82        ::prost::alloc::string::String,
83        ::prost::alloc::string::String,
84    >,
85    /// Error of this `CreateResponse`.
86    #[prost(message, optional, tag = "2")]
87    pub error: ::core::option::Option<Error>,
88}
89/// Response of `ControlApi.Get` RPC method.
90///
91/// If operation fails then an `Error` will be returned.
92/// The response is considered successful only if it doesn't contain an `Error`.
93#[derive(Clone, PartialEq, ::prost::Message)]
94pub struct GetResponse {
95    /// Hashmap with IDs (key) and specs (value) of the requested `Elements`.
96    ///
97    /// Returned only if this `GetResponse` is successful.
98    #[prost(map = "string, message", tag = "1")]
99    pub elements: ::std::collections::HashMap<::prost::alloc::string::String, Element>,
100    /// Error of this `GetResponse`.
101    #[prost(message, optional, tag = "2")]
102    pub error: ::core::option::Option<Error>,
103}
104/// Error of a failed request.
105///
106/// If an `Error` is not returned then a request is considered as successful.
107#[derive(Clone, PartialEq, ::prost::Message)]
108pub struct Error {
109    /// Concrete unique code of this `Error`.
110    #[prost(uint32, tag = "1")]
111    pub code: u32,
112    /// Human-readable text description of this `Error`.
113    #[prost(string, tag = "2")]
114    pub text: ::prost::alloc::string::String,
115    /// Link to online documentation of this `Error`.
116    ///
117    /// Optional field.
118    #[prost(string, tag = "3")]
119    pub doc: ::prost::alloc::string::String,
120    /// FID (Full ID) of the `Element` that this `Error` is related to.
121    /// Some `Error`s are not related to any `Element` and so have this field
122    /// empty.
123    ///
124    /// Optional field.
125    #[prost(string, tag = "4")]
126    pub element: ::prost::alloc::string::String,
127}
128/// Possible media elements forming a media pipeline.
129#[derive(Clone, PartialEq, ::prost::Message)]
130pub struct Element {
131    #[prost(oneof = "element::El", tags = "1, 2, 3, 4")]
132    pub el: ::core::option::Option<element::El>,
133}
134/// Nested message and enum types in `Element`.
135pub mod element {
136    #[derive(Clone, PartialEq, ::prost::Oneof)]
137    pub enum El {
138        #[prost(message, tag = "1")]
139        Member(super::Member),
140        #[prost(message, tag = "2")]
141        Room(super::Room),
142        #[prost(message, tag = "3")]
143        WebrtcPlay(super::WebRtcPlayEndpoint),
144        #[prost(message, tag = "4")]
145        WebrtcPub(super::WebRtcPublishEndpoint),
146    }
147}
148/// Media element representing a single space where multiple `Member`s can
149/// interact with each other.
150#[derive(Clone, PartialEq, ::prost::Message)]
151pub struct Room {
152    /// ID of this `Room`.
153    #[prost(string, tag = "1")]
154    pub id: ::prost::alloc::string::String,
155    /// Media pipeline representing this `Room`.
156    #[prost(map = "string, message", tag = "2")]
157    pub pipeline: ::std::collections::HashMap<
158        ::prost::alloc::string::String,
159        room::Element,
160    >,
161}
162/// Nested message and enum types in `Room`.
163pub mod room {
164    /// Possible media elements forming a `Room` pipeline.
165    #[derive(Clone, PartialEq, ::prost::Message)]
166    pub struct Element {
167        #[prost(oneof = "element::El", tags = "1, 2, 3")]
168        pub el: ::core::option::Option<element::El>,
169    }
170    /// Nested message and enum types in `Element`.
171    pub mod element {
172        #[derive(Clone, PartialEq, ::prost::Oneof)]
173        pub enum El {
174            #[prost(message, tag = "1")]
175            Member(super::super::Member),
176            #[prost(message, tag = "2")]
177            WebrtcPlay(super::super::WebRtcPlayEndpoint),
178            #[prost(message, tag = "3")]
179            WebrtcPub(super::super::WebRtcPublishEndpoint),
180        }
181    }
182}
183/// Media element representing a client authorized to participate in some bigger
184/// media pipeline (`Room`, for example).
185#[derive(Clone, PartialEq, ::prost::Message)]
186pub struct Member {
187    /// ID of this `Member`.
188    #[prost(string, tag = "1")]
189    pub id: ::prost::alloc::string::String,
190    /// URL of the callback to fire when this `Member` establishes a persistent
191    /// connection with a media server via Client API.
192    #[prost(string, tag = "2")]
193    pub on_join: ::prost::alloc::string::String,
194    /// URL of the callback to fire when this `Member` finishes a persistent
195    /// connection with a media server via Client API.
196    #[prost(string, tag = "3")]
197    pub on_leave: ::prost::alloc::string::String,
198    /// Timeout of receiving heartbeat messages from this `Member` via Client API.
199    /// Once reached, this `Member` is considered being idle.
200    #[prost(message, optional, tag = "6")]
201    pub idle_timeout: ::core::option::Option<::prost_types::Duration>,
202    /// Timeout of reconnecting this `Member` via Client API.
203    /// Once reached, this `Member` is considered disconnected.
204    #[prost(message, optional, tag = "7")]
205    pub reconnect_timeout: ::core::option::Option<::prost_types::Duration>,
206    /// Interval of pinging with heartbeat messages this `Member` via Client API
207    /// by a media server.
208    /// If empty then the default interval of a media server is used, if
209    /// configured.
210    #[prost(message, optional, tag = "8")]
211    pub ping_interval: ::core::option::Option<::prost_types::Duration>,
212    /// Media pipeline representing this `Member`.
213    #[prost(map = "string, message", tag = "9")]
214    pub pipeline: ::std::collections::HashMap<
215        ::prost::alloc::string::String,
216        member::Element,
217    >,
218    /// Credentials to authenticate this `Member` in Client API with.
219    ///
220    /// Plain and hashed credentials are supported. If no credentials provided,
221    /// then random plain string will be generated. If no authentication is
222    /// required then empty plain string can be used.
223    ///
224    /// Hashed variant only supports Argon2 hash at the moment.
225    /// `Member` sid won't contain a `token` query parameter if hashed credentials
226    /// are used, so it should be appended manually on a client side.
227    #[prost(oneof = "member::Credentials", tags = "4, 5")]
228    pub credentials: ::core::option::Option<member::Credentials>,
229}
230/// Nested message and enum types in `Member`.
231pub mod member {
232    /// Elements which Member's pipeline can contain.
233    #[derive(Clone, PartialEq, ::prost::Message)]
234    pub struct Element {
235        #[prost(oneof = "element::El", tags = "1, 2")]
236        pub el: ::core::option::Option<element::El>,
237    }
238    /// Nested message and enum types in `Element`.
239    pub mod element {
240        #[derive(Clone, PartialEq, ::prost::Oneof)]
241        pub enum El {
242            #[prost(message, tag = "1")]
243            WebrtcPlay(super::super::WebRtcPlayEndpoint),
244            #[prost(message, tag = "2")]
245            WebrtcPub(super::super::WebRtcPublishEndpoint),
246        }
247    }
248    /// Credentials to authenticate this `Member` in Client API with.
249    ///
250    /// Plain and hashed credentials are supported. If no credentials provided,
251    /// then random plain string will be generated. If no authentication is
252    /// required then empty plain string can be used.
253    ///
254    /// Hashed variant only supports Argon2 hash at the moment.
255    /// `Member` sid won't contain a `token` query parameter if hashed credentials
256    /// are used, so it should be appended manually on a client side.
257    #[derive(Clone, PartialEq, ::prost::Oneof)]
258    pub enum Credentials {
259        /// Argon2 hash of credentials.
260        #[prost(string, tag = "4")]
261        Hash(::prost::alloc::string::String),
262        /// Plain text credentials.
263        #[prost(string, tag = "5")]
264        Plain(::prost::alloc::string::String),
265    }
266}
267/// Media element receiving media data from a client via WebRTC (allows to
268/// publish media data).
269#[derive(Clone, PartialEq, ::prost::Message)]
270pub struct WebRtcPublishEndpoint {
271    /// ID of this `WebRtcPublishEndpoint`.
272    #[prost(string, tag = "1")]
273    pub id: ::prost::alloc::string::String,
274    /// Peer-to-peer mode of this `WebRtcPublishEndpoint`.
275    #[prost(enumeration = "web_rtc_publish_endpoint::P2p", tag = "2")]
276    pub p2p: i32,
277    /// Callback firing when a client starts publishing media data.
278    #[prost(string, tag = "3")]
279    pub on_start: ::prost::alloc::string::String,
280    /// Callback firing when a client stops publishing media data.
281    #[prost(string, tag = "4")]
282    pub on_stop: ::prost::alloc::string::String,
283    /// Indicator whether to relay all media data through a TURN server forcibly.
284    #[prost(bool, tag = "5")]
285    pub force_relay: bool,
286    /// Settings for the audio media type of this `WebRtcPublishEndpoint`.
287    #[prost(message, optional, tag = "6")]
288    pub audio_settings: ::core::option::Option<web_rtc_publish_endpoint::AudioSettings>,
289    /// Settings for the video media type of this `WebRtcPublishEndpoint`.
290    #[prost(message, optional, tag = "7")]
291    pub video_settings: ::core::option::Option<web_rtc_publish_endpoint::VideoSettings>,
292}
293/// Nested message and enum types in `WebRtcPublishEndpoint`.
294pub mod web_rtc_publish_endpoint {
295    /// Audio media type settings of a `WebRtcPublishEndpoint`.
296    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
297    pub struct AudioSettings {
298        /// Policy to publish the audio media type with.
299        #[prost(enumeration = "PublishPolicy", tag = "1")]
300        pub publish_policy: i32,
301    }
302    /// Video media type settings of `WebRtcPublishEndpoint`.
303    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
304    pub struct VideoSettings {
305        /// Policy to publish the video media type with.
306        #[prost(enumeration = "PublishPolicy", tag = "1")]
307        pub publish_policy: i32,
308    }
309    /// Policy of how a video or an audio media type can be published in a
310    /// `WebRtcPublishEndpoint`.
311    #[derive(
312        Clone,
313        Copy,
314        Debug,
315        PartialEq,
316        Eq,
317        Hash,
318        PartialOrd,
319        Ord,
320        ::prost::Enumeration
321    )]
322    #[repr(i32)]
323    pub enum PublishPolicy {
324        /// Media type MAY be published.
325        ///
326        /// Media server will try to initialize publishing, but won't produce any
327        /// errors if user application fails to (or chooses not to) acquire the
328        /// required media track. Media server will approve user requests to stop and
329        /// to restart publishing the specified media type.
330        Optional = 0,
331        /// Media type MUST be published.
332        ///
333        /// Media server will try to initialize publishing, and if the required media
334        /// track cannot be acquired, then an error will be thrown. Media server will
335        /// deny all requests to stop publishing.
336        Required = 1,
337        /// Media type MUST NOT be published.
338        ///
339        /// Media server will not try to initialize publishing.
340        Disabled = 2,
341    }
342    impl PublishPolicy {
343        /// String value of the enum field names used in the ProtoBuf definition.
344        ///
345        /// The values are not transformed in any way and thus are considered stable
346        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
347        pub fn as_str_name(&self) -> &'static str {
348            match self {
349                Self::Optional => "OPTIONAL",
350                Self::Required => "REQUIRED",
351                Self::Disabled => "DISABLED",
352            }
353        }
354        /// Creates an enum from field names used in the ProtoBuf definition.
355        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
356            match value {
357                "OPTIONAL" => Some(Self::Optional),
358                "REQUIRED" => Some(Self::Required),
359                "DISABLED" => Some(Self::Disabled),
360                _ => None,
361            }
362        }
363    }
364    /// Possible peer-to-peer modes of WebRTC interaction in a
365    /// `WebRtcPublishEndpoint`.
366    #[derive(
367        Clone,
368        Copy,
369        Debug,
370        PartialEq,
371        Eq,
372        Hash,
373        PartialOrd,
374        Ord,
375        ::prost::Enumeration
376    )]
377    #[repr(i32)]
378    pub enum P2p {
379        /// Never use peer-to-peer connections and always send media data through a
380        /// media server.
381        Never = 0,
382        /// Use peer-to-peer connections directly if it's possible, otherwise send
383        /// media data through a media server.
384        IfPossible = 1,
385        /// Send media data via peer-to-peer connections only, and never through a
386        /// media server.
387        Always = 2,
388    }
389    impl P2p {
390        /// String value of the enum field names used in the ProtoBuf definition.
391        ///
392        /// The values are not transformed in any way and thus are considered stable
393        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
394        pub fn as_str_name(&self) -> &'static str {
395            match self {
396                Self::Never => "NEVER",
397                Self::IfPossible => "IF_POSSIBLE",
398                Self::Always => "ALWAYS",
399            }
400        }
401        /// Creates an enum from field names used in the ProtoBuf definition.
402        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
403            match value {
404                "NEVER" => Some(Self::Never),
405                "IF_POSSIBLE" => Some(Self::IfPossible),
406                "ALWAYS" => Some(Self::Always),
407                _ => None,
408            }
409        }
410    }
411}
412/// Media element playing media data for a client via WebRTC.
413#[derive(Clone, PartialEq, ::prost::Message)]
414pub struct WebRtcPlayEndpoint {
415    /// ID of this `WebRtcPlayEndpoint`.
416    #[prost(string, tag = "1")]
417    pub id: ::prost::alloc::string::String,
418    /// / Source to play media data from.
419    #[prost(string, tag = "2")]
420    pub src: ::prost::alloc::string::String,
421    /// Callback firing when a client starts playing media data from the source.
422    #[prost(string, tag = "3")]
423    pub on_start: ::prost::alloc::string::String,
424    /// Callback firing when a client stops playing media data from the source.
425    #[prost(string, tag = "4")]
426    pub on_stop: ::prost::alloc::string::String,
427    /// Indicator whether to relay all media data through a TURN server forcibly.
428    #[prost(bool, tag = "5")]
429    pub force_relay: bool,
430}
431/// Ping message received by a media server periodically for probing its
432/// healthiness.
433#[derive(Clone, Copy, PartialEq, ::prost::Message)]
434pub struct Ping {
435    /// Each new `Ping` should increment its nonce, starting with 0.
436    #[prost(uint32, tag = "1")]
437    pub nonce: u32,
438}
439/// Pong message sent by a media server in response to a received `Ping` message.
440#[derive(Clone, Copy, PartialEq, ::prost::Message)]
441pub struct Pong {
442    /// / Nonce of the answered `Ping` message.
443    #[prost(uint32, tag = "1")]
444    pub nonce: u32,
445}
446/// Generated client implementations.
447pub mod control_api_client {
448    #![allow(
449        unused_variables,
450        dead_code,
451        missing_docs,
452        clippy::wildcard_imports,
453        clippy::let_unit_value,
454    )]
455    use tonic::codegen::*;
456    use tonic::codegen::http::Uri;
457    /// Service allowing to control a media server dynamically, by creating, updating
458    /// and destroying pipelines of media `Element`s on it.
459    #[derive(Debug, Clone)]
460    pub struct ControlApiClient<T> {
461        inner: tonic::client::Grpc<T>,
462    }
463    impl ControlApiClient<tonic::transport::Channel> {
464        /// Attempt to create a new client by connecting to a given endpoint.
465        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
466        where
467            D: TryInto<tonic::transport::Endpoint>,
468            D::Error: Into<StdError>,
469        {
470            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
471            Ok(Self::new(conn))
472        }
473    }
474    impl<T> ControlApiClient<T>
475    where
476        T: tonic::client::GrpcService<tonic::body::Body>,
477        T::Error: Into<StdError>,
478        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
479        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
480    {
481        pub fn new(inner: T) -> Self {
482            let inner = tonic::client::Grpc::new(inner);
483            Self { inner }
484        }
485        pub fn with_origin(inner: T, origin: Uri) -> Self {
486            let inner = tonic::client::Grpc::with_origin(inner, origin);
487            Self { inner }
488        }
489        pub fn with_interceptor<F>(
490            inner: T,
491            interceptor: F,
492        ) -> ControlApiClient<InterceptedService<T, F>>
493        where
494            F: tonic::service::Interceptor,
495            T::ResponseBody: Default,
496            T: tonic::codegen::Service<
497                http::Request<tonic::body::Body>,
498                Response = http::Response<
499                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
500                >,
501            >,
502            <T as tonic::codegen::Service<
503                http::Request<tonic::body::Body>,
504            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
505        {
506            ControlApiClient::new(InterceptedService::new(inner, interceptor))
507        }
508        /// Compress requests with the given encoding.
509        ///
510        /// This requires the server to support it otherwise it might respond with an
511        /// error.
512        #[must_use]
513        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
514            self.inner = self.inner.send_compressed(encoding);
515            self
516        }
517        /// Enable decompressing responses.
518        #[must_use]
519        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
520            self.inner = self.inner.accept_compressed(encoding);
521            self
522        }
523        /// Limits the maximum size of a decoded message.
524        ///
525        /// Default: `4MB`
526        #[must_use]
527        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
528            self.inner = self.inner.max_decoding_message_size(limit);
529            self
530        }
531        /// Limits the maximum size of an encoded message.
532        ///
533        /// Default: `usize::MAX`
534        #[must_use]
535        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
536            self.inner = self.inner.max_encoding_message_size(limit);
537            self
538        }
539        /// Creates a new `Element` on the media server.
540        ///
541        /// Non-idempotent. Errors if an `Element` with such ID already exists.
542        pub async fn create(
543            &mut self,
544            request: impl tonic::IntoRequest<super::CreateRequest>,
545        ) -> std::result::Result<tonic::Response<super::CreateResponse>, tonic::Status> {
546            self.inner
547                .ready()
548                .await
549                .map_err(|e| {
550                    tonic::Status::unknown(
551                        format!("Service was not ready: {}", e.into()),
552                    )
553                })?;
554            let codec = tonic::codec::ProstCodec::default();
555            let path = http::uri::PathAndQuery::from_static("/api.ControlApi/Create");
556            let mut req = request.into_request();
557            req.extensions_mut().insert(GrpcMethod::new("api.ControlApi", "Create"));
558            self.inner.unary(req, path, codec).await
559        }
560        /// Removes `Element`s from the media server.
561        /// Allows referring multiple `Element`s on the last two levels of a FID.
562        ///
563        /// Idempotent. If no `Element`s with such FIDs exist, then succeeds.
564        pub async fn delete(
565            &mut self,
566            request: impl tonic::IntoRequest<super::IdRequest>,
567        ) -> std::result::Result<tonic::Response<super::Response>, tonic::Status> {
568            self.inner
569                .ready()
570                .await
571                .map_err(|e| {
572                    tonic::Status::unknown(
573                        format!("Service was not ready: {}", e.into()),
574                    )
575                })?;
576            let codec = tonic::codec::ProstCodec::default();
577            let path = http::uri::PathAndQuery::from_static("/api.ControlApi/Delete");
578            let mut req = request.into_request();
579            req.extensions_mut().insert(GrpcMethod::new("api.ControlApi", "Delete"));
580            self.inner.unary(req, path, codec).await
581        }
582        /// Lookups `Element`s by their FIDs on the media server.
583        /// If no FIDs are specified, then returns all the current `Element`s on the
584        /// media server.
585        pub async fn get(
586            &mut self,
587            request: impl tonic::IntoRequest<super::IdRequest>,
588        ) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status> {
589            self.inner
590                .ready()
591                .await
592                .map_err(|e| {
593                    tonic::Status::unknown(
594                        format!("Service was not ready: {}", e.into()),
595                    )
596                })?;
597            let codec = tonic::codec::ProstCodec::default();
598            let path = http::uri::PathAndQuery::from_static("/api.ControlApi/Get");
599            let mut req = request.into_request();
600            req.extensions_mut().insert(GrpcMethod::new("api.ControlApi", "Get"));
601            self.inner.unary(req, path, codec).await
602        }
603        /// Applies changes to an existing `Element` on the media server, or creates a
604        /// new one in case there is no `Element` with such ID.
605        ///
606        /// Idempotent. If no `Element` with such ID exists, then it will be created,
607        /// otherwise it will be reconfigured. `Element`s that exist on the same
608        /// hierarchy level, but are not specified in the provided spec, will be
609        /// removed.
610        pub async fn apply(
611            &mut self,
612            request: impl tonic::IntoRequest<super::ApplyRequest>,
613        ) -> std::result::Result<tonic::Response<super::CreateResponse>, tonic::Status> {
614            self.inner
615                .ready()
616                .await
617                .map_err(|e| {
618                    tonic::Status::unknown(
619                        format!("Service was not ready: {}", e.into()),
620                    )
621                })?;
622            let codec = tonic::codec::ProstCodec::default();
623            let path = http::uri::PathAndQuery::from_static("/api.ControlApi/Apply");
624            let mut req = request.into_request();
625            req.extensions_mut().insert(GrpcMethod::new("api.ControlApi", "Apply"));
626            self.inner.unary(req, path, codec).await
627        }
628        /// Checks healthiness of the media server.
629        /// Caller should assert that the returned `Pong` has the same nonce as the
630        /// sent `Ping`.
631        pub async fn healthz(
632            &mut self,
633            request: impl tonic::IntoRequest<super::Ping>,
634        ) -> std::result::Result<tonic::Response<super::Pong>, tonic::Status> {
635            self.inner
636                .ready()
637                .await
638                .map_err(|e| {
639                    tonic::Status::unknown(
640                        format!("Service was not ready: {}", e.into()),
641                    )
642                })?;
643            let codec = tonic::codec::ProstCodec::default();
644            let path = http::uri::PathAndQuery::from_static("/api.ControlApi/Healthz");
645            let mut req = request.into_request();
646            req.extensions_mut().insert(GrpcMethod::new("api.ControlApi", "Healthz"));
647            self.inner.unary(req, path, codec).await
648        }
649    }
650}
651/// Generated server implementations.
652pub mod control_api_server {
653    #![allow(
654        unused_variables,
655        dead_code,
656        missing_docs,
657        clippy::wildcard_imports,
658        clippy::let_unit_value,
659    )]
660    use tonic::codegen::*;
661    /// Generated trait containing gRPC methods that should be implemented for use with ControlApiServer.
662    #[async_trait]
663    pub trait ControlApi: std::marker::Send + std::marker::Sync + 'static {
664        /// Creates a new `Element` on the media server.
665        ///
666        /// Non-idempotent. Errors if an `Element` with such ID already exists.
667        async fn create(
668            &self,
669            request: tonic::Request<super::CreateRequest>,
670        ) -> std::result::Result<tonic::Response<super::CreateResponse>, tonic::Status>;
671        /// Removes `Element`s from the media server.
672        /// Allows referring multiple `Element`s on the last two levels of a FID.
673        ///
674        /// Idempotent. If no `Element`s with such FIDs exist, then succeeds.
675        async fn delete(
676            &self,
677            request: tonic::Request<super::IdRequest>,
678        ) -> std::result::Result<tonic::Response<super::Response>, tonic::Status>;
679        /// Lookups `Element`s by their FIDs on the media server.
680        /// If no FIDs are specified, then returns all the current `Element`s on the
681        /// media server.
682        async fn get(
683            &self,
684            request: tonic::Request<super::IdRequest>,
685        ) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status>;
686        /// Applies changes to an existing `Element` on the media server, or creates a
687        /// new one in case there is no `Element` with such ID.
688        ///
689        /// Idempotent. If no `Element` with such ID exists, then it will be created,
690        /// otherwise it will be reconfigured. `Element`s that exist on the same
691        /// hierarchy level, but are not specified in the provided spec, will be
692        /// removed.
693        async fn apply(
694            &self,
695            request: tonic::Request<super::ApplyRequest>,
696        ) -> std::result::Result<tonic::Response<super::CreateResponse>, tonic::Status>;
697        /// Checks healthiness of the media server.
698        /// Caller should assert that the returned `Pong` has the same nonce as the
699        /// sent `Ping`.
700        async fn healthz(
701            &self,
702            request: tonic::Request<super::Ping>,
703        ) -> std::result::Result<tonic::Response<super::Pong>, tonic::Status>;
704    }
705    /// Service allowing to control a media server dynamically, by creating, updating
706    /// and destroying pipelines of media `Element`s on it.
707    #[derive(Debug)]
708    pub struct ControlApiServer<T> {
709        inner: Arc<T>,
710        accept_compression_encodings: EnabledCompressionEncodings,
711        send_compression_encodings: EnabledCompressionEncodings,
712        max_decoding_message_size: Option<usize>,
713        max_encoding_message_size: Option<usize>,
714    }
715    impl<T> ControlApiServer<T> {
716        pub fn new(inner: T) -> Self {
717            Self::from_arc(Arc::new(inner))
718        }
719        pub fn from_arc(inner: Arc<T>) -> Self {
720            Self {
721                inner,
722                accept_compression_encodings: Default::default(),
723                send_compression_encodings: Default::default(),
724                max_decoding_message_size: None,
725                max_encoding_message_size: None,
726            }
727        }
728        pub fn with_interceptor<F>(
729            inner: T,
730            interceptor: F,
731        ) -> InterceptedService<Self, F>
732        where
733            F: tonic::service::Interceptor,
734        {
735            InterceptedService::new(Self::new(inner), interceptor)
736        }
737        /// Enable decompressing requests with the given encoding.
738        #[must_use]
739        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
740            self.accept_compression_encodings.enable(encoding);
741            self
742        }
743        /// Compress responses with the given encoding, if the client supports it.
744        #[must_use]
745        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
746            self.send_compression_encodings.enable(encoding);
747            self
748        }
749        /// Limits the maximum size of a decoded message.
750        ///
751        /// Default: `4MB`
752        #[must_use]
753        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
754            self.max_decoding_message_size = Some(limit);
755            self
756        }
757        /// Limits the maximum size of an encoded message.
758        ///
759        /// Default: `usize::MAX`
760        #[must_use]
761        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
762            self.max_encoding_message_size = Some(limit);
763            self
764        }
765    }
766    impl<T, B> tonic::codegen::Service<http::Request<B>> for ControlApiServer<T>
767    where
768        T: ControlApi,
769        B: Body + std::marker::Send + 'static,
770        B::Error: Into<StdError> + std::marker::Send + 'static,
771    {
772        type Response = http::Response<tonic::body::Body>;
773        type Error = std::convert::Infallible;
774        type Future = BoxFuture<Self::Response, Self::Error>;
775        fn poll_ready(
776            &mut self,
777            _cx: &mut Context<'_>,
778        ) -> Poll<std::result::Result<(), Self::Error>> {
779            Poll::Ready(Ok(()))
780        }
781        fn call(&mut self, req: http::Request<B>) -> Self::Future {
782            match req.uri().path() {
783                "/api.ControlApi/Create" => {
784                    #[allow(non_camel_case_types)]
785                    struct CreateSvc<T: ControlApi>(pub Arc<T>);
786                    impl<T: ControlApi> tonic::server::UnaryService<super::CreateRequest>
787                    for CreateSvc<T> {
788                        type Response = super::CreateResponse;
789                        type Future = BoxFuture<
790                            tonic::Response<Self::Response>,
791                            tonic::Status,
792                        >;
793                        fn call(
794                            &mut self,
795                            request: tonic::Request<super::CreateRequest>,
796                        ) -> Self::Future {
797                            let inner = Arc::clone(&self.0);
798                            let fut = async move {
799                                <T as ControlApi>::create(&inner, request).await
800                            };
801                            Box::pin(fut)
802                        }
803                    }
804                    let accept_compression_encodings = self.accept_compression_encodings;
805                    let send_compression_encodings = self.send_compression_encodings;
806                    let max_decoding_message_size = self.max_decoding_message_size;
807                    let max_encoding_message_size = self.max_encoding_message_size;
808                    let inner = self.inner.clone();
809                    let fut = async move {
810                        let method = CreateSvc(inner);
811                        let codec = tonic::codec::ProstCodec::default();
812                        let mut grpc = tonic::server::Grpc::new(codec)
813                            .apply_compression_config(
814                                accept_compression_encodings,
815                                send_compression_encodings,
816                            )
817                            .apply_max_message_size_config(
818                                max_decoding_message_size,
819                                max_encoding_message_size,
820                            );
821                        let res = grpc.unary(method, req).await;
822                        Ok(res)
823                    };
824                    Box::pin(fut)
825                }
826                "/api.ControlApi/Delete" => {
827                    #[allow(non_camel_case_types)]
828                    struct DeleteSvc<T: ControlApi>(pub Arc<T>);
829                    impl<T: ControlApi> tonic::server::UnaryService<super::IdRequest>
830                    for DeleteSvc<T> {
831                        type Response = super::Response;
832                        type Future = BoxFuture<
833                            tonic::Response<Self::Response>,
834                            tonic::Status,
835                        >;
836                        fn call(
837                            &mut self,
838                            request: tonic::Request<super::IdRequest>,
839                        ) -> Self::Future {
840                            let inner = Arc::clone(&self.0);
841                            let fut = async move {
842                                <T as ControlApi>::delete(&inner, request).await
843                            };
844                            Box::pin(fut)
845                        }
846                    }
847                    let accept_compression_encodings = self.accept_compression_encodings;
848                    let send_compression_encodings = self.send_compression_encodings;
849                    let max_decoding_message_size = self.max_decoding_message_size;
850                    let max_encoding_message_size = self.max_encoding_message_size;
851                    let inner = self.inner.clone();
852                    let fut = async move {
853                        let method = DeleteSvc(inner);
854                        let codec = tonic::codec::ProstCodec::default();
855                        let mut grpc = tonic::server::Grpc::new(codec)
856                            .apply_compression_config(
857                                accept_compression_encodings,
858                                send_compression_encodings,
859                            )
860                            .apply_max_message_size_config(
861                                max_decoding_message_size,
862                                max_encoding_message_size,
863                            );
864                        let res = grpc.unary(method, req).await;
865                        Ok(res)
866                    };
867                    Box::pin(fut)
868                }
869                "/api.ControlApi/Get" => {
870                    #[allow(non_camel_case_types)]
871                    struct GetSvc<T: ControlApi>(pub Arc<T>);
872                    impl<T: ControlApi> tonic::server::UnaryService<super::IdRequest>
873                    for GetSvc<T> {
874                        type Response = super::GetResponse;
875                        type Future = BoxFuture<
876                            tonic::Response<Self::Response>,
877                            tonic::Status,
878                        >;
879                        fn call(
880                            &mut self,
881                            request: tonic::Request<super::IdRequest>,
882                        ) -> Self::Future {
883                            let inner = Arc::clone(&self.0);
884                            let fut = async move {
885                                <T as ControlApi>::get(&inner, request).await
886                            };
887                            Box::pin(fut)
888                        }
889                    }
890                    let accept_compression_encodings = self.accept_compression_encodings;
891                    let send_compression_encodings = self.send_compression_encodings;
892                    let max_decoding_message_size = self.max_decoding_message_size;
893                    let max_encoding_message_size = self.max_encoding_message_size;
894                    let inner = self.inner.clone();
895                    let fut = async move {
896                        let method = GetSvc(inner);
897                        let codec = tonic::codec::ProstCodec::default();
898                        let mut grpc = tonic::server::Grpc::new(codec)
899                            .apply_compression_config(
900                                accept_compression_encodings,
901                                send_compression_encodings,
902                            )
903                            .apply_max_message_size_config(
904                                max_decoding_message_size,
905                                max_encoding_message_size,
906                            );
907                        let res = grpc.unary(method, req).await;
908                        Ok(res)
909                    };
910                    Box::pin(fut)
911                }
912                "/api.ControlApi/Apply" => {
913                    #[allow(non_camel_case_types)]
914                    struct ApplySvc<T: ControlApi>(pub Arc<T>);
915                    impl<T: ControlApi> tonic::server::UnaryService<super::ApplyRequest>
916                    for ApplySvc<T> {
917                        type Response = super::CreateResponse;
918                        type Future = BoxFuture<
919                            tonic::Response<Self::Response>,
920                            tonic::Status,
921                        >;
922                        fn call(
923                            &mut self,
924                            request: tonic::Request<super::ApplyRequest>,
925                        ) -> Self::Future {
926                            let inner = Arc::clone(&self.0);
927                            let fut = async move {
928                                <T as ControlApi>::apply(&inner, request).await
929                            };
930                            Box::pin(fut)
931                        }
932                    }
933                    let accept_compression_encodings = self.accept_compression_encodings;
934                    let send_compression_encodings = self.send_compression_encodings;
935                    let max_decoding_message_size = self.max_decoding_message_size;
936                    let max_encoding_message_size = self.max_encoding_message_size;
937                    let inner = self.inner.clone();
938                    let fut = async move {
939                        let method = ApplySvc(inner);
940                        let codec = tonic::codec::ProstCodec::default();
941                        let mut grpc = tonic::server::Grpc::new(codec)
942                            .apply_compression_config(
943                                accept_compression_encodings,
944                                send_compression_encodings,
945                            )
946                            .apply_max_message_size_config(
947                                max_decoding_message_size,
948                                max_encoding_message_size,
949                            );
950                        let res = grpc.unary(method, req).await;
951                        Ok(res)
952                    };
953                    Box::pin(fut)
954                }
955                "/api.ControlApi/Healthz" => {
956                    #[allow(non_camel_case_types)]
957                    struct HealthzSvc<T: ControlApi>(pub Arc<T>);
958                    impl<T: ControlApi> tonic::server::UnaryService<super::Ping>
959                    for HealthzSvc<T> {
960                        type Response = super::Pong;
961                        type Future = BoxFuture<
962                            tonic::Response<Self::Response>,
963                            tonic::Status,
964                        >;
965                        fn call(
966                            &mut self,
967                            request: tonic::Request<super::Ping>,
968                        ) -> Self::Future {
969                            let inner = Arc::clone(&self.0);
970                            let fut = async move {
971                                <T as ControlApi>::healthz(&inner, request).await
972                            };
973                            Box::pin(fut)
974                        }
975                    }
976                    let accept_compression_encodings = self.accept_compression_encodings;
977                    let send_compression_encodings = self.send_compression_encodings;
978                    let max_decoding_message_size = self.max_decoding_message_size;
979                    let max_encoding_message_size = self.max_encoding_message_size;
980                    let inner = self.inner.clone();
981                    let fut = async move {
982                        let method = HealthzSvc(inner);
983                        let codec = tonic::codec::ProstCodec::default();
984                        let mut grpc = tonic::server::Grpc::new(codec)
985                            .apply_compression_config(
986                                accept_compression_encodings,
987                                send_compression_encodings,
988                            )
989                            .apply_max_message_size_config(
990                                max_decoding_message_size,
991                                max_encoding_message_size,
992                            );
993                        let res = grpc.unary(method, req).await;
994                        Ok(res)
995                    };
996                    Box::pin(fut)
997                }
998                _ => {
999                    Box::pin(async move {
1000                        let mut response = http::Response::new(
1001                            tonic::body::Body::default(),
1002                        );
1003                        let headers = response.headers_mut();
1004                        headers
1005                            .insert(
1006                                tonic::Status::GRPC_STATUS,
1007                                (tonic::Code::Unimplemented as i32).into(),
1008                            );
1009                        headers
1010                            .insert(
1011                                http::header::CONTENT_TYPE,
1012                                tonic::metadata::GRPC_CONTENT_TYPE,
1013                            );
1014                        Ok(response)
1015                    })
1016                }
1017            }
1018        }
1019    }
1020    impl<T> Clone for ControlApiServer<T> {
1021        fn clone(&self) -> Self {
1022            let inner = self.inner.clone();
1023            Self {
1024                inner,
1025                accept_compression_encodings: self.accept_compression_encodings,
1026                send_compression_encodings: self.send_compression_encodings,
1027                max_decoding_message_size: self.max_decoding_message_size,
1028                max_encoding_message_size: self.max_encoding_message_size,
1029            }
1030        }
1031    }
1032    /// Generated gRPC service name
1033    pub const SERVICE_NAME: &str = "api.ControlApi";
1034    impl<T> tonic::server::NamedService for ControlApiServer<T> {
1035        const NAME: &'static str = SERVICE_NAME;
1036    }
1037}