Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net/webrtc/src/utils.rs')
-rw-r--r--net/webrtc/src/utils.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/net/webrtc/src/utils.rs b/net/webrtc/src/utils.rs
index 6b28ee96e..808bc09a9 100644
--- a/net/webrtc/src/utils.rs
+++ b/net/webrtc/src/utils.rs
@@ -357,6 +357,43 @@ pub fn set_ice_servers(
Ok(())
}
+pub fn build_link_header(url_str: &str) -> Result<String, url::ParseError> {
+ let url = url::Url::parse(url_str)?;
+
+ let mut link_str: String = "<".to_owned() + url.scheme();
+ if let Some(host) = url.host_str() {
+ link_str = link_str + ":" + host;
+ }
+
+ if let Some(port) = url.port() {
+ link_str = link_str + ":" + port.to_string().as_str();
+ }
+
+ link_str += url.path();
+
+ if let Some(query) = url.query() {
+ link_str = link_str + "?" + query;
+ }
+
+ link_str += ">";
+
+ if let Some(password) = url.password() {
+ link_str = link_str
+ + "; "
+ + "rel=\"ice-server\""
+ + "; "
+ + "username=\""
+ + url.username()
+ + "\"; "
+ + "credential:\""
+ + password
+ + "\"; "
+ + "credential-type:\"password\";";
+ }
+
+ Ok(link_str)
+}
+
/// Wrapper around `gst::ElementFactory::make` with a better error
/// message
pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> {