From d18761892edf0f816722b9ac622d6a64e1567ab3 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Tue, 29 Nov 2022 10:51:30 +0530 Subject: [PATCH] webrtchttp: Use a proper Rust type name for ICE transport policy We don't need to namespace here but can just use the Rust namespaces. Only the GType name has to stay like it is. Part-of: --- net/webrtchttp/src/lib.rs | 4 ++-- net/webrtchttp/src/whepsrc/imp.rs | 13 ++++++------- net/webrtchttp/src/whipsink/imp.rs | 14 +++++++------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/net/webrtchttp/src/lib.rs b/net/webrtchttp/src/lib.rs index a795f175..812ffdc3 100644 --- a/net/webrtchttp/src/lib.rs +++ b/net/webrtchttp/src/lib.rs @@ -23,7 +23,7 @@ mod whipsink; #[repr(u32)] #[enum_type(name = "GstRsWebRTCICETransportPolicy")] #[non_exhaustive] -pub enum GstRsWebRTCICETransportPolicy { +pub enum IceTransportPolicy { #[enum_value(name = "All: get both STUN and TURN candidate pairs", nick = "all")] All = 0, #[enum_value(name = "Relay: get only TURN candidate pairs", nick = "relay")] @@ -33,7 +33,7 @@ pub enum GstRsWebRTCICETransportPolicy { fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { #[cfg(feature = "doc")] { - GstRsWebRTCICETransportPolicy::static_type() + IceTransportPolicy::static_type() .mark_as_plugin_api(gst::PluginAPIFlags::empty()); } whipsink::register(plugin)?; diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs index 1642756f..ec911fa7 100644 --- a/net/webrtchttp/src/whepsrc/imp.rs +++ b/net/webrtchttp/src/whepsrc/imp.rs @@ -10,7 +10,7 @@ use crate::utils::{ build_reqwest_client, parse_redirect_location, set_ice_servers, wait, WaitError, }; -use crate::GstRsWebRTCICETransportPolicy; +use crate::IceTransportPolicy; use bytes::Bytes; use futures::future; use gst::{glib, prelude::*, subclass::prelude::*, ErrorMessage}; @@ -30,8 +30,7 @@ static CAT: Lazy = Lazy::new(|| { ) }); -const DEFAULT_ICE_TRANSPORT_POLICY: GstRsWebRTCICETransportPolicy = - GstRsWebRTCICETransportPolicy::All; +const DEFAULT_ICE_TRANSPORT_POLICY: IceTransportPolicy = IceTransportPolicy::All; const MAX_REDIRECTS: u8 = 10; const DEFAULT_TIMEOUT: u32 = 15; @@ -44,7 +43,7 @@ struct Settings { whep_endpoint: Option, auth_token: Option, use_link_headers: bool, - ice_transport_policy: GstRsWebRTCICETransportPolicy, + ice_transport_policy: IceTransportPolicy, timeout: u32, } @@ -248,7 +247,7 @@ impl ObjectImpl for WhepSrc { .nick("Authorization Token") .blurb("Authentication token to use, will be sent in the HTTP Header as 'Bearer '") .build(), - glib::ParamSpecEnum::builder::("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY) + glib::ParamSpecEnum::builder::("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY) .nick("ICE transport policy") .blurb("The policy to apply for ICE transport") .build(), @@ -313,10 +312,10 @@ impl ObjectImpl for WhepSrc { "ice-transport-policy" => { let mut settings = self.settings.lock().unwrap(); settings.ice_transport_policy = value - .get::() + .get::() .expect("ice-transport-policy should be an enum value"); - if settings.ice_transport_policy == GstRsWebRTCICETransportPolicy::Relay { + if settings.ice_transport_policy == IceTransportPolicy::Relay { self.webrtcbin .set_property_from_str("ice-transport-policy", "relay"); } else { diff --git a/net/webrtchttp/src/whipsink/imp.rs b/net/webrtchttp/src/whipsink/imp.rs index 23e3aa87..35f28067 100644 --- a/net/webrtchttp/src/whipsink/imp.rs +++ b/net/webrtchttp/src/whipsink/imp.rs @@ -10,7 +10,7 @@ use crate::utils::{ build_reqwest_client, parse_redirect_location, set_ice_servers, wait, WaitError, }; -use crate::GstRsWebRTCICETransportPolicy; +use crate::IceTransportPolicy; use futures::future; use gst::glib; use gst::prelude::*; @@ -29,8 +29,8 @@ static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new("whipsink", gst::DebugColorFlags::empty(), Some("WHIP Sink")) }); -const DEFAULT_ICE_TRANSPORT_POLICY: GstRsWebRTCICETransportPolicy = - GstRsWebRTCICETransportPolicy::All; +const DEFAULT_ICE_TRANSPORT_POLICY: IceTransportPolicy = + IceTransportPolicy::All; const MAX_REDIRECTS: u8 = 10; const DEFAULT_TIMEOUT: u32 = 15; @@ -41,7 +41,7 @@ struct Settings { auth_token: Option, turn_server: Option, stun_server: Option, - ice_transport_policy: GstRsWebRTCICETransportPolicy, + ice_transport_policy: IceTransportPolicy, timeout: u32, } @@ -236,7 +236,7 @@ impl ObjectImpl for WhipSink { .blurb("The TURN server of the form turn(s)://username:password@host:port.") .build(), - glib::ParamSpecEnum::builder::("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY) + glib::ParamSpecEnum::builder::("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY) .nick("ICE transport policy") .blurb("The policy to apply for ICE transport") .build(), @@ -287,10 +287,10 @@ impl ObjectImpl for WhipSink { "ice-transport-policy" => { let mut settings = self.settings.lock().unwrap(); settings.ice_transport_policy = value - .get::() + .get::() .expect("ice-transport-policy should be an enum value"); - if settings.ice_transport_policy == GstRsWebRTCICETransportPolicy::Relay { + if settings.ice_transport_policy == IceTransportPolicy::Relay { self.webrtcbin .set_property_from_str("ice-transport-policy", "relay"); } else {