While the WebRTC specification is relatively stable, not all browsers have fully implemented all of its features. In addition, some browsers still have prefixes on some or all WebRTC APIs. While you can manually code around these issues, there is an easier way. The WebRTC organization provides on GitHub the WebRTC adapter to work around compatibility issues in different browsers' WebRTC implementations. The adapter is a JavaScript shim which lets your code to be written to the specification so that it will "just work" in all browsers with WebRTC support. There's no need to conditionally use prefixed APIs or implement other workarounds.
Note: Since there is ongoing fluidity in functionality and naming of API terms in WebRTC and supporting browsers, use of this adapter is generally recommended.
The adapter is provided under a BSD-style license.
For each version of each browser that supports WebRTC, adapter.js implements the needed polyfills, establishes the non-prefixed names of APIs, and applies any other changes needed to make the browser run code written to the WebRTC specification.
For example, on Firefox versions older than 38, the adapter adds the RTCPeerConnection.urls
property; Firefox doesn't natively support this property until Firefox 38, while on Chrome, support for the Promise
based API is added if not yet available. These are just a couple of examples; there are of course other adjustments made for you by the shim.
The WebRTC adapter currently supports Firefox, Google Chrome, and Microsoft Edge.
In order to use adapter.js, you need to include adapter.js on any page that uses WebRTC APIs:
<script src="adapter.js"></script>
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/adapter.js