Skip to content

Commit

Permalink
DetectRTC.js updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jan 19, 2015
1 parent 5d32c7f commit b565dd2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
24 changes: 18 additions & 6 deletions DetectRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
// detect node-webkit
var isNodeWebkit = !!(window.process && (typeof window.process === 'object') && window.process.versions && window.process.versions['node-webkit']);

var isHTTPs = location.protocol === 'https:';

window.DetectRTC = {
browser: browser,
hasMicrophone: navigator.getMediaDevices || navigator.enumerateDevices ? false : 'unable to detect',
Expand All @@ -56,14 +58,19 @@
isScreenCapturingSupported: (isFirefox && browser.version >= 33) ||
(isChrome && browser.version >= 26 && (isNodeWebkit ? true : location.protocol === 'https:')),

isDesktopCapturingSupported: (isFirefox && browser.version >= 33) || (isChrome && browser.version >= 34) || isNodeWebkit || false,
isDesktopCapturingSupported: isHTTPs && ((isFirefox && browser.version >= 33) || (isChrome && browser.version >= 34) || isNodeWebkit || false),

isSctpDataChannelsSupported: isFirefox || (isChrome && browser.version >= 25),
isRtpDataChannelsSupported: isChrome && browser.version >= 31,
isMobileDevice: !!navigator.userAgent.match(/Android|iPhone|iPad|iPod|BlackBerry|IEMobile/i),
isWebSocketsSupported: 'WebSocket' in window && 2 === window.WebSocket.CLOSING
};

if (!isHTTPs) {
window.DetectRTC.isScreenCapturingSupported =
window.DetectRTC.isDesktopCapturingSupported = 'Requires HTTPs.';
}

DetectRTC.browser = {
isFirefox: isFirefox,
isChrome: isChrome,
Expand Down Expand Up @@ -312,9 +319,14 @@
rtc.setLocalDescription(offerDesc);
}, function(e) {
console.warn('offer failed', e);
}, {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: false
},
optional: []
});


var addrs = Object.create(null);
addrs['0.0.0.0'] = false;

Expand All @@ -334,15 +346,15 @@
function grepSDP(sdp) {
var hosts = [],
parts, addr, type;
sdp.split('\r\n').forEach(function(line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
if (~line.indexOf('a=candidate')) { // http://tools.ietf.org/html/rfc4566#section-5.13
parts = line.split(' '); // http://tools.ietf.org/html/rfc5245#section-15.1
sdp.split('\r\n').forEach(function(line) {
if (~line.indexOf('candidate:')) {
parts = line.split(' ');
addr = parts[4];
type = parts[7];
if (type === 'host') {
updateDisplay(addr);
}
} else if (~line.indexOf('c=')) { // http://tools.ietf.org/html/rfc4566#section-5.7
} else if (~line.indexOf('c=')) {
parts = line.split(' ');
addr = parts[2];
updateDisplay(addr);
Expand Down
2 changes: 1 addition & 1 deletion DetectRTC.min.js

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

18 changes: 10 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!--
> Muaz Khan - www.MuazKhan.com
> MIT License - www.WebRTC-Experiment.com/licence
> Documentation - github.com/muaz-khan/WebRTC-Experiment/tree/master/DetectRTC
> Documentation - github.com/muaz-khan/DetectRTC
> npm install detectrtc
> bower install detectrtc
-->
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -108,15 +110,15 @@ <h2 id="welcome">Detect WebRTC!</h2>
appendTR('System has Speakers?', printVal(DetectRTC.hasSpeakers));
appendTR('System has Microphone?', printVal(DetectRTC.hasMicrophone));
appendTR('System has Webcam?', printVal(DetectRTC.hasWebcam));
appendTR('Browser Supports Screen Capturing?', printVal(DetectRTC.isScreenCapturingSupported));

appendTR('Browser Supports WebRTC?', printVal(DetectRTC.isWebRTCSupported));
appendTR('Browser Supports WebAudio API?', printVal(DetectRTC.isAudioContextSupported));
appendTR('Browser Supports SCTP Data Channels?', printVal(DetectRTC.isSctpDataChannelsSupported));
appendTR('Browser Supports RTP Data Channels?', printVal(DetectRTC.isRtpDataChannelsSupported));

appendTR('Browser Supports desktopCapture API?', printVal(DetectRTC.isDesktopCapturingSupported));
appendTR('Browser Supports Screen Capturing API?', printVal(DetectRTC.isScreenCapturingSupported));
appendTR('Is it mobile device?', printVal(DetectRTC.isMobileDevice));
appendTR('This page Supports desktopCapture API?', printVal(DetectRTC.isDesktopCapturingSupported));
appendTR('This page Supports Screen Capturing API?', printVal(DetectRTC.isScreenCapturingSupported));
appendTR('Is it a mobile device?', printVal(DetectRTC.isMobileDevice));
appendTR('Browser Supports WebSockets?', printVal(DetectRTC.isWebSocketsSupported));

document.getElementById('welcome').innerHTML = DetectRTC.osName + ': ' + DetectRTC.browser.name + ' (version: ' + DetectRTC.browser.version + ')';
Expand Down Expand Up @@ -154,7 +156,7 @@ <h2 class="header" id="feedback">Feedback</h2>

<section class="experiment">
<h2 class="header">
How to use <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DetectRTC" target="_blank">DetectRTC</a>?</h2>
How to use <a href="https://github.com/muaz-khan/DetectRTC" target="_blank">DetectRTC</a>?</h2>
<pre>
&lt;script src="//cdn.WebRTC-Experiment.com/DetectRTC.js"&gt;&lt;/script&gt;
</pre>
Expand Down Expand Up @@ -191,12 +193,12 @@ <h2 class="header">
</section>

<section class="experiment own-widgets latest-commits">
<h2 class="header" id="updates" style="color: red; padding-bottom: .1em;"><a href="https://github.com/muaz-khan/WebRTC-Experiment/commits/master" target="_blank">Latest Updates</a></h2>
<h2 class="header" id="updates" style="color: red; padding-bottom: .1em;"><a href="https://github.com/muaz-khan/DetectRTC/commits/master" target="_blank">Latest Updates</a></h2>
<div id="github-commits"></div>
</section>
</article>

<a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DetectRTC" class="fork-left"></a>
<a href="https://github.com/muaz-khan/DetectRTC" class="fork-left"></a>

<footer>
<p>
Expand Down

0 comments on commit b565dd2

Please sign in to comment.