Skip to content

Commit 494b052

Browse files
k0nservrainliu
authored andcommitted
Integrate UDP mux support for ICE
1 parent ce3a4ad commit 494b052

File tree

4 files changed

+6
-50
lines changed

4 files changed

+6
-50
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sdp = "0.4.0"
1717
mdns = { package = "webrtc-mdns", version = "0.4.0" }
1818
stun = "0.4.0"
1919
turn = "0.5.1"
20-
ice = { package = "webrtc-ice", version = "0.5.1" }
20+
ice = { package = "webrtc-ice", version = "0.6.1" }
2121
dtls = { package = "webrtc-dtls", version = "0.5.0" }
2222
rtp = "0.6.1"
2323
rtcp = "0.6.1"

src/api/setting_engine/mod.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use dtls::extension::extension_use_srtp::SrtpProtectionProfile;
77
use ice::agent::agent_config::InterfaceFilterFn;
88
use ice::mdns::MulticastDnsMode;
99
use ice::network_type::NetworkType;
10+
use ice::udp_network::UDPNetwork;
1011

1112
use crate::error::{Error, Result};
1213

@@ -15,12 +16,6 @@ use std::sync::Arc;
1516
use tokio::time::Duration;
1617
use util::vnet::net::*;
1718

18-
#[derive(Default, Clone)]
19-
pub struct EphemeralUDP {
20-
pub port_min: u16,
21-
pub port_max: u16,
22-
}
23-
2419
#[derive(Default, Clone)]
2520
pub struct Detach {
2621
pub data_channels: bool,
@@ -62,7 +57,6 @@ pub struct ReplayProtection {
6257
/// use-cases without deviating from the WebRTC API elsewhere.
6358
#[derive(Default, Clone)]
6459
pub struct SettingEngine {
65-
pub(crate) ephemeral_udp: EphemeralUDP,
6660
pub(crate) detach: Detach,
6761
pub(crate) timeout: Timeout,
6862
pub(crate) candidates: Candidates,
@@ -77,6 +71,7 @@ pub struct SettingEngine {
7771
//iceTCPMux :ice.TCPMux,?
7872
//iceUDPMux :ice.UDPMux,?
7973
//iceProxyDialer :proxy.Dialer,?
74+
pub(crate) udp_network: UDPNetwork,
8075
pub(crate) disable_media_engine_copy: bool,
8176
pub(crate) srtp_protection_profiles: Vec<SrtpProtectionProfile>,
8277
pub(crate) receive_mtu: usize,
@@ -139,17 +134,8 @@ impl SettingEngine {
139134
self.timeout.ice_relay_acceptance_min_wait = t;
140135
}
141136

142-
/// set_ephemeral_udp_port_range limits the pool of ephemeral ports that
143-
/// ICE UDP connections can allocate from. This affects both host candidates,
144-
/// and the local address of server reflexive candidates.
145-
pub fn set_ephemeral_udp_port_range(&mut self, port_min: u16, port_max: u16) -> Result<()> {
146-
if port_max < port_min {
147-
return Err(ice::Error::ErrPort.into());
148-
}
149-
150-
self.ephemeral_udp.port_min = port_min;
151-
self.ephemeral_udp.port_max = port_max;
152-
Ok(())
137+
pub fn set_udp_network(&mut self, udp_network: UDPNetwork) {
138+
self.udp_network = udp_network;
153139
}
154140

155141
/// set_lite configures whether or not the ice agent should be a lite agent

src/api/setting_engine/setting_engine_test.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@ use crate::peer_connection::peer_connection_test::*;
55
use crate::rtp_transceiver::rtp_codec::RTPCodecType;
66
use std::sync::atomic::Ordering;
77

8-
#[test]
9-
fn test_set_ephemeral_udpport_range() -> Result<()> {
10-
let mut s = SettingEngine::default();
11-
12-
assert!(
13-
!(s.ephemeral_udp.port_min != 0 || s.ephemeral_udp.port_max != 0),
14-
"SettingEngine defaults aren't as expected."
15-
);
16-
17-
// set bad ephemeral ports
18-
assert!(
19-
s.set_ephemeral_udp_port_range(3000, 2999).is_err(),
20-
"Setting engine should fail bad ephemeral ports."
21-
);
22-
23-
assert!(
24-
s.set_ephemeral_udp_port_range(3000, 4000).is_ok(),
25-
"Setting engine failed valid port range"
26-
);
27-
28-
assert!(
29-
!(s.ephemeral_udp.port_min != 3000 || s.ephemeral_udp.port_max != 4000),
30-
"Setting engine ports do not reflect expected range"
31-
);
32-
33-
Ok(())
34-
}
35-
368
#[test]
379
fn test_set_connection_timeout() -> Result<()> {
3810
let mut s = SettingEngine::default();

src/ice_transport/ice_gatherer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ impl RTCIceGatherer {
104104
}
105105

106106
let mut config = ice::agent::agent_config::AgentConfig {
107+
udp_network: self.setting_engine.udp_network.clone(),
107108
lite: self.setting_engine.candidates.ice_lite,
108109
urls: self.validated_servers.clone(),
109-
port_min: self.setting_engine.ephemeral_udp.port_min,
110-
port_max: self.setting_engine.ephemeral_udp.port_max,
111110
disconnected_timeout: self.setting_engine.timeout.ice_disconnected_timeout,
112111
failed_timeout: self.setting_engine.timeout.ice_failed_timeout,
113112
keepalive_interval: self.setting_engine.timeout.ice_keepalive_interval,
@@ -129,7 +128,6 @@ impl RTCIceGatherer {
129128
local_ufrag: self.setting_engine.candidates.username_fragment.clone(),
130129
local_pwd: self.setting_engine.candidates.password.clone(),
131130
//TODO: TCPMux: self.setting_engine.iceTCPMux,
132-
//TODO: UDPMux: self.setting_engine.iceUDPMux,
133131
//TODO: ProxyDialer: self.setting_engine.iceProxyDialer,
134132
..Default::default()
135133
};

0 commit comments

Comments
 (0)