webrtc-adapter
Advanced tools
Comparing version 7.1.1 to 7.2.0
@@ -89,2 +89,3 @@ 'use strict'; | ||
commonShim.shimSendThrowTypeError(window); | ||
commonShim.removeAllowExtmapMixed(window); | ||
break; | ||
@@ -152,2 +153,3 @@ case 'firefox': | ||
commonShim.shimSendThrowTypeError(window); | ||
commonShim.removeAllowExtmapMixed(window); | ||
break; | ||
@@ -154,0 +156,0 @@ default: |
@@ -21,2 +21,3 @@ /* | ||
exports.shimConnectionState = shimConnectionState; | ||
exports.removeAllowExtmapMixed = removeAllowExtmapMixed; | ||
@@ -304,1 +305,21 @@ var _sdp = require('sdp'); | ||
} | ||
function removeAllowExtmapMixed(window) { | ||
/* remove a=extmap-allow-mixed for Chrome < M71 */ | ||
if (!window.RTCPeerConnection) { | ||
return; | ||
} | ||
var browserDetails = utils.detectBrowser(window); | ||
if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) { | ||
return; | ||
} | ||
var nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription; | ||
window.RTCPeerConnection.prototype.setRemoteDescription = function (desc) { | ||
if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) { | ||
desc.sdp = desc.sdp.split('\n').filter(function (line) { | ||
return line.trim() !== 'a=extmap-allow-mixed'; | ||
}).join('\n'); | ||
} | ||
return nativeSRD.apply(this, arguments); | ||
}; | ||
} |
@@ -20,2 +20,3 @@ /* | ||
exports.shimGetUserMedia = shimGetUserMedia; | ||
exports.shimConstraints = shimConstraints; | ||
exports.shimRTCIceServerUrls = shimRTCIceServerUrls; | ||
@@ -219,2 +220,11 @@ exports.shimTrackEventTransceiver = shimTrackEventTransceiver; | ||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { | ||
// shim not needed in Safari 12.1 | ||
var mediaDevices = navigator.mediaDevices; | ||
var _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices); | ||
navigator.mediaDevices.getUserMedia = function (constraints) { | ||
return _getUserMedia(shimConstraints(constraints)); | ||
}; | ||
} | ||
if (!navigator.getUserMedia && navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { | ||
@@ -227,2 +237,10 @@ navigator.getUserMedia = function (constraints, cb, errcb) { | ||
function shimConstraints(constraints) { | ||
if (constraints && constraints.video !== undefined) { | ||
return Object.assign({}, constraints, { video: utils.compactObject(constraints.video) }); | ||
} | ||
return constraints; | ||
} | ||
function shimRTCIceServerUrls(window) { | ||
@@ -229,0 +247,0 @@ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls |
@@ -24,2 +24,6 @@ /* | ||
exports.detectBrowser = detectBrowser; | ||
exports.compactObject = compactObject; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var logDisabled_ = true; | ||
@@ -179,1 +183,23 @@ var deprecationWarnings_ = true; | ||
} | ||
/** | ||
* Remove all empty objects and undefined values | ||
* from a nested object -- an enhanced and vanilla version | ||
* of Lodash's `compact`. | ||
*/ | ||
function compactObject(data) { | ||
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') { | ||
return data; | ||
} | ||
return Object.keys(data).reduce(function (accumulator, key) { | ||
var isObject = _typeof(data[key]) === 'object'; | ||
var value = isObject ? compactObject(data[key]) : data[key]; | ||
var isEmptyObject = isObject && !Object.keys(value).length; | ||
if (value === undefined || isEmptyObject) { | ||
return accumulator; | ||
} | ||
return Object.assign(accumulator, _defineProperty({}, key, value)); | ||
}, {}); | ||
} |
{ | ||
"name": "webrtc-adapter", | ||
"version": "7.1.1", | ||
"version": "7.2.0", | ||
"description": "A shim to insulate apps from WebRTC spec changes and browser prefix differences", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -62,3 +62,3 @@ [![Build Status](https://travis-ci.org/webrtcHacks/adapter.svg)](https://travis-ci.org/webrtc/adapter) | ||
* Go back to your checkout and run `git pull` | ||
* Run `npm publish` (you need access to the [webrtc-adapter npmjs package](https://www.npmjs.com/package/webrtc-adapter)). For big changes, consider using a [tag version](https://docs.npmjs.com/adding-dist-tags-to-packages) such as `next`. | ||
* Run `npm publish` (you need access to the [webrtc-adapter npmjs package](https://www.npmjs.com/package/webrtc-adapter)). For big changes, consider using a [tag version](https://docs.npmjs.com/adding-dist-tags-to-packages) such as `next` and then [change the dist-tag after testing](https://docs.npmjs.com/cli/dist-tag). | ||
* Done! There should now be a new release published to NPM and the gh-pages branch. | ||
@@ -65,0 +65,0 @@ |
@@ -61,2 +61,3 @@ /* | ||
commonShim.shimSendThrowTypeError(window); | ||
commonShim.removeAllowExtmapMixed(window); | ||
break; | ||
@@ -125,2 +126,3 @@ case 'firefox': | ||
commonShim.shimSendThrowTypeError(window); | ||
commonShim.removeAllowExtmapMixed(window); | ||
break; | ||
@@ -127,0 +129,0 @@ default: |
@@ -299,1 +299,21 @@ /* | ||
} | ||
export function removeAllowExtmapMixed(window) { | ||
/* remove a=extmap-allow-mixed for Chrome < M71 */ | ||
if (!window.RTCPeerConnection) { | ||
return; | ||
} | ||
const browserDetails = utils.detectBrowser(window); | ||
if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) { | ||
return; | ||
} | ||
const nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription; | ||
window.RTCPeerConnection.prototype.setRemoteDescription = function(desc) { | ||
if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) { | ||
desc.sdp = desc.sdp.split('\n').filter((line) => { | ||
return line.trim() !== 'a=extmap-allow-mixed'; | ||
}).join('\n'); | ||
} | ||
return nativeSRD.apply(this, arguments); | ||
}; | ||
} |
@@ -192,2 +192,11 @@ /* | ||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { | ||
// shim not needed in Safari 12.1 | ||
const mediaDevices = navigator.mediaDevices; | ||
const _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices); | ||
navigator.mediaDevices.getUserMedia = (constraints) => { | ||
return _getUserMedia(shimConstraints(constraints)); | ||
}; | ||
} | ||
if (!navigator.getUserMedia && navigator.mediaDevices && | ||
@@ -202,2 +211,13 @@ navigator.mediaDevices.getUserMedia) { | ||
export function shimConstraints(constraints) { | ||
if (constraints && constraints.video !== undefined) { | ||
return Object.assign({}, | ||
constraints, | ||
{video: utils.compactObject(constraints.video)} | ||
); | ||
} | ||
return constraints; | ||
} | ||
export function shimRTCIceServerUrls(window) { | ||
@@ -204,0 +224,0 @@ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls |
@@ -174,1 +174,23 @@ /* | ||
} | ||
/** | ||
* Remove all empty objects and undefined values | ||
* from a nested object -- an enhanced and vanilla version | ||
* of Lodash's `compact`. | ||
*/ | ||
export function compactObject(data) { | ||
if (typeof data !== 'object') { | ||
return data; | ||
} | ||
return Object.keys(data).reduce(function(accumulator, key) { | ||
const isObject = typeof data[key] === 'object'; | ||
const value = isObject ? compactObject(data[key]) : data[key]; | ||
const isEmptyObject = isObject && !Object.keys(value).length; | ||
if (value === undefined || isEmptyObject) { | ||
return accumulator; | ||
} | ||
return Object.assign(accumulator, {[key]: value}); | ||
}, {}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
908343
22506
0