1- /*! adapterjs - v0.13.3 - 2016-04-13 */
1+ /*! adapterjs - v0.13.4 - 2016-09-22 */
22
33// Adapter's interface.
44var AdapterJS = AdapterJS || { } ;
@@ -17,7 +17,7 @@ AdapterJS.options = AdapterJS.options || {};
1717// AdapterJS.options.hidePluginInstallPrompt = true;
1818
1919// AdapterJS version
20- AdapterJS . VERSION = '0.13.3 ' ;
20+ AdapterJS . VERSION = '0.13.4 ' ;
2121
2222// This function will be called when the WebRTC API is ready to be used
2323// Whether it is the native implementation (Chrome, Firefox, Opera) or
@@ -59,22 +59,29 @@ AdapterJS.WebRTCPlugin = AdapterJS.WebRTCPlugin || {};
5959
6060// The object to store plugin information
6161/* jshint ignore:start */
62- AdapterJS . WebRTCPlugin . pluginInfo = {
62+ AdapterJS . WebRTCPlugin . pluginInfo = AdapterJS . WebRTCPlugin . pluginInfo || {
6363 prefix : 'Tem' ,
6464 plugName : 'TemWebRTCPlugin' ,
6565 pluginId : 'plugin0' ,
6666 type : 'application/x-temwebrtcplugin' ,
6767 onload : '__TemWebRTCReady0' ,
6868 portalLink : 'http://skylink.io/plugin/' ,
6969 downloadLink : null , //set below
70- companyName : 'Temasys'
70+ companyName : 'Temasys' ,
71+ downloadLinks : {
72+ mac : 'http://bit.ly/1n77hco' ,
73+ win : 'http://bit.ly/1kkS4FN'
74+ }
7175} ;
72- if ( ! ! navigator . platform . match ( / ^ M a c / i) ) {
73- AdapterJS . WebRTCPlugin . pluginInfo . downloadLink = 'http://bit.ly/1n77hco' ;
74- }
75- else if ( ! ! navigator . platform . match ( / ^ W i n / i) ) {
76- AdapterJS . WebRTCPlugin . pluginInfo . downloadLink = 'http://bit.ly/1kkS4FN' ;
76+ if ( typeof AdapterJS . WebRTCPlugin . pluginInfo . downloadLinks !== "undefined" && AdapterJS . WebRTCPlugin . pluginInfo . downloadLinks !== null ) {
77+ if ( ! ! navigator . platform . match ( / ^ M a c / i) ) {
78+ AdapterJS . WebRTCPlugin . pluginInfo . downloadLink = AdapterJS . WebRTCPlugin . pluginInfo . downloadLinks . mac ;
79+ }
80+ else if ( ! ! navigator . platform . match ( / ^ W i n / i) ) {
81+ AdapterJS . WebRTCPlugin . pluginInfo . downloadLink = AdapterJS . WebRTCPlugin . pluginInfo . downloadLinks . win ;
82+ }
7783}
84+
7885/* jshint ignore:end */
7986
8087AdapterJS . WebRTCPlugin . TAGS = {
@@ -247,8 +254,8 @@ AdapterJS.isDefined = null;
247254// - 'plugin': Using the plugin implementation.
248255AdapterJS . parseWebrtcDetectedBrowser = function ( ) {
249256 var hasMatch = null ;
250- if ( ( ! ! window . opr && ! ! opr . addons ) ||
251- ! ! window . opera ||
257+ if ( ( ! ! window . opr && ! ! opr . addons ) ||
258+ ! ! window . opera ||
252259 navigator . userAgent . indexOf ( ' OPR/' ) >= 0 ) {
253260 // Opera 8.0+
254261 webrtcDetectedBrowser = 'opera' ;
@@ -276,7 +283,7 @@ AdapterJS.parseWebrtcDetectedBrowser = function () {
276283 webrtcDetectedVersion = parseInt ( hasMatch [ 1 ] || '0' , 10 ) ;
277284 if ( ! webrtcDetectedVersion ) {
278285 hasMatch = / \b M S I E [ : ] + ( \d + ) / g. exec ( navigator . userAgent ) || [ ] ;
279- webrtcDetectedVersion = parseInt ( hasMatch [ 1 ] || '0' , 10 ) ;
286+ webrtcDetectedVersion = parseInt ( hasMatch [ 1 ] || '0' , 10 ) ;
280287 }
281288 } else if ( ! ! window . StyleMedia ) {
282289 // Edge 20+
@@ -286,13 +293,20 @@ AdapterJS.parseWebrtcDetectedBrowser = function () {
286293 // Chrome 1+
287294 // Bowser and Version set in Google's adapter
288295 webrtcDetectedType = 'webkit' ;
289- } else if ( ( webrtcDetectedBrowser === 'chrome' || webrtcDetectedBrowser === 'opera' ) &&
296+ } else if ( ( webrtcDetectedBrowser === 'chrome' || webrtcDetectedBrowser === 'opera' ) &&
290297 ! ! window . CSS ) {
291298 // Blink engine detection
292299 webrtcDetectedBrowser = 'blink' ;
293300 // TODO: detected WebRTC version
294301 }
295-
302+ if ( ( navigator . userAgent . match ( / a n d r o i d / ig) || [ ] ) . length === 0 &&
303+ ( navigator . userAgent . match ( / c h r o m e / ig) || [ ] ) . length === 0 &&
304+ navigator . userAgent . indexOf ( 'Safari/' ) > 0 ) {
305+ webrtcDetectedBrowser = 'safari' ;
306+ webrtcDetectedVersion = parseInt ( ( navigator . userAgent . match ( / V e r s i o n \/ ( .* ) \ / ) || [ '' , '0' ] ) [ 1 ] , 10 ) ;
307+ webrtcMinimumVersion = 7 ;
308+ webrtcDetectedType = 'plugin' ;
309+ }
296310 window . webrtcDetectedBrowser = webrtcDetectedBrowser ;
297311 window . webrtcDetectedVersion = webrtcDetectedVersion ;
298312 window . webrtcMinimumVersion = webrtcMinimumVersion ;
@@ -364,6 +378,7 @@ AdapterJS.renderNotificationBar = function (text, buttonText, buttonLink, openNe
364378 AdapterJS . WebRTCPlugin . isPluginInstalled (
365379 AdapterJS . WebRTCPlugin . pluginInfo . prefix ,
366380 AdapterJS . WebRTCPlugin . pluginInfo . plugName ,
381+ AdapterJS . WebRTCPlugin . pluginInfo . type ,
367382 function ( ) { // plugin now installed
368383 clearInterval ( pluginInstallInterval ) ;
369384 AdapterJS . WebRTCPlugin . defineWebRTCInterface ( ) ;
@@ -551,10 +566,12 @@ webrtcDetectedVersion = null;
551566webrtcMinimumVersion = null ;
552567
553568// Check for browser types and react accordingly
554- if ( navigator . mozGetUserMedia ||
555- navigator . webkitGetUserMedia ||
556- ( navigator . mediaDevices &&
557- navigator . userAgent . match ( / E d g e \/ ( \d + ) .( \d + ) $ / ) ) ) {
569+ if ( ( navigator . mozGetUserMedia ||
570+ navigator . webkitGetUserMedia ||
571+ ( navigator . mediaDevices &&
572+ navigator . userAgent . match ( / E d g e \/ ( \d + ) .( \d + ) $ / ) ) )
573+ && ! ( ( navigator . userAgent . match ( / a n d r o i d / ig) || [ ] ) . length === 0 &&
574+ ( navigator . userAgent . match ( / c h r o m e / ig) || [ ] ) . length === 0 && navigator . userAgent . indexOf ( 'Safari/' ) > 0 ) ) {
558575
559576 ///////////////////////////////////////////////////////////////////
560577 // INJECTION OF GOOGLE'S ADAPTER.JS CONTENT
@@ -2433,9 +2450,21 @@ if ( navigator.mozGetUserMedia ||
24332450 // Need to override attachMediaStream and reattachMediaStream
24342451 // to support the plugin's logic
24352452 attachMediaStream_base = attachMediaStream ;
2453+
2454+ if ( webrtcDetectedBrowser === 'opera' ) {
2455+ attachMediaStream_base = function ( element , stream ) {
2456+ if ( webrtcDetectedVersion > 38 ) {
2457+ element . srcObject = stream ;
2458+ } else if ( typeof element . src !== 'undefined' ) {
2459+ element . src = URL . createObjectURL ( stream ) ;
2460+ }
2461+ // Else it doesn't work
2462+ } ;
2463+ }
2464+
24362465 attachMediaStream = function ( element , stream ) {
24372466 if ( ( webrtcDetectedBrowser === 'chrome' ||
2438- webrtcDetectedBrowser === 'opera' ) &&
2467+ webrtcDetectedBrowser === 'opera' ) &&
24392468 ! stream ) {
24402469 // Chrome does not support "src = null"
24412470 element . src = '' ;
@@ -2615,11 +2644,11 @@ if ( navigator.mozGetUserMedia ||
26152644 } ;
26162645
26172646 AdapterJS . WebRTCPlugin . isPluginInstalled =
2618- function ( comName , plugName , installedCb , notInstalledCb ) {
2647+ function ( comName , plugName , plugType , installedCb , notInstalledCb ) {
26192648 if ( ! isIE ) {
2620- var pluginArray = navigator . plugins ;
2649+ var pluginArray = navigator . mimeTypes ;
26212650 for ( var i = 0 ; i < pluginArray . length ; i ++ ) {
2622- if ( pluginArray [ i ] . name . indexOf ( plugName ) >= 0 ) {
2651+ if ( pluginArray [ i ] . type . indexOf ( plugType ) >= 0 ) {
26232652 installedCb ( ) ;
26242653 return ;
26252654 }
@@ -2694,11 +2723,11 @@ if ( navigator.mozGetUserMedia ||
26942723 if ( typeof constraints !== 'undefined' && constraints !== null ) {
26952724 var invalidConstraits = false ;
26962725 invalidConstraits |= typeof constraints !== 'object' ;
2697- invalidConstraits |= constraints . hasOwnProperty ( 'mandatory' ) &&
2698- constraints . mandatory !== undefined &&
2699- constraints . mandatory !== null &&
2726+ invalidConstraits |= constraints . hasOwnProperty ( 'mandatory' ) &&
2727+ constraints . mandatory !== undefined &&
2728+ constraints . mandatory !== null &&
27002729 constraints . mandatory . constructor !== Object ;
2701- invalidConstraits |= constraints . hasOwnProperty ( 'optional' ) &&
2730+ invalidConstraits |= constraints . hasOwnProperty ( 'optional' ) &&
27022731 constraints . optional !== undefined &&
27032732 constraints . optional !== null &&
27042733 ! Array . isArray ( constraints . optional ) ;
@@ -2743,20 +2772,76 @@ if ( navigator.mozGetUserMedia ||
27432772 }
27442773 } ;
27452774
2746- MediaStreamTrack = { } ;
2775+ MediaStreamTrack = function ( ) { } ;
27472776 MediaStreamTrack . getSources = function ( callback ) {
27482777 AdapterJS . WebRTCPlugin . callWhenPluginReady ( function ( ) {
27492778 AdapterJS . WebRTCPlugin . plugin . GetSources ( callback ) ;
27502779 } ) ;
27512780 } ;
27522781
2782+ // getUserMedia constraints shim.
2783+ // Copied from Chrome
2784+ var constraintsToPlugin = function ( c ) {
2785+ if ( typeof c !== 'object' || c . mandatory || c . optional ) {
2786+ return c ;
2787+ }
2788+ var cc = { } ;
2789+ Object . keys ( c ) . forEach ( function ( key ) {
2790+ if ( key === 'require' || key === 'advanced' || key === 'mediaSource' ) {
2791+ return ;
2792+ }
2793+ var r = ( typeof c [ key ] === 'object' ) ? c [ key ] : { ideal : c [ key ] } ;
2794+ if ( r . exact !== undefined && typeof r . exact === 'number' ) {
2795+ r . min = r . max = r . exact ;
2796+ }
2797+ var oldname = function ( prefix , name ) {
2798+ if ( prefix ) {
2799+ return prefix + name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) ;
2800+ }
2801+ return ( name === 'deviceId' ) ? 'sourceId' : name ;
2802+ } ;
2803+ if ( r . ideal !== undefined ) {
2804+ cc . optional = cc . optional || [ ] ;
2805+ var oc = { } ;
2806+ if ( typeof r . ideal === 'number' ) {
2807+ oc [ oldname ( 'min' , key ) ] = r . ideal ;
2808+ cc . optional . push ( oc ) ;
2809+ oc = { } ;
2810+ oc [ oldname ( 'max' , key ) ] = r . ideal ;
2811+ cc . optional . push ( oc ) ;
2812+ } else {
2813+ oc [ oldname ( '' , key ) ] = r . ideal ;
2814+ cc . optional . push ( oc ) ;
2815+ }
2816+ }
2817+ if ( r . exact !== undefined && typeof r . exact !== 'number' ) {
2818+ cc . mandatory = cc . mandatory || { } ;
2819+ cc . mandatory [ oldname ( '' , key ) ] = r . exact ;
2820+ } else {
2821+ [ 'min' , 'max' ] . forEach ( function ( mix ) {
2822+ if ( r [ mix ] !== undefined ) {
2823+ cc . mandatory = cc . mandatory || { } ;
2824+ cc . mandatory [ oldname ( mix , key ) ] = r [ mix ] ;
2825+ }
2826+ } ) ;
2827+ }
2828+ } ) ;
2829+ if ( c . advanced ) {
2830+ cc . optional = ( cc . optional || [ ] ) . concat ( c . advanced ) ;
2831+ }
2832+ return cc ;
2833+ } ;
2834+
27532835 getUserMedia = function ( constraints , successCallback , failureCallback ) {
2754- constraints . audio = constraints . audio || false ;
2755- constraints . video = constraints . video || false ;
2836+ var cc = { } ;
2837+ cc . audio = constraints . audio ?
2838+ constraintsToPlugin ( constraints . audio ) : false ;
2839+ cc . video = constraints . video ?
2840+ constraintsToPlugin ( constraints . video ) : false ;
27562841
27572842 AdapterJS . WebRTCPlugin . callWhenPluginReady ( function ( ) {
27582843 AdapterJS . WebRTCPlugin . plugin .
2759- getUserMedia ( constraints , successCallback , failureCallback ) ;
2844+ getUserMedia ( cc , successCallback , failureCallback ) ;
27602845 } ) ;
27612846 } ;
27622847 window . navigator . getUserMedia = getUserMedia ;
@@ -2902,7 +2987,7 @@ if ( navigator.mozGetUserMedia ||
29022987 propName = properties [ prop ] ;
29032988
29042989 if ( typeof propName . slice === 'function' &&
2905- propName . slice ( 0 , 2 ) === 'on' &&
2990+ propName . slice ( 0 , 2 ) === 'on' &&
29062991 typeof srcElem [ propName ] === 'function' ) {
29072992 AdapterJS . addEvent ( destElem , propName . slice ( 2 ) , srcElem [ propName ] ) ;
29082993 }
@@ -2964,10 +3049,12 @@ if ( navigator.mozGetUserMedia ||
29643049 }
29653050 } ;
29663051
3052+
29673053 // Try to detect the plugin and act accordingly
29683054 AdapterJS . WebRTCPlugin . isPluginInstalled (
29693055 AdapterJS . WebRTCPlugin . pluginInfo . prefix ,
29703056 AdapterJS . WebRTCPlugin . pluginInfo . plugName ,
3057+ AdapterJS . WebRTCPlugin . pluginInfo . type ,
29713058 AdapterJS . WebRTCPlugin . defineWebRTCInterface ,
29723059 AdapterJS . WebRTCPlugin . pluginNeededButNotInstalledCb ) ;
29733060
0 commit comments