зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551316 - Add pc.restartIce() method. r=bwc,smaug
Differential Revision: https://phabricator.services.mozilla.com/D30976 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
77fcf48fbf
Коммит
3aef894f49
|
@ -446,6 +446,7 @@ class RTCPeerConnection {
|
|||
// canTrickle == null means unknown; when a remote description is received it
|
||||
// is set to true or false based on the presence of the "trickle" ice-option
|
||||
this._canTrickle = null;
|
||||
this._localUfragsToReplace = new Set();
|
||||
|
||||
// So we can record telemetry on state transitions
|
||||
this._iceConnectionState = "new";
|
||||
|
@ -936,12 +937,13 @@ class RTCPeerConnection {
|
|||
} else {
|
||||
options = optionsOrOnSucc;
|
||||
}
|
||||
|
||||
if (this._localUfragsToReplace.size > 0) {
|
||||
options.iceRestart = true;
|
||||
}
|
||||
// This entry-point handles both new and legacy call sig. Decipher which one
|
||||
if (onSuccess) {
|
||||
return this._legacy(onSuccess, onErr, () => this._createOffer(options));
|
||||
}
|
||||
|
||||
return this._async(() => this._createOffer(options));
|
||||
}
|
||||
|
||||
|
@ -1136,6 +1138,12 @@ class RTCPeerConnection {
|
|||
if (type == "answer") {
|
||||
this._currentRole = "answerer";
|
||||
this._pendingRole = null;
|
||||
if (this._localUfragsToReplace.size > 0) {
|
||||
const ufrags = new Set(this._getUfragsWithPwds(sdp));
|
||||
if (![...this._localUfragsToReplace].some(uf => ufrags.has(uf))) {
|
||||
this._localUfragsToReplace.clear();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._pendingRole = "offerer";
|
||||
}
|
||||
|
@ -1235,6 +1243,14 @@ class RTCPeerConnection {
|
|||
if (type == "answer") {
|
||||
this._currentRole = "offerer";
|
||||
this._pendingRole = null;
|
||||
if (this._localUfragsToReplace.size > 0) {
|
||||
const ufrags = new Set(
|
||||
this._getUfragsWithPwds(this._impl.currentLocalDescription)
|
||||
);
|
||||
if (![...this._localUfragsToReplace].some(uf => ufrags.has(uf))) {
|
||||
this._localUfragsToReplace.clear();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._pendingRole = "answerer";
|
||||
}
|
||||
|
@ -1334,6 +1350,32 @@ class RTCPeerConnection {
|
|||
});
|
||||
}
|
||||
|
||||
restartIce() {
|
||||
this._localUfragsToReplace = new Set([
|
||||
...this._getUfragsWithPwds(this._impl.currentLocalDescription),
|
||||
...this._getUfragsWithPwds(this._impl.pendingLocalDescription),
|
||||
]);
|
||||
this.updateNegotiationNeeded();
|
||||
}
|
||||
|
||||
_getUfragsWithPwds(sdp) {
|
||||
return (
|
||||
sdp
|
||||
.split("\r\nm=")
|
||||
.map(block => block.split("\r\n"))
|
||||
.map(lines => [
|
||||
lines.find(l => l.startsWith("a=ice-ufrag:")),
|
||||
lines.find(l => l.startsWith("a=ice-pwd:")),
|
||||
])
|
||||
// Even though our own SDP doesn't currently do this: JSEP says properties
|
||||
// found in the session (array[0]) apply to all m-lines that don't specify
|
||||
// them, like default values.
|
||||
.map(([a, b], i, array) => [a || array[0][0], b || array[0][1]])
|
||||
.filter(([a, b]) => a && b)
|
||||
.map(array => array.join())
|
||||
);
|
||||
}
|
||||
|
||||
addStream(stream) {
|
||||
stream.getTracks().forEach(track => this.addTrack(track, stream));
|
||||
}
|
||||
|
@ -1500,7 +1542,9 @@ class RTCPeerConnection {
|
|||
return;
|
||||
}
|
||||
|
||||
let negotiationNeeded = this._impl.checkNegotiationNeeded();
|
||||
let negotiationNeeded =
|
||||
this._impl.checkNegotiationNeeded() ||
|
||||
this._localUfragsToReplace.size > 0;
|
||||
if (!negotiationNeeded) {
|
||||
this._negotiationNeeded = false;
|
||||
return;
|
||||
|
|
|
@ -104,6 +104,7 @@ interface RTCPeerConnection : EventTarget {
|
|||
readonly attribute boolean? canTrickleIceCandidates;
|
||||
readonly attribute RTCIceGatheringState iceGatheringState;
|
||||
readonly attribute RTCIceConnectionState iceConnectionState;
|
||||
void restartIce ();
|
||||
[Pref="media.peerconnection.identity.enabled"]
|
||||
readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
|
||||
[Pref="media.peerconnection.identity.enabled"]
|
||||
|
|
Загрузка…
Ссылка в новой задаче