@twilio/webrtc
Advanced tools
Comparing version 4.2.1 to 4.3.0
@@ -0,1 +1,10 @@ | ||
4.3.0 (June 5, 2020) | ||
==================== | ||
Changes | ||
------- | ||
- twilio-webrtc.js will no longer support Chrome and Firefox versions that support | ||
only the prefixed versions (`webkit` and `moz`) of `getUserMedia` and `RTCPeerConnection`. (JSDK-2832) | ||
4.2.1 (May 27, 2020) | ||
@@ -2,0 +11,0 @@ ==================== |
@@ -0,9 +1,11 @@ | ||
/* globals navigator */ | ||
'use strict'; | ||
/** | ||
* This function is very similar to <code>navigator.getUserMedia</code> except | ||
* that it does not use callbacks and returns a Promise for a MediaStream | ||
* This function is very similar to <code>navigator.mediaDevices.getUserMedia</code> | ||
* except that if no MediaStreamConstraints are provided, then bot audio and video | ||
* are requested. | ||
* @function getUserMedia | ||
* @param {MediaStreamConstraints} [constraints={audio:true,video:true}] - the | ||
* MediaStreamConstraints object specifying what kind of LocalMediaStream to | ||
* MediaStreamConstraints object specifying what kind of MediaStream to | ||
* request from the browser (by default both audio and video) | ||
@@ -13,24 +15,11 @@ * @returns Promise<MediaStream> | ||
function getUserMedia(constraints) { | ||
return new Promise(function getUserMediaPromise(resolve, reject) { | ||
_getUserMedia(constraints || { audio: true, video: true }, resolve, reject); | ||
}); | ||
} | ||
function _getUserMedia(constraints, onSuccess, onFailure) { | ||
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') { | ||
if (typeof navigator.mediaDevices === 'object' && | ||
typeof navigator.mediaDevices.getUserMedia === 'function') { | ||
navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onFailure); | ||
return; | ||
} else if (typeof navigator.webkitGetUserMedia === 'function') { | ||
navigator.webkitGetUserMedia(constraints, onSuccess, onFailure); | ||
return; | ||
} else if (typeof navigator.mozGetUserMedia === 'function') { | ||
navigator.mozGetUserMedia(constraints, onSuccess, onFailure); | ||
return; | ||
} | ||
if (typeof navigator === 'object' | ||
&& typeof navigator.mediaDevices === 'object' | ||
&& typeof navigator.mediaDevices.getUserMedia === 'function') { | ||
constraints = constraints || { audio: true, video: true }; | ||
return navigator.mediaDevices.getUserMedia(constraints); | ||
} | ||
onFailure(new Error('getUserMedia is not supported')); | ||
return Promise.reject(new Error('getUserMedia is not supported')); | ||
} | ||
module.exports = getUserMedia; |
/* globals MediaStream */ | ||
'use strict'; | ||
if (typeof MediaStream !== 'undefined') { | ||
if (typeof MediaStream === 'function') { | ||
module.exports = MediaStream; | ||
} else { | ||
module.exports = function MediaStream() { | ||
throw new Error('WebRTC is not supported in this browser'); | ||
throw new Error('MediaStream is not supported'); | ||
}; | ||
} |
/* global MediaStreamTrack */ | ||
'use strict'; | ||
if (typeof MediaStreamTrack !== 'undefined') { | ||
if (typeof MediaStreamTrack === 'function') { | ||
module.exports = MediaStreamTrack; | ||
} else { | ||
module.exports = function MediaStreamTrack() { | ||
throw new Error('WebRTC is not supported in this browser'); | ||
throw new Error('MediaStreamTrack is not supported'); | ||
}; | ||
} |
@@ -1,12 +0,10 @@ | ||
/* global mozRTCIceCandidate, RTCIceCandidate */ | ||
/* global RTCIceCandidate */ | ||
'use strict'; | ||
if (typeof RTCIceCandidate !== 'undefined') { | ||
if (typeof RTCIceCandidate === 'function') { | ||
module.exports = RTCIceCandidate; | ||
} else if (typeof mozRTCIceCandidate !== 'undefined') { | ||
module.exports = mozRTCIceCandidate; | ||
} else { | ||
module.exports = function RTCIceCandidate() { | ||
throw new Error('WebRTC is unsupported'); | ||
throw new Error('RTCIceCandidate is not supported'); | ||
}; | ||
} |
'use strict'; | ||
if (typeof RTCPeerConnection !== 'undefined') { | ||
if (typeof RTCPeerConnection === 'function') { | ||
var guessBrowser = require('../util').guessBrowser; | ||
@@ -17,3 +17,8 @@ switch (guessBrowser()) { | ||
module.exports = RTCPeerConnection; | ||
break; | ||
} | ||
} else { | ||
module.exports = function RTCPeerConnection() { | ||
throw new Error('RTCPeerConnection is not supported'); | ||
}; | ||
} |
/* globals RTCSessionDescription */ | ||
'use strict'; | ||
module.exports = typeof RTCSessionDescription !== 'undefined' | ||
? RTCSessionDescription | ||
: window.mozRTCSessionDescription; | ||
module.exports = RTCSessionDescription; |
@@ -0,17 +1,21 @@ | ||
/* globals RTCSessionDescription */ | ||
'use strict'; | ||
var guessBrowser = require('../util').guessBrowser; | ||
switch (guessBrowser()) { | ||
case 'chrome': | ||
module.exports = require('./chrome'); | ||
break; | ||
case 'firefox': | ||
module.exports = require('./firefox'); | ||
break; | ||
default: | ||
if (typeof RTCSessionDescription === 'undefined') { | ||
if (typeof RTCSessionDescription === 'function') { | ||
var guessBrowser = require('../util').guessBrowser; | ||
switch (guessBrowser()) { | ||
case 'chrome': | ||
module.exports = require('./chrome'); | ||
break; | ||
} | ||
module.exports = RTCSessionDescription; | ||
case 'firefox': | ||
module.exports = require('./firefox'); | ||
break; | ||
default: | ||
module.exports = RTCSessionDescription; | ||
break; | ||
} | ||
} else { | ||
module.exports = function RTCSessionDescription() { | ||
throw new Error('RTCSessionDescription is not supported'); | ||
}; | ||
} |
@@ -276,2 +276,13 @@ 'use strict'; | ||
/** | ||
* Check whether native WebRTC APIs are supported. | ||
* @returns {boolean} | ||
*/ | ||
function support() { | ||
return typeof navigator === 'object' | ||
&& typeof navigator.mediaDevices === 'object' | ||
&& typeof navigator.mediaDevices.getUserMedia === 'function' | ||
&& typeof RTCPeerConnection === 'function'; | ||
} | ||
/** | ||
* @typedef {object} Deferred | ||
@@ -293,1 +304,2 @@ * @property {Promise} promise | ||
exports.proxyProperties = proxyProperties; | ||
exports.support = support; |
{ | ||
"name": "@twilio/webrtc", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "WebRTC-related APIs and shims used by twilio-video.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
129838
2907