Bug 1548318 - find new local addrs each time we gather ICE candidates. r?bwc!
If we don't refresh the local addrs, an ICE restart due to a WiFi change
will fail.
Differential Revision:
https://phabricator.services.mozilla.com/D55883
--- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
@@ -688,20 +688,16 @@ int nr_ice_set_local_addresses(nr_ice_ct
{
int r,_status;
nr_local_addr local_addrs[MAXADDRS];
nr_local_addr *addrs = 0;
int i,addr_ct;
nr_local_addr default_addrs[2];
int default_addr_ct = 0;
- if (ctx->local_addrs) {
- r_log(LOG_ICE,LOG_WARNING,"ICE(%s): local addresses already set, no work to do",ctx->label);
- ABORT(R_ALREADY);
- }
if (!stun_addrs || !stun_addr_ct) {
r_log(LOG_ICE,LOG_ERR,"ICE(%s): no stun addrs provided",ctx->label);
ABORT(R_BAD_ARGS);
}
addr_ct = MIN(stun_addr_ct, MAXADDRS);
r_log(LOG_ICE, LOG_DEBUG, "ICE(%s): copy %d pre-fetched stun addrs", ctx->label, addr_ct);
for (i=0; i<addr_ct; ++i) {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -152,19 +152,16 @@ bool PeerConnectionMedia::ShouldForcePro
proxyInfo->GetType(proxyType);
return !proxyType.IsEmpty() && !proxyType.EqualsLiteral("direct");
}
nsresult PeerConnectionMedia::Init() {
mForceProxy = ShouldForceProxy();
- // setup the stun local addresses IPC async call
- InitLocalAddrs();
-
ConnectSignals();
return NS_OK;
}
void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
for (const auto& transceiver : aSession.GetTransceivers()) {
if (transceiver->HasOwnTransport()) {
mTransportHandler->EnsureProvisionalTransport(
@@ -497,16 +494,23 @@ void PeerConnectionMedia::PerformOrEnque
} else {
mQueuedIceCtxOperations.push_back(runnable);
}
}
void PeerConnectionMedia::GatherIfReady() {
ASSERT_ON_THREAD(mMainThread);
+ // Init local addrs here so that if we re-gather after an ICE restart
+ // resulting from changing WiFi networks, we get new local addrs.
+ // Otherwise, we would reuse the addrs from the original WiFi network
+ // and the ICE restart will fail.
+ mLocalAddrsCompleted = false;
+ InitLocalAddrs();
+
// If we had previously queued gathering or ICE start, unqueue them
mQueuedIceCtxOperations.clear();
nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
RefPtr<PeerConnectionMedia>(this),
&PeerConnectionMedia::EnsureIceGathering, GetPrefDefaultAddressOnly(),
GetPrefObfuscateHostAddresses()));
PerformOrEnqueueIceCtxOperation(runnable);