diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html index c7ca5f9a820..94d4d4afcdc 100644 --- a/dom/events/test/test_all_synthetic_events.html +++ b/dom/events/test/test_all_synthetic_events.html @@ -449,9 +449,6 @@ const kEventConstructors = { return new RTCPeerConnectionIceEvent(aName, aProps); }, }, - RTCTrackEvent: { - // Difficult to test required arguments. - }, ScrollAreaEvent: { create: function (aName, aProps) { var e = document.createEvent("scrollareaevent"); e.initScrollAreaEvent(aName, aProps.bubbles, aProps.cancelable, diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 656edc03568..f7358d6f3ac 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -405,9 +405,8 @@ RTCPeerConnection.prototype = { "InvalidStateError"); } - this.makeGetterSetterEH("ontrack"); - this.makeLegacyGetterSetterEH("onaddstream", "Use peerConnection.ontrack instead."); - this.makeLegacyGetterSetterEH("onaddtrack", "Use peerConnection.ontrack instead."); + this.makeGetterSetterEH("onaddstream"); + this.makeGetterSetterEH("onaddtrack"); this.makeGetterSetterEH("onicecandidate"); this.makeGetterSetterEH("onnegotiationneeded"); this.makeGetterSetterEH("onsignalingstatechange"); @@ -664,18 +663,6 @@ RTCPeerConnection.prototype = { }); }, - makeLegacyGetterSetterEH: function(name, msg) { - Object.defineProperty(this, name, - { - get:function() { return this.getEH(name); }, - set:function(h) { - this.logWarning(name + " is deprecated! " + msg, - null, 0); - return this.setEH(name, h); - } - }); - }, - _addIdentityAssertion: function(sdpPromise, origin) { if (!this._localIdp.enabled) { return sdpPromise; @@ -1366,16 +1353,15 @@ PeerConnectionObserver.prototype = { // STUN requests. handleIceConnectionStateChange: function(iceConnectionState) { - let pc = this._dompc; - if (pc.iceConnectionState === 'new') { + if (this._dompc.iceConnectionState === 'new') { var checking_histogram = Services.telemetry.getHistogramById("WEBRTC_ICE_CHECKING_RATE"); if (iceConnectionState === 'checking') { checking_histogram.add(true); } else if (iceConnectionState === 'failed') { checking_histogram.add(false); } - } else if (pc.iceConnectionState === 'checking') { - var success_histogram = Services.telemetry.getHistogramById(pc._isLoop ? + } else if (this._dompc.iceConnectionState === 'checking') { + var success_histogram = Services.telemetry.getHistogramById(this._dompc._isLoop ? "LOOP_ICE_SUCCESS_RATE" : "WEBRTC_ICE_SUCCESS_RATE"); if (iceConnectionState === 'completed' || iceConnectionState === 'connected') { @@ -1386,10 +1372,10 @@ PeerConnectionObserver.prototype = { } if (iceConnectionState === 'failed') { - pc.logError("ICE failed, see about:webrtc for more details", null, 0); + this._dompc.logError("ICE failed, see about:webrtc for more details", null, 0); } - pc.changeIceConnectionState(iceConnectionState); + this._dompc.changeIceConnectionState(iceConnectionState); }, // This method is responsible for updating iceGatheringState. This @@ -1444,11 +1430,11 @@ PeerConnectionObserver.prototype = { }, onGetStatsSuccess: function(dict) { - let pc = this._dompc; - let chromeobj = new RTCStatsReport(pc._win, dict); - let webidlobj = pc._win.RTCStatsReport._create(pc._win, chromeobj); + let chromeobj = new RTCStatsReport(this._dompc._win, dict); + let webidlobj = this._dompc._win.RTCStatsReport._create(this._dompc._win, + chromeobj); chromeobj.makeStatsPublic(); - pc._onGetStatsSuccess(webidlobj); + this._dompc._onGetStatsSuccess(webidlobj); }, onGetStatsError: function(code, message) { @@ -1461,34 +1447,20 @@ PeerConnectionObserver.prototype = { this.dispatchEvent(ev); }, - onRemoveStream: function(stream) { + onRemoveStream: function(stream, type) { this.dispatchEvent(new this._dompc._win.MediaStreamEvent("removestream", { stream: stream })); }, - onAddTrack: function(track, streams) { - let pc = this._dompc; - let receiver = pc._win.RTCRtpReceiver._create(pc._win, - new RTCRtpReceiver(this, - track)); - pc._receivers.push(receiver); - let ev = new pc._win.RTCTrackEvent("track", - { receiver: receiver, - track: track, - streams: streams }); - this.dispatchEvent(ev); - - // Fire legacy event as well for a little bit. - ev = new pc._win.MediaStreamTrackEvent("addtrack", { track: track }); + onAddTrack: function(track) { + let ev = new this._dompc._win.MediaStreamTrackEvent("addtrack", + { track: track }); this.dispatchEvent(ev); }, - onRemoveTrack: function(track) { - let pc = this._dompc; - let i = pc._receivers.findIndex(receiver => receiver.track == track); - if (i >= 0) { - pc._receivers.splice(i, 1); - } + onRemoveTrack: function(track, type) { + this.dispatchEvent(new this._dompc._win.MediaStreamTrackEvent("removetrack", + { track: track })); }, onReplaceTrackSuccess: function() { @@ -1562,7 +1534,7 @@ RTCRtpSender.prototype = { }; function RTCRtpReceiver(pc, track) { - this._pc = pc; + this.pc = pc; this.track = track; } RTCRtpReceiver.prototype = { diff --git a/dom/media/tests/mochitest/pc.js b/dom/media/tests/mochitest/pc.js index 25ffea449ce..f6bd93fd3e5 100644 --- a/dom/media/tests/mochitest/pc.js +++ b/dom/media/tests/mochitest/pc.js @@ -1393,9 +1393,6 @@ PeerConnectionWrapper.prototype = { var rtpStatsKey = Object.keys(stats) .find(key => !stats[key].isRemote && stats[key].type.endsWith("boundrtp")); ok(rtpStatsKey, "Should have RTP stats for track " + track.id); - if (!rtpStatsKey) { - return false; - } var rtp = stats[rtpStatsKey]; var nrPackets = rtp[rtp.type == "outboundrtp" ? "packetsSent" : "packetsReceived"]; @@ -1404,12 +1401,21 @@ PeerConnectionWrapper.prototype = { return nrPackets > 0; }; - info("Checking RTP packet flow for track " + track.id); + return new Promise(resolve => { + info("Checking RTP packet flow for track " + track.id); - var retry = () => this._pc.getStats(track) - .then(stats => hasFlow(stats)? ok(true, "RTP flowing for track " + track.id) : - wait(200).then(retry)); - return retry(); + var waitForFlow = () => { + this._pc.getStats(track).then(stats => { + if (hasFlow(stats)) { + ok(true, "RTP flowing for track " + track.id); + resolve(); + } else { + wait(200).then(waitForFlow); + } + }); + }; + waitForFlow(); + }); }, /** diff --git a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html index 3e3e3365d99..41b302e42c1 100644 --- a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html +++ b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html @@ -15,33 +15,19 @@ var pc1 = new RTCPeerConnection(); var pc2 = new RTCPeerConnection(); - var add = (pc, can, failed) => can && pc.addIceCandidate(can).catch(failed); - pc1.onicecandidate = e => add(pc2, e.candidate, generateErrorCallback()); - pc2.onicecandidate = e => add(pc1, e.candidate, generateErrorCallback()); + var pc2_haveRemoteOffer = new Promise(resolve => pc2.onsignalingstatechange = + e => (e.target.signalingState == "have-remote-offer") && resolve()); + var pc1_stable = new Promise(resolve => pc1.onsignalingstatechange = + e => (e.target.signalingState == "stable") && resolve()); - function mustThrowWith(msg, reason, f) { - try { - f(); - ok(false, msg + " must throw"); - } catch (e) { - is(e.name, reason, msg + " must throw: " + e.message); - } - }; + pc1.onicecandidate = e => pc2_haveRemoteOffer.then(() => !e.candidate || + pc2.addIceCandidate(e.candidate)).catch(generateErrorCallback()); + pc2.onicecandidate = e => pc1_stable.then(() => !e.candidate || + pc1.addIceCandidate(e.candidate)).catch(generateErrorCallback()); var v1, v2; - var delivered = new Promise(resolve => pc2.ontrack = e => { - // Test RTCTrackEvent here. - ok(e.streams.length > 0, "has streams"); - ok(e.streams[0].getTracks().some(track => track == e.track), "has track"); - ok(pc2.getReceivers().some(receiver => receiver == e.receiver), "has receiver"); - if (e.streams[0].getTracks().length == 2) { - // Test RTCTrackEvent required args here. - mustThrowWith("RTCTrackEvent wo/required args", - "TypeError", () => new RTCTrackEvent("track", {})); - v2.srcObject = e.streams[0]; - resolve(); - } - }); + var delivered = new Promise(resolve => + pc2.onaddstream = e => resolve(v2.srcObject = e.stream)); runNetworkTest(function() { v1 = createMediaElement('video', 'v1'); @@ -51,7 +37,7 @@ is(v2.currentTime, 0, "v2.currentTime is zero at outset"); navigator.mediaDevices.getUserMedia({ video: true, audio: true }) - .then(stream => (v1.srcObject = stream).getTracks().forEach(t => pc1.addTrack(t, stream))) + .then(stream => pc1.addStream(v1.srcObject = stream)) .then(() => pc1.createOffer({})) // check that createOffer accepts arg. .then(offer => pc1.setLocalDescription(offer)) .then(() => pc2.setRemoteDescription(pc1.localDescription)) diff --git a/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html b/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html index fbf1ecebeae..6444f71862e 100644 --- a/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html +++ b/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html @@ -19,13 +19,6 @@ .some(sn => sn.track == t))) // that's being sent over |pc|. } - function allRemoteStreamsHaveReceiver(pc) { - return pc.getRemoteStreams() - .every(s => s.getTracks() // Every remote stream, - .some(t => pc.getReceivers() // should have some track, - .some(sn => sn.track == t))) // that's being received over |pc|. - } - function replacetest(wrapper) { var pc = wrapper._pc; var oldSenderCount = pc.getSenders().length; @@ -33,9 +26,7 @@ var oldTrack = sender.track; ok(sender, "We have a sender for video"); ok(allLocalStreamsHaveSender(pc), - "Shouldn't have any local streams without a corresponding sender"); - ok(allRemoteStreamsHaveReceiver(pc), - "Shouldn't have any remote streams without a corresponding receiver"); + "Shouldn't have any streams without a corresponding sender"); var newTrack; var audiotrack; diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index acc41fe8c2d..65f48e645ae 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -997,8 +997,6 @@ var interfaceNamesInGlobalScope = "RTCSessionDescription", // IMPORTANT: Do not change this list without review from a DOM peer! "RTCStatsReport", -// IMPORTANT: Do not change this list without review from a DOM peer! - "RTCTrackEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "Screen", // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/PeerConnectionObserver.webidl b/dom/webidl/PeerConnectionObserver.webidl index ab82870a35c..0b0d61ce890 100644 --- a/dom/webidl/PeerConnectionObserver.webidl +++ b/dom/webidl/PeerConnectionObserver.webidl @@ -42,6 +42,6 @@ interface PeerConnectionObserver /* Changes to MediaStreamTracks */ void onAddStream(MediaStream stream); void onRemoveStream(MediaStream stream); - void onAddTrack(MediaStreamTrack track, sequence streams); + void onAddTrack(MediaStreamTrack track); void onRemoveTrack(MediaStreamTrack track); }; diff --git a/dom/webidl/RTCPeerConnection.webidl b/dom/webidl/RTCPeerConnection.webidl index 9dc946a396c..923b38a215d 100644 --- a/dom/webidl/RTCPeerConnection.webidl +++ b/dom/webidl/RTCPeerConnection.webidl @@ -141,9 +141,8 @@ interface RTCPeerConnection : EventTarget { attribute EventHandler onnegotiationneeded; attribute EventHandler onicecandidate; attribute EventHandler onsignalingstatechange; - attribute EventHandler onaddstream; // obsolete - attribute EventHandler onaddtrack; // obsolete - attribute EventHandler ontrack; // replaces onaddtrack and onaddstream. + attribute EventHandler onaddstream; + attribute EventHandler onaddtrack; // replaces onaddstream; see AddTrackEvent attribute EventHandler onremovestream; attribute EventHandler oniceconnectionstatechange; diff --git a/dom/webidl/RTCTrackEvent.webidl b/dom/webidl/RTCTrackEvent.webidl deleted file mode 100644 index a87915bbed7..00000000000 --- a/dom/webidl/RTCTrackEvent.webidl +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://w3c.github.io/webrtc-pc/#idl-def-RTCTrackEvent - */ - -dictionary RTCTrackEventInit : EventInit { - required RTCRtpReceiver receiver; - required MediaStreamTrack track; - sequence streams = []; -}; - -[Pref="media.peerconnection.enabled", - Constructor(DOMString type, RTCTrackEventInit eventInitDict)] -interface RTCTrackEvent : Event { - readonly attribute RTCRtpReceiver receiver; - readonly attribute MediaStreamTrack track; - -// TODO: Use FrozenArray once available. (Bug 1236777) -// readonly attribute FrozenArray streams; - - [Frozen, Cached, Pure] - readonly attribute sequence streams; // workaround -}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 9b39fa8a014..be1b282922e 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -836,7 +836,6 @@ if CONFIG['MOZ_WEBRTC']: 'MediaStreamTrackEvent.webidl', 'RTCDataChannelEvent.webidl', 'RTCPeerConnectionIceEvent.webidl', - 'RTCTrackEvent.webidl', ] if CONFIG['MOZ_WEBSPEECH']: diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index ad4d448c1c5..03eba7e6304 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -187,7 +187,6 @@ public: virtual void NotifyTracksAvailable(DOMMediaStream* aStream) override { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aStream); PeerConnectionWrapper wrapper(mPcHandle); @@ -201,13 +200,6 @@ public: std::string streamId = PeerConnectionImpl::GetStreamId(*aStream); bool notifyStream = true; - Sequence> streams; - if (!streams.AppendElement(OwningNonNull(*aStream), - fallible)) { - MOZ_ASSERT(false); - return; - } - for (size_t i = 0; i < tracks.Length(); i++) { std::string trackId; // This is the first chance we get to set the string track id on this @@ -239,7 +231,7 @@ public: JSErrorResult jrv; CSFLogInfo(logTag, "Calling OnAddTrack(%s)", trackId.c_str()); - mObserver->OnAddTrack(*tracks[i], streams, jrv); + mObserver->OnAddTrack(*tracks[i], jrv); if (jrv.Failed()) { CSFLogError(logTag, ": OnAddTrack(%u) failed! Error: %u", static_cast(i), @@ -1868,31 +1860,19 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) mJsepSession->GetRemoteTracksRemoved(); for (auto i = removedTracks.begin(); i != removedTracks.end(); ++i) { - const std::string& streamId = (*i)->GetStreamId(); - const std::string& trackId = (*i)->GetTrackId(); - - RefPtr info = mMedia->GetRemoteStreamById(streamId); + RefPtr info = + mMedia->GetRemoteStreamById((*i)->GetStreamId()); if (!info) { MOZ_ASSERT(false, "A stream/track was removed that wasn't in PCMedia. " "This is a bug."); continue; } - mMedia->RemoveRemoteTrack(streamId, trackId); - - DOMMediaStream* stream = info->GetMediaStream(); - nsTArray> tracks; - stream->GetTracks(tracks); - for (auto& track : tracks) { - if (PeerConnectionImpl::GetTrackId(*track) == trackId) { - pco->OnRemoveTrack(*track, jrv); - break; - } - } + mMedia->RemoveRemoteTrack((*i)->GetStreamId(), (*i)->GetTrackId()); // We might be holding the last ref, but that's ok. if (!info->GetTrackCount()) { - pco->OnRemoveStream(*stream, jrv); + pco->OnRemoveStream(*info->GetMediaStream(), jrv); } } diff --git a/testing/web-platform/meta/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html.ini b/testing/web-platform/meta/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html.ini index 2feef2ad53b..12cec4fa9c5 100644 --- a/testing/web-platform/meta/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html.ini +++ b/testing/web-platform/meta/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html.ini @@ -36,6 +36,9 @@ [RTCPeerConnection interface: operation addTrack(MediaStreamTrack,MediaStream)] expected: FAIL + [RTCPeerConnection interface: attribute ontrack] + expected: FAIL + [RTCPeerConnection interface: operation getStats(MediaStreamTrack,RTCStatsCallback,RTCPeerConnectionErrorCallback)] expected: FAIL @@ -183,6 +186,9 @@ [RTCPeerConnection interface: operation addTrack(MediaStreamTrack,MediaStream)] expected: FAIL + [RTCPeerConnection interface: attribute ontrack] + expected: FAIL + [RTCPeerConnection interface: operation createDTMFSender(MediaStreamTrack)] expected: FAIL