Skip to content

Commit 0748501

Browse files
author
Mariusz Bełtowski
committed
Fail silently if unable to shim GetUserMedia & AddTrackRemoveTrack & PeerConnection on chrome
1 parent 96ef288 commit 0748501

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ validation-report.json
88
validation-status.json
99
npm-debug.log
1010
*~
11+
.idea

src/js/chrome/chrome_shim.js

+6
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ export function shimAddTrackRemoveTrackWithNative(window) {
403403
}
404404

405405
export function shimAddTrackRemoveTrack(window) {
406+
if (!window.RTCPeerConnection) {
407+
return;
408+
}
406409
const browserDetails = utils.detectBrowser(window);
407410
// shim addTrack and removeTrack.
408411
if (window.RTCPeerConnection.prototype.addTrack &&
@@ -625,6 +628,9 @@ export function shimPeerConnection(window) {
625628
// very basic support for old versions.
626629
window.RTCPeerConnection = window.webkitRTCPeerConnection;
627630
}
631+
if (!window.RTCPeerConnection) {
632+
return;
633+
}
628634

629635
const origGetStats = window.RTCPeerConnection.prototype.getStats;
630636
window.RTCPeerConnection.prototype.getStats = function(selector,

src/js/chrome/getusermedia.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import * as utils from '../utils.js';
1111
const logging = utils.log;
1212

1313
export function shimGetUserMedia(window) {
14-
const browserDetails = utils.detectBrowser(window);
1514
const navigator = window && window.navigator;
1615

16+
if (!navigator.mediaDevices) {
17+
return;
18+
}
19+
20+
const browserDetails = utils.detectBrowser(window);
21+
1722
const constraintsToChrome_ = function(c) {
1823
if (typeof c !== 'object' || c.mandatory || c.optional) {
1924
return c;

0 commit comments

Comments
 (0)