Skip to content

Commit bd8cba7

Browse files
authoredAug 19, 2024··
RSDK-8469 - Fix offline dial (#128)
1 parent 751965a commit bd8cba7

File tree

5 files changed

+324
-247
lines changed

5 files changed

+324
-247
lines changed
 

‎Cargo.lock

Lines changed: 170 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tracing = {version = "0.1.34"}
5959
tracing-subscriber = {version = "0.3.11", features = ["env-filter"]}
6060
viam-mdns = "3.0.1"
6161
webpki-roots = "0.21.1"
62-
webrtc = "0.11.0"
62+
webrtc = { git = "https://github.com/webrtc-rs/webrtc.git", rev = "88dff7b1dd6880aaa3d3f60894f1be51169a2f9d" }
6363

6464
[dev-dependencies]
6565
async-stream = "0.3.3"

‎examples/Cargo.lock

Lines changed: 138 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/rpc/dial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
const STATUS_CODE_UNKNOWN: i32 = 2;
5757
const STATUS_CODE_RESOURCE_EXHAUSTED: i32 = 8;
5858

5959
pub const VIAM_MDNS_SERVICE_NAME: &'static str = "_rpc._tcp.local";
6060

6161
type SecretType = String;
6262

@@ -400,7 +400,7 @@
400400

401401
let ifaces: HashMap<&str, Vec<&IpAddr>> =
402402
ifaces.iter().fold(HashMap::new(), |mut map, (k, v)| {
403403
map.entry(k).or_insert(vec![]).push(v);
404404
map
405405
});
406406

@@ -827,7 +827,7 @@
827827
.map_err(anyhow::Error::from)
828828
.map(|_| ())
829829
{
830-
log::error!("Error sending done or error update: {e}");
830+
log::error!("Error sending done or error update: {e}")
831831
}
832832
}
833833

@@ -881,7 +881,7 @@
881881

882882
impl fmt::Display for CallerUpdateStats {
883883
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
884884
let average_duration = &self.total_duration.as_millis() / &self.count;
885885
writeln!(
886886
f,
887887
"Caller update statistics: num_updates: {}, average_duration: {}ms, max_duration: {}ms",

‎src/rpc/webrtc.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
data_channel_init::RTCDataChannelInit, data_channel_message::DataChannelMessage,
1616
RTCDataChannel,
1717
},
18+
dtls::extension::extension_use_srtp::SrtpProtectionProfile,
1819
ice::mdns::MulticastDnsMode,
1920
ice_transport::ice_server::RTCIceServer,
2021
interceptor::registry::Registry,
@@ -112,7 +113,6 @@
112113
urls: ice_server.urls,
113114
username: ice_server.username,
114115
credential: ice_server.credential,
115-
credential_type: webrtc::ice_transport::ice_credential_type::RTCIceCredentialType::Password,
116116
}
117117
}
118118

@@ -145,7 +145,20 @@
145145
interceptor_registry::register_default_interceptors(registry, &mut media_engine)?;
146146

147147
let mut setting_engine = SettingEngine::default();
148+
149+
// A recent commit to the upstream webrtc library added `Srtp_Aead_Aes_256_Gcm` to the
150+
// list of default `SrtpProtectionProfile`s. This caused assertion failures upstream in
151+
// the `GenericArray` crate, which prevented us from connecting properly. Removing this
152+
// default (which is consistent with how `rust-utils` has operated for the past several
153+
// years) prevents the upstream conflicts and lets us avoid navigating potential conflicts
154+
// in reworking the upstream defaults.
155+
let srtp_protection_profiles = vec![
156+
SrtpProtectionProfile::Srtp_Aead_Aes_128_Gcm,
157+
SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_80,
158+
];
159+
setting_engine.set_srtp_protection_profiles(srtp_protection_profiles);
148160
setting_engine.set_ice_multicast_dns_mode(MulticastDnsMode::QueryAndGather);
161+
setting_engine.set_include_loopback_candidate(true);
149162

150163
Ok(APIBuilder::new()
151164
.with_media_engine(media_engine)
@@ -305,14 +318,14 @@
305318
None => "0".to_string(),
306319
};
307320

308321
match proto.status {
309322
Some(ref status) => {
310323
let key = HeaderName::from_str("Grpc-Message").unwrap();
311324
let val = HeaderValue::from_str(&status.message).unwrap();
312325
trailers.insert(key, val);
313326
}
314327
None => (),
315328
}
316329

317330
let k = match HeaderName::from_str(status_name) {
318331
Ok(k) => k,

0 commit comments

Comments
 (0)
Please sign in to comment.