diff --git a/dom/media/PeerConnection.jsm b/dom/media/PeerConnection.jsm index a161e54b05e8..3d9f7d6e40b4 100644 --- a/dom/media/PeerConnection.jsm +++ b/dom/media/PeerConnection.jsm @@ -1989,6 +1989,32 @@ class PeerConnectionObserver { ); } + fireTrackEvent(receiver, streams) { + const pc = this._dompc; + const transceiver = pc.getTransceivers().find(t => t.receiver == receiver); + if (!transceiver) { + return; + } + const track = receiver.track; + this.dispatchEvent( + new this._win.RTCTrackEvent("track", { + transceiver, + receiver, + track, + streams, + }) + ); + // Fire legacy event as well for a little bit. + this.dispatchEvent( + new this._win.MediaStreamTrackEvent("addtrack", { track }) + ); + } + + fireStreamEvent(stream) { + const ev = new this._win.MediaStreamEvent("addstream", { stream }); + this.dispatchEvent(ev); + } + onDTMFToneChange(track, tone) { var pc = this._dompc; var sender = pc.getSenders().find(sender => sender.track == track); diff --git a/dom/webidl/PeerConnectionObserver.webidl b/dom/webidl/PeerConnectionObserver.webidl index b4769aa99205..df8d926d4ffb 100644 --- a/dom/webidl/PeerConnectionObserver.webidl +++ b/dom/webidl/PeerConnectionObserver.webidl @@ -42,6 +42,16 @@ interface PeerConnectionObserver transceiver to be created on the C++ side */ void onTransceiverNeeded(DOMString kind, TransceiverImpl transceiverImpl); + /* + Lets PeerConnectionImpl fire track events on the RTCPeerConnection + */ + void fireTrackEvent(RTCRtpReceiver receiver, sequence streams); + + /* + Lets PeerConnectionImpl fire addstream events on the RTCPeerConnection + */ + void fireStreamEvent(MediaStream stream); + /* DTMF callback */ void onDTMFToneChange(MediaStreamTrack track, DOMString tone);