WebRTC-related APIs and shims used by twilio-video.js
npm install @twilio/webrtctwilio-webrtc.js
================
 
twilio-webrtc.js contains the various WebRTC shims used by twilio-video.js.
It is not intended for general consumption.
```
npm install --save @twilio/webrtc
The following WebRTC API shims are available:
`javascript`
const {
getStats,
getUserMedia,
MediaStream,
MediaStreamTrack,
RTCIceCandidate,
RTCPeerConnection,
RTCSessionDescription
} = require('@twilio/webrtc');
getStats resolves with normalized WebRTC statistics for the active ICEMediaStreamTrack
candidate pair and each , local or remote, of a particularRTCPeerConnection.
`javascript`
/**
* Get the statistics for a given RTCPeerConnection.
* @param {RTCPeerConnection} peerConnection
* @returns {Promise
*/
function getStats(peerConnection) {}
__NOTE__: StandardizedStatsResponse
normalizes the different formats of the stats returned by RTCPeerConnection#getStats in different
browsers. It does not conform to the W3C spec.
getUserMedia accepts a MediaStreamConstraints object and resolvesMediaStream
with a . By default, it requests both audio and video.
`javascript`
/**
* Request media from the user.
* @param {MediaStreamConstraints} [constraints={audio: true, video: true}]
* @returns {Promise
*/
function getUserMedia(constraints) {}
RTCPeerConnection abstracts away some of the browser-specific implementations
of WebRTC, and implements some WebRTC features that are not present in some
browsers.
#### Chrome
* Adds rollback support, according to the workaround specified here.
* Adds "track" event support, as per the workaround in webrtc-adapter.
* Provides a workaround for the case where, when the SSRC of a MediaStreamTrack changes, theMediaStreamTrack
browser treats this as a removal of the existing and the addition of a newMediaStreamTrack
.maxPacketLifeTime
* Adds support for getting and setting on RTCDataChannels bymaxRetransmitTime
remapping the legacy property to maxPacketLifeTime. SeeremoveTrack
this bug for
more information.
* Provides a workaround for this bug, where calling RTCRtpSender
with an that is not created by the RTCPeerConnection in question throws an exception.
#### Firefox
* For new offers, adds support for calling setLocalDescription and setRemoteDescription inhave-local-offer
and have-remote-offer signaling states respectively.createOffer
* Adds support for calling in signaling state have-local-offer.RTCPeerConnection.prototype.peerIdentity
* The above features are implemented using rollback to work around this bug.
* Provides a workaround for this bug, where the browser may
change the previously negotiated DTLS role in an answer, which breaks Chrome.
* Provides a workaround for this bug,
where the browser throws when is accessed.
* Works around Firefox Bug 1480277.
#### Safari
* Adds rollback support, according to the workaround specified here.
* Provides a workaround for the case where, when the SSRC of a MediaStreamTrack changes, theMediaStreamTrack
browser treats this as a removal of the existing and the addition of a newMediaStreamTrack
.addTrack
* Provides a workaround for this bug, where webrtc-adapter's shimmed
method does not return the RTCRtpSender associated with the added track.
RTCSessionDescription abstracts away some of the browser-specific implementationsRTCSessionDescription
of WebRTC for Firefox and Safari, and works around this bug
in Chrome, where the native constructor throws when its argument is{ type: 'rollback'}.
MediaStream, MediaStreamTrack, and RTCIceCandidate` abstracts away their
browser-prefixed counterparts for earlier browser versions.