Bug 1425621 - Part 5: Handle transceiver removal caused by rollback after track events. r?jib, r?drno, r=smaug
MozReview-Commit-ID: 5Z5ntG5Bvgc
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -1677,16 +1677,17 @@ class PeerConnectionObserver {
this._dompc._syncTransceivers();
this._dompc._onSetLocalDescriptionSuccess();
}
onSetRemoteDescriptionSuccess() {
this._dompc._syncTransceivers();
this._dompc._processTrackAdditionsAndRemovals();
this._dompc._fireLegacyAddStreamEvents();
+ this._dompc._transceivers = this._dompc._transceivers.filter(t => !t.shouldRemove);
this._dompc._onSetRemoteDescriptionSuccess();
}
onSetLocalDescriptionError(code, message) {
this._localType = null;
this._dompc._onSetLocalDescriptionFailure(this.newError(message, code));
}
@@ -2239,16 +2240,17 @@ class RTCRtpTransceiver {
mid: null,
sender,
receiver,
stopped: false,
_direction: direction,
currentDirection: null,
_remoteTrackId: null,
addTrackMagic: false,
+ shouldRemove: false,
_hasBeenUsedToSend: false,
// the receiver starts out without a track, so record this here
_kind: kind,
_transceiverImpl: transceiverImpl
});
}
set direction(direction) {
@@ -2288,23 +2290,16 @@ class RTCRtpTransceiver {
this._pc.updateNegotiationNeeded();
}
setStopped() {
this.stopped = true;
this.currentDirection = null;
}
- remove() {
- var index = this._pc._transceivers.indexOf(this.__DOM_IMPL__);
- if (index != -1) {
- this._pc._transceivers.splice(index, 1);
- }
- }
-
getKind() {
return this._kind;
}
hasBeenUsedToSend() {
return this._hasBeenUsedToSend;
}
--- a/dom/webidl/RTCRtpTransceiver.webidl
+++ b/dom/webidl/RTCRtpTransceiver.webidl
@@ -46,27 +46,27 @@ interface RTCRtpTransceiver {
[Pref="media.peerconnection.remoteTrackId.enabled"]
DOMString getRemoteTrackId();
[ChromeOnly]
void setAddTrackMagic();
[ChromeOnly]
readonly attribute boolean addTrackMagic;
[ChromeOnly]
+ attribute boolean shouldRemove;
+ [ChromeOnly]
void setCurrentDirection(RTCRtpTransceiverDirection direction);
[ChromeOnly]
void setDirectionInternal(RTCRtpTransceiverDirection direction);
[ChromeOnly]
void setMid(DOMString mid);
[ChromeOnly]
void unsetMid();
[ChromeOnly]
void setStopped();
- [ChromeOnly]
- void remove();
[ChromeOnly]
DOMString getKind();
[ChromeOnly]
boolean hasBeenUsedToSend();
[ChromeOnly]
void sync();
--- a/media/webrtc/signaling/src/peerconnection/TransceiverImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/TransceiverImpl.cpp
@@ -556,17 +556,17 @@ TransceiverImpl::SyncWithJS(dom::RTCRtpT
mJsepTransceiver->SetAddTrackMagic();
}
if (aRv.Failed()) {
return;
}
if (mJsepTransceiver->IsRemoved()) {
- aJsTransceiver.Remove(aRv);
+ aJsTransceiver.SetShouldRemove(true, aRv);
}
}
void
TransceiverImpl::InsertDTMFTone(int tone, uint32_t duration)
{
if (mJsepTransceiver->IsStopped()) {
return;