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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1008>
This commit is contained in:
Sanchayan Maity 2022-11-29 10:51:30 +05:30 committed by Sebastian Dröge
parent 1d4d9b3bdb
commit 4f67623c22
3 changed files with 15 additions and 16 deletions

View file

@ -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)?;

View file

@ -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<gst::DebugCategory> = 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<String>,
auth_token: Option<String>,
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 <auth-token>'")
.build(),
glib::ParamSpecEnum::builder::<GstRsWebRTCICETransportPolicy>("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY)
glib::ParamSpecEnum::builder::<IceTransportPolicy>("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::<GstRsWebRTCICETransportPolicy>()
.get::<IceTransportPolicy>()
.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 {

View file

@ -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<gst::DebugCategory> = 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<String>,
turn_server: Option<String>,
stun_server: Option<String>,
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::<GstRsWebRTCICETransportPolicy>("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY)
glib::ParamSpecEnum::builder::<IceTransportPolicy>("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::<GstRsWebRTCICETransportPolicy>()
.get::<IceTransportPolicy>()
.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 {