- Webrtc For Mozilla
- Webrtc Mozilla Test
- Firefox Disable Webrtc
- Webrtc Firefox Addon
- Cached
- Disable WebRTC – Get This Extension For 🦊 Firefox (en-US)
Webrtc For Mozilla
- The WebRTC project is open-source and supported by Apple, Google, Microsoft and Mozilla, amongst others. This page is maintained by the Google WebRTC team. What can WebRTC do? There are many different use-cases for WebRTC, from basic web apps that uses the camera or microphone, to more advanced video-calling applications and screen sharing.
- May 22, 2020 WebRTC stands for “Web Real-Time Communication”. This basically allows for voice, video chat, and P2P sharing within the browser (real-time communication) without adding extra browser extensions. What is a WebRTC leak? A WebRTC leak is when your external (public) IP address is exposed via your browser’s WebRTC functionality.
- Feb 04, 2021 WebRTC isn’t a complete videoconferencing system; it’s a set of tools built in to the browser that take care of many of the hard pieces of building a VC system so that you don’t have to.
- For native clients, like Android and iOS applications, a library is available that provides the same functionality. The WebRTC project is open-source and supported by Apple, Google, Microsoft and Mozilla, amongst others. This page is maintained by the Google WebRTC team.
The WebRTC components have been optimized to best serve this purpose. Our mission: To enable rich, high-quality RTC applications to be developed for the browser, mobile platforms, and IoT devices, and allow them all to communicate via a common set of protocols. The WebRTC initiative is a project supported by Google, Mozilla and Opera, amongst.
Exploring RTCRtpTransceiver.
Firefox now implements the RTCRtpTransceiver API, a.k.a. stage 3 in my blog post “The evolution of WebRTC 1.0.” from last year. Transceivers more accurately reflect the SDP-rooted network behaviors of an RTCPeerConnection. E.g. addTransceiver()
(or addTrack
) now creates a receiver at the same time, which correlates better with the bi-directional m-line that begins life in the SDP offer, rather than being something that arrives later once negotiation completes. This lets media arrive early on renegotiation.
But most WebRTC sites today are still written the old way, and there are subtle differences to trip over. Web developers are stuck in a bit of limbo, as other browsers haven’t caught up yet. In light of that, we should probably dive right into two immediate breaking spec changes you might have run into in Firefox 59:
- Remote tracks are now muted and temporarily removed from their stream(s), rather than ended, in response to direction changes (e.g. from the poorly named
removeTrack
). track.id
s at the two end-points rarely correlate anymore.
Importantly, this affects you whether you use transceivers or not. addTrack
(even addStream
) is just a tweaked version of addTransceiver
these days. This blog will look at how to handle this—tying up lose ends from last year’s blog post—and demonstrate how Firefox works.
The short answer to “Why no ended?”, is that incoming tracks now correspond to sender objects on the other side, which may resume in response to transceiver.direction
changes.
The short answer to “Why no matching track IDs?”, is that incoming (receiver) tracks now usually exist ahead of connecting, their immutable id
s unable to match up with the other side (and were never guaranteed to be unique anyway).
As you might notice, this boils down to changes to the lifetime of remote tracks. Gone is misleading symmetry between local and remote tracks, or the streams they belong to for that matter. That symmetry looked pretty, but got in the way of fully controlling tracks remotely.
Remote-controlled tracks.
A more useful analogy is that of transceiver.sender
as a remote-control of the transceiver.receiver.track
held by the other peer. Their lifetimes match that of the transceiver itself. Here’s how this remote-control works:
When we do this… | …the other side sees this |
---|---|
pc.addTransceiver(trackA, {streams}) * | (stream.onaddtrack only if stream already exists there) |
… | pc.ontrack with new transceiver and streams |
…then once media flows | transceiver.receiver.track.onunmute |
tranceiver.direction = 'recvonly' * | transceiver.receiver.track.onmute |
… | stream.onremovetrack |
tranceiver.direction = 'sendrecv' * | stream.onaddtrack |
… | pc.ontrack with existing transceiver and streams |
…then once media flows | transceiver.receiver.track.onunmute |
transceiver.sender.track.enabled = false | Media seamlessly goes black/silent |
transceiver.sender.track.enabled = true | Media seamlessly resumes |
transceiver.sender.replaceTrack(trackB) | Media seamlessly changes |
transceiver.sender.replaceTrack(null) | Media seamlessly halts |
Network (RTP SSRC) timeout | transceiver.receiver.track.onmute |
tranceiver.stop() * | transceiver.receiver.track.onended |
* = after renegotiation through pc.onnegotiationneeded
completes.
(Note that many of these transitions are state-based and only fire events if the state ends up changing.)
You can try out this remote-control below in Firefox (59):
In the “Result” tab, grant permission, then click the buttons in sequence from top to bottom, to see the video update.
Then try the sequence again from the top. The sequence is repeatable, because we use the newest transceiver
returned from addTransceiver
each go-around (they accumulate).
Note that we get stream.onaddtrack
from addTransceiver
only the second time around, since we had no opportunity to add listeners to the remote stream the first time.
Interestingly, the video element, here representing the remote side, will play along with this, showing the latest video, provided we always either:
stop()
the previoustransceiver
, or- set its
direction
to'recvonly'
.
Stopping works because video elements ignore ended tracks. Changing direction works because the temporarily-muted tracks get removed from the stream the video element is playing. Try clicking the buttons in different order to prove this out.
Now this may look like a lot of ways to accomplish the same thing. The differences may not be appreciable in a small demo, but each control has trade-offs:
stop()
terminates both directions (in this example we were only sending one way). Also,stopped
transceivers stick around inpc.getTransceivers()
, at least locally, and litter the remote stream with ended tracks (however, the Offer/Answer m-line may get repurposed in subsequent negotiations apparently).direction
-changes reuse the same transceiver and track without waste, but still require re-negotiation.replaceTrack(null)
is instant, requiring no negotiation at all, but stops sending without informing the other party. This may be indistinguishable from a network issue if the other side is looking at stats.track.enabled = false
never completely halts network traffic, instead sending one black frame per second, or silence for audio. This is the only control that lets browsers know the camera/microphone is no longer in use.
For the above reasons, the spec encourages implementing “hold” functionality using both direction
and replaceTrack(null)
in combination.
Don’t forget the camera!
In addition to the spec’s recommended “hold” solution, consider setting track.enabled = false
at the same time. If you do, Firefox 60 will turn off the user’s camera and hardware indicator light, for less paranoid face-muting. This is a spec-supported feature Chrome does not have yet, and is the subject of my next blog.
Correlate tracks by transceiver.mid or order
Last year’s blog explained how using track ids out-of-band to correlate remote tracks would no longer work. It recommended using transceiver.mid
instead for this, but, sans implementation, left out a working example.
Here’s an example that correlates tracks regardless of arrival order to always put the camera track on the left:
In the “Result” tab, check the boxes in any order; the camera always appears on the left, the other one on the right.
The trick here in ontrack
is using camTransceiver.mid
to pick between the left or right video element. This is the mid
from the other side. In the real world, we’d send this ID over a) transceivers—in transceiver order—before creating new ones. This is a bit magic.
On the other hand, calling addTransceiver()
3 times is straightforward, but would give us 6 m-lines total.
To make due with only 3 m-lines, the answerer must effectively modify the 3 transceivers created by setRemoteDescription
from the offer, instead of adding 3 of its own. Think of it as the offerer setting up the transceivers, and the answerer plugging into them.
Make sure you’ve stopped the previous example before running this one.
In the “Result” tab, you’ll see 6 remote tracks, 3 each way, over 3 m-lines total. Mute audio in both video elements.
We use addTransceiver()
on one end, and addTrack()
on the other to re-use m-lines, relying on their order.
How to answer ONLY with transceivers.
addTrack()
looks for unused transceivers to usurp, based on order and kind. This reliance on order may not always be practical. E.g. when using out-of-band mid
, it’s more natural to want to modify the transceiver directly. Here the specification comes up a bit short unfortunately.
Webrtc Mozilla Test
Let’s see how we’d answer the 3 transceivers without relying on their order, and then discuss what works and what doesn’t (again, make sure you’ve stopped the previous example first):
Rather than resort to addTrack()
, we explicitly modify each transceiver on the answering end:
- We change its
transceiver.direction
from'recvonly'
to'sendrecv'
, and - we add our track using
tranceiver.sender.replaceTrack()
.
Firefox Disable Webrtc
Unfortunately, this API offers no way to associate streams with these tracks, so our tracks end up being stream-less. Our ontrack
code becomes more complicated as a result, since the camera and microphone tracks no longer come grouped into a stream. But at least it works.
Extending the API to provide a way to add stream associations in this situation, seems reasonable. I’ve filed an issue on the spec about this. Update: This has been fixed with the sender.setStreams() API.
In closing
We’ve found people generally don’t care how media is organized over the wire, until they do. The tipping point is usually some combination of needing to do something more complicated, trying to correlate media to some underlying network metric, or explain some anomaly not gleaned from simpler API abstractions. Hopefully this API gives some insight into how WebRTC actually works, giving you options should you need it.
The MediaDevices
interface provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data.
Properties
Inherits properties from its parent interface, EventTarget
.
Events
devicechange
- Fired when a media input or output device is attached to or removed from the user's computer.
Also available via theondevicechange
property.
Methods
Inherits methods from its parent interface, EventTarget
.
enumerateDevices()
- Obtains an array of information about the media input and output devices available on the system.
getSupportedConstraints()
- Returns an object conforming to
MediaTrackSupportedConstraints
indicating which constrainable properties are supported on theMediaStreamTrack
interface. See Capabilities and constraints in Media Capture and Streams API (Media Stream) to learn more about constraints and how to use them. getDisplayMedia()
- Prompts the user to select a display or portion of a display (such as a window) to capture as a
MediaStream
for sharing or recording purposes. Returns a promise that resolves to aMediaStream
. getUserMedia()
- With the user's permission through a prompt, turns on a camera and/or a microphone on the system and provides a
MediaStream
containing a video track and/or an audio track with the input.
Example
Specifications
Webrtc Firefox Addon
Specification | Status | Comment |
---|---|---|
Media Capture and Streams The definition of 'MediaDevices' in that specification. | Candidate Recommendation | Initial definition |
Cached
Browser compatibility
BCD tables only load in the browser
See also
Disable WebRTC – Get This Extension For 🦊 Firefox (en-US)
- Media Capture and Streams API: The API this interface is part of.
- Screen Capture API: The API defining the
getDisplayMedia()
method. Navigator.mediaDevices
: Returns a reference to aMediaDevices
object that can be used to access devices.- CameraCaptureJS: HTML5 video capture and playback using
MediaDevices
and the MediaStream Recording API (source on GitHub) - OpenLang: HTML5 video language lab web application using
MediaDevices
and the MediaStream Recording API for video recording (source on GitHub)