I had to hack together this to make str0m work for local testing:
pub fn add_remote_ice_candidate(&mut self, candidate: String) -> Result<()> {
let candidate = candidate.trim().to_string();
if candidate.is_empty() {
// Browser emits empty candidate as end-of-candidates; nothing to add.
return Ok(());
}
println!("Incoming remote candidate {candidate}");
let normalized_candidate =
Self::resolve_mdns_candidate(&candidate).unwrap_or_else(|| candidate.clone());
match Candidate::from_sdp_string(&normalized_candidate) {
Ok(candidate) => {
self.rtc.add_remote_candidate(candidate);
}
Err(err) => {
eprintln!("ignoring unsupported remote ICE candidate: {candidate} ({err})");
}
}
Ok(())
}
// some of the ice candidates are mDNS, convert to IP to properly digest them
fn resolve_mdns_candidate(candidate: &str) -> Option<String> {
let mut parts: Vec<String> = candidate
.split_whitespace()
.map(std::string::ToString::to_string)
.collect();
if parts.len() < 6 {
return None;
}
let host = parts[4].clone();
let port = parts[5].clone();
if !host.ends_with(".local") {
return None;
}
let lookup = format!("{host}:{port}");
let resolved = lookup.to_socket_addrs().ok()?.next()?.ip();
parts[4] = resolved.to_string();
let converted_candidate = parts.join(" ");
println!("Converted mDNS to IP -> {converted_candidate}");
Some(converted_candidate)
}
This feels like something that should be handled internally by str0m, and I'm not sure if this is what I'm "supposed" to do
I had to hack together this to make str0m work for local testing:
This feels like something that should be handled internally by str0m, and I'm not sure if this is what I'm "supposed" to do