Skip to content

Commit

Permalink
Merge pull request #220 from Temasys/development
Browse files Browse the repository at this point in the history
Merge dev into master for version 0.13.4
  • Loading branch information
johache authored Sep 22, 2016
2 parents e8668c9 + 4cbe13a commit 78125a7
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 101 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ window.navigator.getUserMedia({

## Setup this project

- Copy this repository with submodules (`git clone --recursive ...`), or run `git submodule init` and `git submodule udpate`
- Copy this repository with submodules (`git clone --recursive ...`), or run `git submodule init` and `git submodule update`
- Install or update to at lest version 0.10.26 of node and version 1.4.6 of npm
- Install `grunt-cli` (See: http://gruntjs.com/getting-started)
- Run `npm install` to install dev dependencies.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapterjs",
"description": "Creating a common API for WebRTC in the browser",
"version": "0.13.3",
"version": "0.13.4",
"homepage": "https://temasys.github.io/",
"author": {
"name": "Temasys Communications Pte. Ltd.",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapterjs",
"description": "Creating a common API for WebRTC in the browser",
"version": "0.13.3",
"version": "0.13.4",
"homepage": "https://temasys.github.io/",
"author": {
"name": "Temasys Communications Pte. Ltd.",
Expand Down
149 changes: 118 additions & 31 deletions publish/adapter.debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! adapterjs - v0.13.3 - 2016-04-13 */
/*! adapterjs - v0.13.4 - 2016-09-22 */

// Adapter's interface.
var AdapterJS = AdapterJS || {};
Expand All @@ -17,7 +17,7 @@ AdapterJS.options = AdapterJS.options || {};
// AdapterJS.options.hidePluginInstallPrompt = true;

// AdapterJS version
AdapterJS.VERSION = '0.13.3';
AdapterJS.VERSION = '0.13.4';

// This function will be called when the WebRTC API is ready to be used
// Whether it is the native implementation (Chrome, Firefox, Opera) or
Expand Down Expand Up @@ -59,22 +59,29 @@ AdapterJS.WebRTCPlugin = AdapterJS.WebRTCPlugin || {};

// The object to store plugin information
/* jshint ignore:start */
AdapterJS.WebRTCPlugin.pluginInfo = {
AdapterJS.WebRTCPlugin.pluginInfo = AdapterJS.WebRTCPlugin.pluginInfo || {
prefix : 'Tem',
plugName : 'TemWebRTCPlugin',
pluginId : 'plugin0',
type : 'application/x-temwebrtcplugin',
onload : '__TemWebRTCReady0',
portalLink : 'http://skylink.io/plugin/',
downloadLink : null, //set below
companyName: 'Temasys'
companyName: 'Temasys',
downloadLinks : {
mac: 'http://bit.ly/1n77hco',
win: 'http://bit.ly/1kkS4FN'
}
};
if(!!navigator.platform.match(/^Mac/i)) {
AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = 'http://bit.ly/1n77hco';
}
else if(!!navigator.platform.match(/^Win/i)) {
AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = 'http://bit.ly/1kkS4FN';
if(typeof AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks !== "undefined" && AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks !== null) {
if(!!navigator.platform.match(/^Mac/i)) {
AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks.mac;
}
else if(!!navigator.platform.match(/^Win/i)) {
AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = AdapterJS.WebRTCPlugin.pluginInfo.downloadLinks.win;
}
}

/* jshint ignore:end */

AdapterJS.WebRTCPlugin.TAGS = {
Expand Down Expand Up @@ -247,8 +254,8 @@ AdapterJS.isDefined = null;
// - 'plugin': Using the plugin implementation.
AdapterJS.parseWebrtcDetectedBrowser = function () {
var hasMatch = null;
if ((!!window.opr && !!opr.addons) ||
!!window.opera ||
if ((!!window.opr && !!opr.addons) ||
!!window.opera ||
navigator.userAgent.indexOf(' OPR/') >= 0) {
// Opera 8.0+
webrtcDetectedBrowser = 'opera';
Expand Down Expand Up @@ -276,7 +283,7 @@ AdapterJS.parseWebrtcDetectedBrowser = function () {
webrtcDetectedVersion = parseInt(hasMatch[1] || '0', 10);
if (!webrtcDetectedVersion) {
hasMatch = /\bMSIE[ :]+(\d+)/g.exec(navigator.userAgent) || [];
webrtcDetectedVersion = parseInt(hasMatch[1] || '0', 10);
webrtcDetectedVersion = parseInt(hasMatch[1] || '0', 10);
}
} else if (!!window.StyleMedia) {
// Edge 20+
Expand All @@ -286,13 +293,20 @@ AdapterJS.parseWebrtcDetectedBrowser = function () {
// Chrome 1+
// Bowser and Version set in Google's adapter
webrtcDetectedType = 'webkit';
} else if ((webrtcDetectedBrowser === 'chrome'|| webrtcDetectedBrowser === 'opera') &&
} else if ((webrtcDetectedBrowser === 'chrome'|| webrtcDetectedBrowser === 'opera') &&
!!window.CSS) {
// Blink engine detection
webrtcDetectedBrowser = 'blink';
// TODO: detected WebRTC version
}

if ((navigator.userAgent.match(/android/ig) || []).length === 0 &&
(navigator.userAgent.match(/chrome/ig) || []).length === 0 &&
navigator.userAgent.indexOf('Safari/') > 0) {
webrtcDetectedBrowser = 'safari';
webrtcDetectedVersion = parseInt((navigator.userAgent.match(/Version\/(.*)\ /) || ['', '0'])[1], 10);
webrtcMinimumVersion = 7;
webrtcDetectedType = 'plugin';
}
window.webrtcDetectedBrowser = webrtcDetectedBrowser;
window.webrtcDetectedVersion = webrtcDetectedVersion;
window.webrtcMinimumVersion = webrtcMinimumVersion;
Expand Down Expand Up @@ -364,6 +378,7 @@ AdapterJS.renderNotificationBar = function (text, buttonText, buttonLink, openNe
AdapterJS.WebRTCPlugin.isPluginInstalled(
AdapterJS.WebRTCPlugin.pluginInfo.prefix,
AdapterJS.WebRTCPlugin.pluginInfo.plugName,
AdapterJS.WebRTCPlugin.pluginInfo.type,
function() { // plugin now installed
clearInterval(pluginInstallInterval);
AdapterJS.WebRTCPlugin.defineWebRTCInterface();
Expand Down Expand Up @@ -551,10 +566,12 @@ webrtcDetectedVersion = null;
webrtcMinimumVersion = null;

// Check for browser types and react accordingly
if ( navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia ||
(navigator.mediaDevices &&
navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) ) {
if ( (navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia ||
(navigator.mediaDevices &&
navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)))
&& !((navigator.userAgent.match(/android/ig) || []).length === 0 &&
    (navigator.userAgent.match(/chrome/ig) || []).length === 0 && navigator.userAgent.indexOf('Safari/') > 0)) {

///////////////////////////////////////////////////////////////////
// INJECTION OF GOOGLE'S ADAPTER.JS CONTENT
Expand Down Expand Up @@ -2433,9 +2450,21 @@ if ( navigator.mozGetUserMedia ||
// Need to override attachMediaStream and reattachMediaStream
// to support the plugin's logic
attachMediaStream_base = attachMediaStream;

if (webrtcDetectedBrowser === 'opera') {
attachMediaStream_base = function (element, stream) {
if (webrtcDetectedVersion > 38) {
element.srcObject = stream;
} else if (typeof element.src !== 'undefined') {
element.src = URL.createObjectURL(stream);
}
// Else it doesn't work
};
}

attachMediaStream = function (element, stream) {
if ((webrtcDetectedBrowser === 'chrome' ||
webrtcDetectedBrowser === 'opera') &&
webrtcDetectedBrowser === 'opera') &&
!stream) {
// Chrome does not support "src = null"
element.src = '';
Expand Down Expand Up @@ -2615,11 +2644,11 @@ if ( navigator.mozGetUserMedia ||
};

AdapterJS.WebRTCPlugin.isPluginInstalled =
function (comName, plugName, installedCb, notInstalledCb) {
function (comName, plugName, plugType, installedCb, notInstalledCb) {
if (!isIE) {
var pluginArray = navigator.plugins;
var pluginArray = navigator.mimeTypes;
for (var i = 0; i < pluginArray.length; i++) {
if (pluginArray[i].name.indexOf(plugName) >= 0) {
if (pluginArray[i].type.indexOf(plugType) >= 0) {
installedCb();
return;
}
Expand Down Expand Up @@ -2694,11 +2723,11 @@ if ( navigator.mozGetUserMedia ||
if (typeof constraints !== 'undefined' && constraints !== null) {
var invalidConstraits = false;
invalidConstraits |= typeof constraints !== 'object';
invalidConstraits |= constraints.hasOwnProperty('mandatory') &&
constraints.mandatory !== undefined &&
constraints.mandatory !== null &&
invalidConstraits |= constraints.hasOwnProperty('mandatory') &&
constraints.mandatory !== undefined &&
constraints.mandatory !== null &&
constraints.mandatory.constructor !== Object;
invalidConstraits |= constraints.hasOwnProperty('optional') &&
invalidConstraits |= constraints.hasOwnProperty('optional') &&
constraints.optional !== undefined &&
constraints.optional !== null &&
!Array.isArray(constraints.optional);
Expand Down Expand Up @@ -2743,20 +2772,76 @@ if ( navigator.mozGetUserMedia ||
}
};

MediaStreamTrack = {};
MediaStreamTrack = function(){};
MediaStreamTrack.getSources = function (callback) {
AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
AdapterJS.WebRTCPlugin.plugin.GetSources(callback);
});
};

// getUserMedia constraints shim.
// Copied from Chrome
var constraintsToPlugin = function(c) {
if (typeof c !== 'object' || c.mandatory || c.optional) {
return c;
}
var cc = {};
Object.keys(c).forEach(function(key) {
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
return;
}
var r = (typeof c[key] === 'object') ? c[key] : {ideal: c[key]};
if (r.exact !== undefined && typeof r.exact === 'number') {
r.min = r.max = r.exact;
}
var oldname = function(prefix, name) {
if (prefix) {
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
}
return (name === 'deviceId') ? 'sourceId' : name;
};
if (r.ideal !== undefined) {
cc.optional = cc.optional || [];
var oc = {};
if (typeof r.ideal === 'number') {
oc[oldname('min', key)] = r.ideal;
cc.optional.push(oc);
oc = {};
oc[oldname('max', key)] = r.ideal;
cc.optional.push(oc);
} else {
oc[oldname('', key)] = r.ideal;
cc.optional.push(oc);
}
}
if (r.exact !== undefined && typeof r.exact !== 'number') {
cc.mandatory = cc.mandatory || {};
cc.mandatory[oldname('', key)] = r.exact;
} else {
['min', 'max'].forEach(function(mix) {
if (r[mix] !== undefined) {
cc.mandatory = cc.mandatory || {};
cc.mandatory[oldname(mix, key)] = r[mix];
}
});
}
});
if (c.advanced) {
cc.optional = (cc.optional || []).concat(c.advanced);
}
return cc;
};

getUserMedia = function (constraints, successCallback, failureCallback) {
constraints.audio = constraints.audio || false;
constraints.video = constraints.video || false;
var cc = {};
cc.audio = constraints.audio ?
constraintsToPlugin(constraints.audio) : false;
cc.video = constraints.video ?
constraintsToPlugin(constraints.video) : false;

AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
AdapterJS.WebRTCPlugin.plugin.
getUserMedia(constraints, successCallback, failureCallback);
getUserMedia(cc, successCallback, failureCallback);
});
};
window.navigator.getUserMedia = getUserMedia;
Expand Down Expand Up @@ -2902,7 +2987,7 @@ if ( navigator.mozGetUserMedia ||
propName = properties[prop];

if (typeof propName.slice === 'function' &&
propName.slice(0,2) === 'on' &&
propName.slice(0,2) === 'on' &&
typeof srcElem[propName] === 'function') {
AdapterJS.addEvent(destElem, propName.slice(2), srcElem[propName]);
}
Expand Down Expand Up @@ -2964,10 +3049,12 @@ if ( navigator.mozGetUserMedia ||
}
};


// Try to detect the plugin and act accordingly
AdapterJS.WebRTCPlugin.isPluginInstalled(
AdapterJS.WebRTCPlugin.pluginInfo.prefix,
AdapterJS.WebRTCPlugin.pluginInfo.plugName,
AdapterJS.WebRTCPlugin.pluginInfo.type,
AdapterJS.WebRTCPlugin.defineWebRTCInterface,
AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCb);

Expand Down
6 changes: 3 additions & 3 deletions publish/adapter.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 78125a7

Please sign in to comment.