Skip to content

Commit

Permalink
Revert "update(deps): webrtc version (#193)"
Browse files Browse the repository at this point in the history
This reverts commit 08dfd26.
  • Loading branch information
a-wing committed Jul 9, 2024
1 parent 38169c2 commit 7483637
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 28 deletions.
47 changes: 23 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ license = "MPL-2.0"
repository = "https://github.com/binbat/live777"

[workspace.dependencies]
webrtc = { git = "https://github.com/webrtc-rs/webrtc", rev = "40642c8" }
webrtc = { git = "https://github.com/webrtc-rs/webrtc", rev = "ae93e81" }

anyhow = "1.0"
clap = "4.5"
Expand Down
1 change: 1 addition & 0 deletions conf/live777.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ urls = [
# urls = [ "turn:turn.22333.fun", "turn:cn.22333.fun" ]
# username = "live777"
# credential = "live777"
# credential_type = "password"

# WHIP/WHEP auth token
# Headers["Authorization"] = "Bearer {token}"
Expand Down
13 changes: 12 additions & 1 deletion libs/libwish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ impl Client {
urls: vec![link.raw_uri.to_string().replacen("://", ":", 1)],
username: link.params.remove("username").unwrap_or("".to_owned()),
credential: link.params.remove("credential").unwrap_or("".to_owned()),
credential_type: link
.params
.remove("credential-type")
.unwrap_or("".to_owned())
.as_str()
.into(),
})
}
}
Expand Down Expand Up @@ -168,6 +174,7 @@ mod tests {
use http::header;
use http::response::Builder;
use reqwest::Response;
use webrtc::ice_transport::ice_credential_type::RTCIceCredentialType;

use crate::Client;

Expand All @@ -176,7 +183,7 @@ mod tests {
let response = Builder::new()
.header(header::LINK, r#"<stun:stun.22333.fun>; rel="ice-server""#)
.header(header::LINK, r#"<stun:stun.l.google.com:19302>; rel="ice-server""#)
.header(header::LINK, r#"<turn:turn.22333.fun>; rel="ice-server"; username="live777"; credential="live777""#)
.header(header::LINK, r#"<turn:turn.22333.fun>; rel="ice-server"; username="live777"; credential="live777"; credential-type="password""#)
.body("")
.unwrap();
let response = Response::from(response);
Expand All @@ -198,6 +205,10 @@ mod tests {
);
assert_eq!(ice_servers.get(2).unwrap().username, "live777");
assert_eq!(ice_servers.get(2).unwrap().credential, "live777");
assert_eq!(
ice_servers.get(2).unwrap().credential_type,
RTCIceCredentialType::Password
);

println!("{:?}", ice_servers);
}
Expand Down
24 changes: 23 additions & 1 deletion liveion/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use serde::{Deserialize, Serialize};
use std::{env, fs, net::SocketAddr, str::FromStr};
use webrtc::{ice, ice_transport::ice_server::RTCIceServer, Error};
use webrtc::{
ice,
ice_transport::{ice_credential_type::RTCIceCredentialType, ice_server::RTCIceServer},
Error,
};

#[derive(Debug, Default, Clone, Deserialize, Serialize)]
pub struct Config {
Expand Down Expand Up @@ -196,7 +200,24 @@ impl IceServer {
return Err(Error::ErrNoTurnCredentials);
}
url.username.clone_from(&self.username);

match self.credential_type.as_str().into() {
RTCIceCredentialType::Password => {
// https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.3)
url.password.clone_from(&self.credential);
}
RTCIceCredentialType::Oauth => {
// https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.4)
/*if _, ok: = s.Credential.(OAuthCredential); !ok {
return nil,
&rtcerr.InvalidAccessError{Err: ErrTurnCredentials
}
}*/
}
_ => return Err(Error::ErrTurnCredentials),
};
}

urls.push(url);
}

Expand All @@ -210,6 +231,7 @@ impl From<IceServer> for RTCIceServer {
urls: val.urls,
username: val.username,
credential: val.credential,
credential_type: val.credential_type.as_str().into(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tools/whepfrom/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tokio::{
sync::mpsc::{unbounded_channel, UnboundedSender},
};
use tracing::{debug, info, trace, warn, Level};
use webrtc::ice_transport::ice_credential_type::RTCIceCredentialType;
use webrtc::{
api::{interceptor_registry::register_default_interceptors, media_engine::*, APIBuilder},
ice_transport::ice_server::RTCIceServer,
Expand Down Expand Up @@ -189,6 +190,7 @@ async fn new_peer(
urls: vec!["stun:stun.l.google.com:19302".to_string()],
username: "".to_string(),
credential: "".to_string(),
credential_type: RTCIceCredentialType::Unspecified,
}
}],
..Default::default()
Expand Down
3 changes: 2 additions & 1 deletion tools/whipinto/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tokio::{
use tracing::{debug, info, trace, warn, Level};
use webrtc::{
api::{interceptor_registry::register_default_interceptors, media_engine::*, APIBuilder},
ice_transport::ice_server::RTCIceServer,
ice_transport::{ice_credential_type::RTCIceCredentialType, ice_server::RTCIceServer},
interceptor::registry::Registry,
peer_connection::{
configuration::RTCConfiguration, peer_connection_state::RTCPeerConnectionState,
Expand Down Expand Up @@ -180,6 +180,7 @@ async fn new_peer(
urls: vec!["stun:stun.l.google.com:19302".to_string()],
username: "".to_string(),
credential: "".to_string(),
credential_type: RTCIceCredentialType::Unspecified,
}
}],
..Default::default()
Expand Down
7 changes: 7 additions & 0 deletions tools/whipinto/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod tests {
};

use std::sync::Arc;
use webrtc::ice_transport::ice_credential_type::RTCIceCredentialType;
use webrtc::peer_connection::policy::bundle_policy::RTCBundlePolicy;
use webrtc::peer_connection::policy::ice_transport_policy::RTCIceTransportPolicy;
use webrtc::peer_connection::policy::rtcp_mux_policy::RTCRtcpMuxPolicy;
Expand All @@ -34,6 +35,7 @@ mod tests {
urls: vec!["stun:stun.l.google.com:19302".to_string()],
username: "".to_string(),
credential: "".to_string(),
credential_type: RTCIceCredentialType::Unspecified,
}],
..Default::default()
};
Expand All @@ -53,6 +55,7 @@ mod tests {
],
username: "live777".to_string(),
credential: "live777".to_string(),
credential_type: RTCIceCredentialType::Password,
}],
..Default::default()
};
Expand All @@ -74,6 +77,10 @@ mod tests {
);
assert_eq!(updated_config.ice_servers[0].username, "live777");
assert_eq!(updated_config.ice_servers[0].credential, "live777");
assert_eq!(
updated_config.ice_servers[0].credential_type,
RTCIceCredentialType::Password
);
assert_eq!(
updated_config.ice_transport_policy,
RTCIceTransportPolicy::Unspecified
Expand Down

0 comments on commit 7483637

Please sign in to comment.