Skip to content

Commit

Permalink
Fixed #14 and forced skipping redundant checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Nov 30, 2015
1 parent bee1a47 commit 9039a0b
Show file tree
Hide file tree
Showing 9 changed files with 422 additions and 400 deletions.
35 changes: 26 additions & 9 deletions DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated at Sunday, November 29th, 2015, 8:05:29 PM
// Last time updated at Monday, November 30th, 2015, 10:25:38 AM

// Latest file can be found here: https://cdn.webrtc-experiment.com/DetectRTC.js

Expand Down Expand Up @@ -36,7 +36,8 @@
}
} else {
navigator = {
getUserMedia: function() {}
getUserMedia: function() {},
userAgent: 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45'
};
}

Expand Down Expand Up @@ -198,18 +199,25 @@
var isCanvasSupportsStreamCapturing = false;
var isVideoSupportsStreamCapturing = false;
['captureStream', 'mozCaptureStream', 'webkitCaptureStream'].forEach(function(item) {
// asdf
if (item in document.createElement('canvas')) {
if (!isCanvasSupportsStreamCapturing && item in document.createElement('canvas')) {
isCanvasSupportsStreamCapturing = true;
}

if (item in document.createElement('video')) {
if (!isVideoSupportsStreamCapturing && item in document.createElement('video')) {
isVideoSupportsStreamCapturing = true;
}
});

// via: https://github.com/diafygi/webrtc-ips
function DetectLocalIPAddress(callback) {
if (!DetectRTC.isWebRTCSupported) {
return;
}

if (DetectRTC.isORTCSupported) {
return;
}

getIPs(function(ip) {
//local IPs
if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {
Expand Down Expand Up @@ -454,7 +462,11 @@

// --------- Detect if system supports WebRTC 1.0 or WebRTC 1.1.
var isWebRTCSupported = false;
['webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
if (isWebRTCSupported) {
return;
}

if (item in window) {
isWebRTCSupported = true;
}
Expand All @@ -478,11 +490,16 @@
DetectRTC.isScreenCapturingSupported = isScreenCapturingSupported;

// --------- Detect if WebAudio API are supported
var webAudio = {};
var webAudio = {
isSupported: false,
isCreateMediaStreamSourceSupported: false
};

['AudioContext', 'webkitAudioContext', 'mozAudioContext', 'msAudioContext'].forEach(function(item) {
if (webAudio.isSupported && webAudio.isCreateMediaStreamSourceSupported) {
if (webAudio.isSupported) {
return;
}

if (item in window) {
webAudio.isSupported = true;

Expand Down Expand Up @@ -547,7 +564,7 @@
} else if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
isGetUserMediaSupported = true;
}
if (DetectRTC.browser.isChrome && DetectRTC.browser.version >= 47 && !isHTTPs) {
if (DetectRTC.browser.isChrome && DetectRTC.browser.version >= 46 && !isHTTPs) {
DetectRTC.isGetUserMediaSupported = 'Requires HTTPs';
}
DetectRTC.isGetUserMediaSupported = isGetUserMediaSupported;
Expand Down
4 changes: 3 additions & 1 deletion DetectRTC.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ module.exports = function(grunt) {
},
uglify: {
options: {
mangle: false
mangle: false,
banner: '// Last time updated at <%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %> \n\n'
},
my_target: {
files: {
Expand Down
8 changes: 8 additions & 0 deletions dev/DetectLocalIPAddress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// via: https://github.com/diafygi/webrtc-ips
function DetectLocalIPAddress(callback) {
if(!DetectRTC.isWebRTCSupported) {
return;
}

if(DetectRTC.isORTCSupported) {
return;
}

getIPs(function(ip) {
//local IPs
if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {
Expand Down
17 changes: 13 additions & 4 deletions dev/DetectRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ var isNodeWebkit = !!(window.process && (typeof window.process === 'object') &&

// --------- Detect if system supports WebRTC 1.0 or WebRTC 1.1.
var isWebRTCSupported = false;
['webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
if(isWebRTCSupported) {
return;
}

if(item in window) {
isWebRTCSupported = true;
}
Expand All @@ -37,11 +41,16 @@ if(!isHTTPs) {
DetectRTC.isScreenCapturingSupported = isScreenCapturingSupported;

// --------- Detect if WebAudio API are supported
var webAudio = {};
var webAudio = {
isSupported: false,
isCreateMediaStreamSourceSupported: false
};

['AudioContext', 'webkitAudioContext', 'mozAudioContext', 'msAudioContext'].forEach(function(item) {
if (webAudio.isSupported && webAudio.isCreateMediaStreamSourceSupported) {
if (webAudio.isSupported) {
return;
}

if(item in window) {
webAudio.isSupported = true;

Expand Down Expand Up @@ -109,7 +118,7 @@ if(navigator.getUserMedia) {
else if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia){
isGetUserMediaSupported = true;
}
if(DetectRTC.browser.isChrome && DetectRTC.browser.version >= 47 && !isHTTPs) {
if(DetectRTC.browser.isChrome && DetectRTC.browser.version >= 46 && !isHTTPs) {
DetectRTC.isGetUserMediaSupported = 'Requires HTTPs';
}
DetectRTC.isGetUserMediaSupported = isGetUserMediaSupported;
Expand Down
3 changes: 2 additions & 1 deletion dev/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (typeof navigator !== 'undefined') {
}
} else {
navigator = {
getUserMedia: function() { }
getUserMedia: function() { },
userAgent: 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45'
};
}
5 changes: 2 additions & 3 deletions dev/detectCaptureStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
var isCanvasSupportsStreamCapturing = false;
var isVideoSupportsStreamCapturing = false;
['captureStream', 'mozCaptureStream', 'webkitCaptureStream'].forEach(function(item) {
// asdf
if(item in document.createElement('canvas')) {
if(!isCanvasSupportsStreamCapturing && item in document.createElement('canvas')) {
isCanvasSupportsStreamCapturing = true;
}

if(item in document.createElement('video')) {
if(!isVideoSupportsStreamCapturing && item in document.createElement('video')) {
isVideoSupportsStreamCapturing = true;
}
});
Loading

0 comments on commit 9039a0b

Please sign in to comment.