Skip to content

Commit

Permalink
DetectRTC.js updates in "development" branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Sep 21, 2015
1 parent cb69c0b commit e57aff7
Show file tree
Hide file tree
Showing 11 changed files with 756 additions and 65 deletions.
564 changes: 564 additions & 0 deletions DetectRTC.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions DetectRTC.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ module.exports = function(grunt) {
concat: {
options: {
stripBanners: true,
separator: ''
separator: '\n'
},
dist: {
src: [
'DetectRTC.js'
'dev/head.js',
'dev/common.js',
'dev/getBrowserInfo.js',
'dev/isMobile.js',
'dev/detectOSName.js',
'dev/detectCaptureStream.js',
'dev/DetectLocalIPAddress.js',
'dev/CheckDeviceSupport.js',
'dev/DetectRTC.js'
],
dest: 'DetectRTC.js',
},
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
# Proposed NEW API

```javascript
DetectRTC.isSetSinkIdSupported
DetectRTC.isSetSinkIdSupported // (implemented)
DetectRTC.isRTPSenderReplaceTracksSupported // (implemented)
DetectRTC.isORTCSupported // (implemented)

DetectRTC.isRemoteStreamProcessingSupported
DetectRTC.isRTPSenderReplaceTracksSupported
DetectRTC.isOutputDevicesEnumerationSupported
DetectRTC.isMediaDevicesNewSyntaxSupported
DetectRTC.browser.googSupportedFlags.googDAEEchoCancellation
DetecRTC.browser.googSupportedFlags.echoCancellation
Expand Down
44 changes: 28 additions & 16 deletions dev/CheckDeviceSupport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
DetectRTC.MediaDevices = [];
var MediaDevices = [];

// ---------- Media Devices detection
var canEnumerate = false;
if(typeof MediaStreamTrack !== 'undefined') {
canEnumerate = true;
}

else if(navigator.mediaDevices && !!navigator.mediaDevices.enumerateDevices) {
canEnumerate = true;
}

var hasMicrophone = canEnumerate;
var hasSpeakers = canEnumerate;
var hasWebcam = canEnumerate;

// http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediadevices
// todo: switch to enumerateDevices when landed in canary.
Expand All @@ -14,21 +28,13 @@ function CheckDeviceSupport(callback) {
}

if (!navigator.enumerateDevices) {
warn('navigator.enumerateDevices is undefined.');
// assuming that it is older chrome or chromium implementation
if (isChrome) {
DetectRTC.hasMicrophone = true;
DetectRTC.hasSpeakers = true;
DetectRTC.hasWebcam = true;
}

if (callback) {
callback();
}
return;
}

DetectRTC.MediaDevices = [];
MediaDevices = [];
navigator.enumerateDevices(function(devices) {
devices.forEach(function(_device) {
var device = {};
Expand All @@ -37,7 +43,7 @@ function CheckDeviceSupport(callback) {
}

var skip;
DetectRTC.MediaDevices.forEach(function(d) {
MediaDevices.forEach(function(d) {
if (d.id === device.id) {
skip = true;
}
Expand Down Expand Up @@ -69,22 +75,29 @@ function CheckDeviceSupport(callback) {
}

if (device.kind === 'audioinput' || device.kind === 'audio') {
DetectRTC.hasMicrophone = true;
hasMicrophone = true;
}

if (device.kind === 'audiooutput') {
DetectRTC.hasSpeakers = true;
hasSpeakers = true;
}

if (device.kind === 'videoinput' || device.kind === 'video') {
DetectRTC.hasWebcam = true;
hasWebcam = true;
}

// there is no 'videoouput' in the spec.

DetectRTC.MediaDevices.push(device);
MediaDevices.push(device);
});

if(typeof DetectRTC !== 'undefined') {
DetectRTC.MediaDevices = MediaDevices;
DetectRTC.hasMicrophone = MediaDevices;
DetectRTC.hasSpeakers = MediaDevices;
DetectRTC.hasWebcam = MediaDevices;
}

if (callback) {
callback();
}
Expand All @@ -93,4 +106,3 @@ function CheckDeviceSupport(callback) {

// check for microphone/camera support!
new CheckDeviceSupport();
DetectRTC.load = CheckDeviceSupport;
10 changes: 8 additions & 2 deletions dev/DetectLocalIPAddress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// via: https://github.com/diafygi/webrtc-ips
DetectRTC.DetectLocalIPAddress = function(callback) {
function DetectLocalIPAddress(callback) {
getIPs(function(ip) {
//local IPs
if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {
Expand All @@ -11,7 +11,7 @@ DetectRTC.DetectLocalIPAddress = function(callback) {
callback('Public: ' + ip);
}
});
};
}

//get the IP addresses associated with an account
function getIPs(callback) {
Expand Down Expand Up @@ -52,6 +52,12 @@ function getIPs(callback) {
urls: 'stun:stun.services.mozilla.com'
}]
};

if(typeof DetectRTC !== 'undefined' && DetectRTC.browser.isFirefox && DetectRTC.browser.version <= 38) {
servers[0] = {
url: servers[0].urls
};
}
}

//construct a new RTCPeerConnection
Expand Down
Loading

0 comments on commit e57aff7

Please sign in to comment.