|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-/*! adapterjs - custom version from - 2015-08-12 */
|
|
|
1
|
+/*! adapterjs - custom version from - 2015-08-18 */
|
|
2
|
2
|
|
|
3
|
3
|
// Adapter's interface.
|
|
4
|
4
|
var AdapterJS = AdapterJS || {};
|
|
|
@@ -17,7 +17,7 @@ AdapterJS.options = AdapterJS.options || {};
|
|
17
|
17
|
// AdapterJS.options.hidePluginInstallPrompt = true;
|
|
18
|
18
|
|
|
19
|
19
|
// AdapterJS version
|
|
20
|
|
-AdapterJS.VERSION = '0.11.1';
|
|
|
20
|
+AdapterJS.VERSION = '0.12.0';
|
|
21
|
21
|
|
|
22
|
22
|
// This function will be called when the WebRTC API is ready to be used
|
|
23
|
23
|
// Whether it is the native implementation (Chrome, Firefox, Opera) or
|
|
|
@@ -72,6 +72,12 @@ else if(!!navigator.platform.match(/^Win/i)) {
|
|
72
|
72
|
AdapterJS.WebRTCPlugin.pluginInfo.downloadLink = 'http://bit.ly/1kkS4FN';
|
|
73
|
73
|
}
|
|
74
|
74
|
|
|
|
75
|
+AdapterJS.WebRTCPlugin.TAGS = {
|
|
|
76
|
+ NONE : 'none',
|
|
|
77
|
+ AUDIO : 'audio',
|
|
|
78
|
+ VIDEO : 'video'
|
|
|
79
|
+};
|
|
|
80
|
+
|
|
75
|
81
|
// Unique identifier of each opened page
|
|
76
|
82
|
AdapterJS.WebRTCPlugin.pageId = Math.random().toString(36).slice(2);
|
|
77
|
83
|
|
|
|
@@ -341,23 +347,24 @@ AdapterJS.renderNotificationBar = function (text, buttonText, buttonLink, openNe
|
|
341
|
347
|
event.cancelBubble = true;
|
|
342
|
348
|
} catch(error) { }
|
|
343
|
349
|
|
|
344
|
|
- var pluginInstallInterval = setInterval(function(){
|
|
345
|
|
- if(! isIE) {
|
|
346
|
|
- navigator.plugins.refresh(false);
|
|
347
|
|
- }
|
|
348
|
|
- AdapterJS.WebRTCPlugin.isPluginInstalled(
|
|
349
|
|
- AdapterJS.WebRTCPlugin.pluginInfo.prefix,
|
|
350
|
|
- AdapterJS.WebRTCPlugin.pluginInfo.plugName,
|
|
351
|
|
- function() {
|
|
352
|
|
- clearInterval(pluginInstallInterval);
|
|
353
|
|
- AdapterJS.WebRTCPlugin.defineWebRTCInterface();
|
|
354
|
|
- },
|
|
355
|
|
- function() { //Does nothing because not used here
|
|
356
|
|
- });
|
|
357
|
|
- } , 500);
|
|
|
350
|
+ var pluginInstallInterval = setInterval(function(){
|
|
|
351
|
+ if(! isIE) {
|
|
|
352
|
+ navigator.plugins.refresh(false);
|
|
|
353
|
+ }
|
|
|
354
|
+ AdapterJS.WebRTCPlugin.isPluginInstalled(
|
|
|
355
|
+ AdapterJS.WebRTCPlugin.pluginInfo.prefix,
|
|
|
356
|
+ AdapterJS.WebRTCPlugin.pluginInfo.plugName,
|
|
|
357
|
+ AdapterJS.WebRTCPlugin.defineWebRTCInterface,
|
|
|
358
|
+ function() {
|
|
|
359
|
+ clearInterval(pluginInstallInterval);
|
|
|
360
|
+ AdapterJS.WebRTCPlugin.defineWebRTCInterface();
|
|
|
361
|
+ },
|
|
|
362
|
+ function() {
|
|
|
363
|
+ //Does nothing because not used here
|
|
|
364
|
+ });
|
|
|
365
|
+ } , 500);
|
|
358
|
366
|
});
|
|
359
|
|
-
|
|
360
|
|
- }else {
|
|
|
367
|
+ } else {
|
|
361
|
368
|
c.document.close();
|
|
362
|
369
|
}
|
|
363
|
370
|
AdapterJS.addEvent(c.document, 'click', function() {
|
|
|
@@ -809,8 +816,8 @@ if (navigator.mozGetUserMedia) {
|
|
809
|
816
|
AdapterJS.WebRTCPlugin.pluginInfo.pluginId + '" /> ' +
|
|
810
|
817
|
'<param name="windowless" value="false" /> ' +
|
|
811
|
818
|
'<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> ' +
|
|
812
|
|
- '<param name="onload" value="' + AdapterJS.WebRTCPlugin.pluginInfo.onload +
|
|
813
|
|
- '" />' +
|
|
|
819
|
+ '<param name="onload" value="' + AdapterJS.WebRTCPlugin.pluginInfo.onload + '" />' +
|
|
|
820
|
+ '<param name="tag" value="' + AdapterJS.WebRTCPlugin.TAGS.NONE + '" />' +
|
|
814
|
821
|
// uncomment to be able to use virtual cams
|
|
815
|
822
|
(AdapterJS.options.getAllCams ? '<param name="forceGetAllCams" value="True" />':'') +
|
|
816
|
823
|
|
|
|
@@ -844,7 +851,8 @@ if (navigator.mozGetUserMedia) {
|
|
844
|
851
|
AdapterJS.WebRTCPlugin.pluginInfo.pluginId + '">' +
|
|
845
|
852
|
'<param name="windowless" value="false" /> ' +
|
|
846
|
853
|
(AdapterJS.options.getAllCams ? '<param name="forceGetAllCams" value="True" />':'') +
|
|
847
|
|
- '<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '">';
|
|
|
854
|
+ '<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '">' +
|
|
|
855
|
+ '<param name="tag" value="' + AdapterJS.WebRTCPlugin.TAGS.NONE + '" />';
|
|
848
|
856
|
document.body.appendChild(AdapterJS.WebRTCPlugin.plugin);
|
|
849
|
857
|
}
|
|
850
|
858
|
|
|
|
@@ -971,78 +979,88 @@ if (navigator.mozGetUserMedia) {
|
|
971
|
979
|
streamId = '';
|
|
972
|
980
|
}
|
|
973
|
981
|
else {
|
|
974
|
|
- stream.enableSoundTracks(true);
|
|
|
982
|
+ stream.enableSoundTracks(true); // TODO: remove on 0.12.0
|
|
975
|
983
|
streamId = stream.id;
|
|
976
|
984
|
}
|
|
977
|
985
|
|
|
978
|
|
- if (element.nodeName.toLowerCase() !== 'audio') {
|
|
979
|
|
- var elementId = element.id.length === 0 ? Math.random().toString(36).slice(2) : element.id;
|
|
980
|
|
- if (!element.isWebRTCPlugin || !element.isWebRTCPlugin()) {
|
|
981
|
|
- var frag = document.createDocumentFragment();
|
|
982
|
|
- var temp = document.createElement('div');
|
|
983
|
|
- var classHTML = '';
|
|
984
|
|
- if (element.className) {
|
|
985
|
|
- classHTML = 'class="' + element.className + '" ';
|
|
986
|
|
- } else if (element.attributes && element.attributes['class']) {
|
|
987
|
|
- classHTML = 'class="' + element.attributes['class'].value + '" ';
|
|
|
986
|
+ var elementId = element.id.length === 0 ? Math.random().toString(36).slice(2) : element.id;
|
|
|
987
|
+ if (!element.isWebRTCPlugin || !element.isWebRTCPlugin()) {
|
|
|
988
|
+ var tag;
|
|
|
989
|
+ switch(element.nodeName.toLowerCase()) {
|
|
|
990
|
+ case 'audio':
|
|
|
991
|
+ tag = AdapterJS.WebRTCPlugin.TAGS.AUDIO;
|
|
|
992
|
+ break;
|
|
|
993
|
+ case 'video':
|
|
|
994
|
+ tag = AdapterJS.WebRTCPlugin.TAGS.VIDEO;
|
|
|
995
|
+ break;
|
|
|
996
|
+ default:
|
|
|
997
|
+ tag = AdapterJS.WebRTCPlugin.TAGS.NONE;
|
|
988
|
998
|
}
|
|
989
|
999
|
|
|
990
|
|
- temp.innerHTML = '<object id="' + elementId + '" ' + classHTML +
|
|
991
|
|
- 'type="' + AdapterJS.WebRTCPlugin.pluginInfo.type + '">' +
|
|
992
|
|
- '<param name="pluginId" value="' + elementId + '" /> ' +
|
|
993
|
|
- '<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> ' +
|
|
994
|
|
- '<param name="windowless" value="true" /> ' +
|
|
995
|
|
- '<param name="streamId" value="' + streamId + '" /> ' +
|
|
996
|
|
- '</object>';
|
|
997
|
|
- while (temp.firstChild) {
|
|
998
|
|
- frag.appendChild(temp.firstChild);
|
|
999
|
|
- }
|
|
|
1000
|
+ var frag = document.createDocumentFragment();
|
|
|
1001
|
+ var temp = document.createElement('div');
|
|
|
1002
|
+ var classHTML = '';
|
|
|
1003
|
+ if (element.className) {
|
|
|
1004
|
+ classHTML = 'class="' + element.className + '" ';
|
|
|
1005
|
+ } else if (element.attributes && element.attributes['class']) {
|
|
|
1006
|
+ classHTML = 'class="' + element.attributes['class'].value + '" ';
|
|
|
1007
|
+ }
|
|
1000
|
1008
|
|
|
1001
|
|
- var height = '';
|
|
1002
|
|
- var width = '';
|
|
1003
|
|
- if (element.getBoundingClientRect) {
|
|
1004
|
|
- var rectObject = element.getBoundingClientRect();
|
|
1005
|
|
- width = rectObject.width + 'px';
|
|
1006
|
|
- height = rectObject.height + 'px';
|
|
1007
|
|
- }
|
|
1008
|
|
- else if (element.width) {
|
|
1009
|
|
- width = element.width;
|
|
1010
|
|
- height = element.height;
|
|
1011
|
|
- } else {
|
|
1012
|
|
- // TODO: What scenario could bring us here?
|
|
1013
|
|
- }
|
|
|
1009
|
+ temp.innerHTML = '<object id="' + elementId + '" ' + classHTML +
|
|
|
1010
|
+ 'type="' + AdapterJS.WebRTCPlugin.pluginInfo.type + '">' +
|
|
|
1011
|
+ '<param name="pluginId" value="' + elementId + '" /> ' +
|
|
|
1012
|
+ '<param name="pageId" value="' + AdapterJS.WebRTCPlugin.pageId + '" /> ' +
|
|
|
1013
|
+ '<param name="windowless" value="true" /> ' +
|
|
|
1014
|
+ '<param name="streamId" value="' + streamId + '" /> ' +
|
|
|
1015
|
+ '<param name="tag" value="' + tag + '" /> ' +
|
|
|
1016
|
+ '</object>';
|
|
|
1017
|
+ while (temp.firstChild) {
|
|
|
1018
|
+ frag.appendChild(temp.firstChild);
|
|
|
1019
|
+ }
|
|
1014
|
1020
|
|
|
1015
|
|
- element.parentNode.insertBefore(frag, element);
|
|
1016
|
|
- frag = document.getElementById(elementId);
|
|
1017
|
|
- frag.width = width;
|
|
1018
|
|
- frag.height = height;
|
|
1019
|
|
- element.parentNode.removeChild(element);
|
|
|
1021
|
+ var height = '';
|
|
|
1022
|
+ var width = '';
|
|
|
1023
|
+ if (element.getBoundingClientRect) {
|
|
|
1024
|
+ var rectObject = element.getBoundingClientRect();
|
|
|
1025
|
+ width = rectObject.width + 'px';
|
|
|
1026
|
+ height = rectObject.height + 'px';
|
|
|
1027
|
+ }
|
|
|
1028
|
+ else if (element.width) {
|
|
|
1029
|
+ width = element.width;
|
|
|
1030
|
+ height = element.height;
|
|
1020
|
1031
|
} else {
|
|
1021
|
|
- var children = element.children;
|
|
1022
|
|
- for (var i = 0; i !== children.length; ++i) {
|
|
1023
|
|
- if (children[i].name === 'streamId') {
|
|
1024
|
|
- children[i].value = streamId;
|
|
1025
|
|
- break;
|
|
1026
|
|
- }
|
|
|
1032
|
+ // TODO: What scenario could bring us here?
|
|
|
1033
|
+ }
|
|
|
1034
|
+
|
|
|
1035
|
+ element.parentNode.insertBefore(frag, element);
|
|
|
1036
|
+ frag = document.getElementById(elementId);
|
|
|
1037
|
+ frag.width = width;
|
|
|
1038
|
+ frag.height = height;
|
|
|
1039
|
+ element.parentNode.removeChild(element);
|
|
|
1040
|
+ } else {
|
|
|
1041
|
+ var children = element.children;
|
|
|
1042
|
+ for (var i = 0; i !== children.length; ++i) {
|
|
|
1043
|
+ if (children[i].name === 'streamId') {
|
|
|
1044
|
+ children[i].value = streamId;
|
|
|
1045
|
+ break;
|
|
1027
|
1046
|
}
|
|
1028
|
|
- element.setStreamId(streamId);
|
|
1029
|
1047
|
}
|
|
1030
|
|
- var newElement = document.getElementById(elementId);
|
|
1031
|
|
- newElement.onplaying = (element.onplaying) ? element.onplaying : function (arg) {};
|
|
1032
|
|
- if (isIE) { // on IE the event needs to be plugged manually
|
|
1033
|
|
- newElement.attachEvent('onplaying', newElement.onplaying);
|
|
1034
|
|
- newElement.onclick = (element.onclick) ? element.onclick : function (arg) {};
|
|
1035
|
|
- newElement._TemOnClick = function (id) {
|
|
1036
|
|
- var arg = {
|
|
1037
|
|
- srcElement : document.getElementById(id)
|
|
1038
|
|
- };
|
|
1039
|
|
- newElement.onclick(arg);
|
|
|
1048
|
+ element.setStreamId(streamId);
|
|
|
1049
|
+ }
|
|
|
1050
|
+ var newElement = document.getElementById(elementId);
|
|
|
1051
|
+ newElement.onplaying = (element.onplaying) ? element.onplaying : function (arg) {};
|
|
|
1052
|
+ if (isIE) { // on IE the event needs to be plugged manually
|
|
|
1053
|
+ newElement.attachEvent('onplaying', newElement.onplaying);
|
|
|
1054
|
+ newElement.onclick = (element.onclick) ? element.onclick : function (arg) {};
|
|
|
1055
|
+ newElement._TemOnClick = function (id) {
|
|
|
1056
|
+ var arg = {
|
|
|
1057
|
+ srcElement : document.getElementById(id)
|
|
1040
|
1058
|
};
|
|
1041
|
|
- }
|
|
1042
|
|
- return newElement;
|
|
1043
|
|
- } else {
|
|
1044
|
|
- return element;
|
|
|
1059
|
+ newElement.onclick(arg);
|
|
|
1060
|
+ };
|
|
1045
|
1061
|
}
|
|
|
1062
|
+
|
|
|
1063
|
+ return newElement;
|
|
1046
|
1064
|
};
|
|
1047
|
1065
|
|
|
1048
|
1066
|
reattachMediaStream = function (to, from) {
|
|
|
@@ -1120,211 +1138,3 @@ if (navigator.mozGetUserMedia) {
|
|
1120
|
1138
|
AdapterJS.WebRTCPlugin.defineWebRTCInterface,
|
|
1121
|
1139
|
AdapterJS.WebRTCPlugin.pluginNeededButNotInstalledCb);
|
|
1122
|
1140
|
}
|
|
1123
|
|
-
|
|
1124
|
|
-
|
|
1125
|
|
-
|
|
1126
|
|
-(function () {
|
|
1127
|
|
-
|
|
1128
|
|
- 'use strict';
|
|
1129
|
|
-
|
|
1130
|
|
- var baseGetUserMedia = null;
|
|
1131
|
|
-
|
|
1132
|
|
- AdapterJS.TEXT.EXTENSION = {
|
|
1133
|
|
- REQUIRE_INSTALLATION_FF: 'To enable screensharing you need to install the Skylink WebRTC tools Firefox Add-on.',
|
|
1134
|
|
- REQUIRE_INSTALLATION_CHROME: 'To enable screensharing you need to install the Skylink WebRTC tools Chrome Extension.',
|
|
1135
|
|
- REQUIRE_REFRESH: 'Please refresh this page after the Skylink WebRTC tools extension has been installed.',
|
|
1136
|
|
- BUTTON_FF: 'Install Now',
|
|
1137
|
|
- BUTTON_CHROME: 'Go to Chrome Web Store'
|
|
1138
|
|
- };
|
|
1139
|
|
-
|
|
1140
|
|
- var clone = function(obj) {
|
|
1141
|
|
- if (null == obj || "object" != typeof obj) return obj;
|
|
1142
|
|
- var copy = obj.constructor();
|
|
1143
|
|
- for (var attr in obj) {
|
|
1144
|
|
- if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
|
|
1145
|
|
- }
|
|
1146
|
|
- return copy;
|
|
1147
|
|
- };
|
|
1148
|
|
-
|
|
1149
|
|
- if (window.navigator.mozGetUserMedia) {
|
|
1150
|
|
- baseGetUserMedia = window.navigator.getUserMedia;
|
|
1151
|
|
-
|
|
1152
|
|
- navigator.getUserMedia = function (constraints, successCb, failureCb) {
|
|
1153
|
|
-
|
|
1154
|
|
- if (constraints && constraints.video && !!constraints.video.mediaSource) {
|
|
1155
|
|
- // intercepting screensharing requests
|
|
1156
|
|
-
|
|
1157
|
|
- if (constraints.video.mediaSource !== 'screen' && constraints.video.mediaSource !== 'window') {
|
|
1158
|
|
- throw new Error('Only "screen" and "window" option is available as mediaSource');
|
|
1159
|
|
- }
|
|
1160
|
|
-
|
|
1161
|
|
- var updatedConstraints = clone(constraints);
|
|
1162
|
|
-
|
|
1163
|
|
- //constraints.video.mediaSource = constraints.video.mediaSource;
|
|
1164
|
|
- updatedConstraints.video.mozMediaSource = updatedConstraints.video.mediaSource;
|
|
1165
|
|
-
|
|
1166
|
|
- // so generally, it requires for document.readyState to be completed before the getUserMedia could be invoked.
|
|
1167
|
|
- // strange but this works anyway
|
|
1168
|
|
- var checkIfReady = setInterval(function () {
|
|
1169
|
|
- if (document.readyState === 'complete') {
|
|
1170
|
|
- clearInterval(checkIfReady);
|
|
1171
|
|
-
|
|
1172
|
|
- baseGetUserMedia(updatedConstraints, successCb, function (error) {
|
|
1173
|
|
- if (error.name === 'PermissionDeniedError' && window.parent.location.protocol === 'https:') {
|
|
1174
|
|
- AdapterJS.renderNotificationBar(AdapterJS.TEXT.EXTENSION.REQUIRE_INSTALLATION_FF,
|
|
1175
|
|
- AdapterJS.TEXT.EXTENSION.BUTTON_FF,
|
|
1176
|
|
- 'http://skylink.io/screensharing/ff_addon.php?domain=' + window.location.hostname, false, true);
|
|
1177
|
|
- //window.location.href = 'http://skylink.io/screensharing/ff_addon.php?domain=' + window.location.hostname;
|
|
1178
|
|
- } else {
|
|
1179
|
|
- failureCb(error);
|
|
1180
|
|
- }
|
|
1181
|
|
- });
|
|
1182
|
|
- }
|
|
1183
|
|
- }, 1);
|
|
1184
|
|
-
|
|
1185
|
|
- } else { // regular GetUserMediaRequest
|
|
1186
|
|
- baseGetUserMedia(constraints, successCb, failureCb);
|
|
1187
|
|
- }
|
|
1188
|
|
- };
|
|
1189
|
|
-
|
|
1190
|
|
- getUserMedia = navigator.getUserMedia;
|
|
1191
|
|
-
|
|
1192
|
|
- } else if (window.navigator.webkitGetUserMedia) {
|
|
1193
|
|
- baseGetUserMedia = window.navigator.getUserMedia;
|
|
1194
|
|
-
|
|
1195
|
|
- navigator.getUserMedia = function (constraints, successCb, failureCb) {
|
|
1196
|
|
-
|
|
1197
|
|
- if (constraints && constraints.video && !!constraints.video.mediaSource) {
|
|
1198
|
|
- if (window.webrtcDetectedBrowser !== 'chrome') {
|
|
1199
|
|
- throw new Error('Current browser does not support screensharing');
|
|
1200
|
|
- }
|
|
1201
|
|
-
|
|
1202
|
|
- // would be fine since no methods
|
|
1203
|
|
- var updatedConstraints = clone(constraints);
|
|
1204
|
|
-
|
|
1205
|
|
- var chromeCallback = function(error, sourceId) {
|
|
1206
|
|
- if(!error) {
|
|
1207
|
|
- updatedConstraints.video.mandatory = updatedConstraints.video.mandatory || {};
|
|
1208
|
|
- updatedConstraints.video.mandatory.chromeMediaSource = 'desktop';
|
|
1209
|
|
- updatedConstraints.video.mandatory.maxWidth = window.screen.width > 1920 ? window.screen.width : 1920;
|
|
1210
|
|
- updatedConstraints.video.mandatory.maxHeight = window.screen.height > 1080 ? window.screen.height : 1080;
|
|
1211
|
|
-
|
|
1212
|
|
- if (sourceId) {
|
|
1213
|
|
- updatedConstraints.video.mandatory.chromeMediaSourceId = sourceId;
|
|
1214
|
|
- }
|
|
1215
|
|
-
|
|
1216
|
|
- delete updatedConstraints.video.mediaSource;
|
|
1217
|
|
-
|
|
1218
|
|
- baseGetUserMedia(updatedConstraints, successCb, failureCb);
|
|
1219
|
|
-
|
|
1220
|
|
- } else {
|
|
1221
|
|
- if (error === 'permission-denied') {
|
|
1222
|
|
- throw new Error('Permission denied for screen retrieval');
|
|
1223
|
|
- } else {
|
|
1224
|
|
- throw new Error('Failed retrieving selected screen');
|
|
1225
|
|
- }
|
|
1226
|
|
- }
|
|
1227
|
|
- };
|
|
1228
|
|
-
|
|
1229
|
|
- var onIFrameCallback = function (event) {
|
|
1230
|
|
- if (!event.data) {
|
|
1231
|
|
- return;
|
|
1232
|
|
- }
|
|
1233
|
|
-
|
|
1234
|
|
- if (event.data.chromeMediaSourceId) {
|
|
1235
|
|
- if (event.data.chromeMediaSourceId === 'PermissionDeniedError') {
|
|
1236
|
|
- chromeCallback('permission-denied');
|
|
1237
|
|
- } else {
|
|
1238
|
|
- chromeCallback(null, event.data.chromeMediaSourceId);
|
|
1239
|
|
- }
|
|
1240
|
|
- }
|
|
1241
|
|
-
|
|
1242
|
|
- if (event.data.chromeExtensionStatus) {
|
|
1243
|
|
- if (event.data.chromeExtensionStatus === 'not-installed') {
|
|
1244
|
|
- AdapterJS.renderNotificationBar(AdapterJS.TEXT.EXTENSION.REQUIRE_INSTALLATION_CHROME,
|
|
1245
|
|
- AdapterJS.TEXT.EXTENSION.BUTTON_CHROME,
|
|
1246
|
|
- event.data.data, true, true);
|
|
1247
|
|
- } else {
|
|
1248
|
|
- chromeCallback(event.data.chromeExtensionStatus, null);
|
|
1249
|
|
- }
|
|
1250
|
|
- }
|
|
1251
|
|
-
|
|
1252
|
|
- // this event listener is no more needed
|
|
1253
|
|
- window.removeEventListener('message', onIFrameCallback);
|
|
1254
|
|
- };
|
|
1255
|
|
-
|
|
1256
|
|
- window.addEventListener('message', onIFrameCallback);
|
|
1257
|
|
-
|
|
1258
|
|
- postFrameMessage({
|
|
1259
|
|
- captureSourceId: true
|
|
1260
|
|
- });
|
|
1261
|
|
-
|
|
1262
|
|
- } else {
|
|
1263
|
|
- baseGetUserMedia(constraints, successCb, failureCb);
|
|
1264
|
|
- }
|
|
1265
|
|
- };
|
|
1266
|
|
-
|
|
1267
|
|
- getUserMedia = navigator.getUserMedia;
|
|
1268
|
|
-
|
|
1269
|
|
- } else {
|
|
1270
|
|
- baseGetUserMedia = window.navigator.getUserMedia;
|
|
1271
|
|
-
|
|
1272
|
|
- navigator.getUserMedia = function (constraints, successCb, failureCb) {
|
|
1273
|
|
- if (constraints && constraints.video && !!constraints.video.mediaSource) {
|
|
1274
|
|
- // would be fine since no methods
|
|
1275
|
|
- var updatedConstraints = clone(constraints);
|
|
1276
|
|
-
|
|
1277
|
|
- // wait for plugin to be ready
|
|
1278
|
|
- AdapterJS.WebRTCPlugin.callWhenPluginReady(function() {
|
|
1279
|
|
- // check if screensharing feature is available
|
|
1280
|
|
- if (!!AdapterJS.WebRTCPlugin.plugin.HasScreensharingFeature &&
|
|
1281
|
|
- !!AdapterJS.WebRTCPlugin.plugin.isScreensharingAvailable) {
|
|
1282
|
|
-
|
|
1283
|
|
-
|
|
1284
|
|
- // set the constraints
|
|
1285
|
|
- updatedConstraints.video.optional = updatedConstraints.video.optional || [];
|
|
1286
|
|
- updatedConstraints.video.optional.push({
|
|
1287
|
|
- sourceId: AdapterJS.WebRTCPlugin.plugin.screensharingKey || 'Screensharing'
|
|
1288
|
|
- });
|
|
1289
|
|
-
|
|
1290
|
|
- delete updatedConstraints.video.mediaSource;
|
|
1291
|
|
- } else {
|
|
1292
|
|
- throw new Error('Your WebRTC plugin does not support screensharing');
|
|
1293
|
|
- }
|
|
1294
|
|
- baseGetUserMedia(updatedConstraints, successCb, failureCb);
|
|
1295
|
|
- });
|
|
1296
|
|
- } else {
|
|
1297
|
|
- baseGetUserMedia(constraints, successCb, failureCb);
|
|
1298
|
|
- }
|
|
1299
|
|
- };
|
|
1300
|
|
-
|
|
1301
|
|
- getUserMedia = window.navigator.getUserMedia;
|
|
1302
|
|
- }
|
|
1303
|
|
-
|
|
1304
|
|
- if (window.webrtcDetectedBrowser === 'chrome') {
|
|
1305
|
|
- var iframe = document.createElement('iframe');
|
|
1306
|
|
-
|
|
1307
|
|
- iframe.onload = function() {
|
|
1308
|
|
- iframe.isLoaded = true;
|
|
1309
|
|
- };
|
|
1310
|
|
-
|
|
1311
|
|
- iframe.src = 'https://cdn.temasys.com.sg/skylink/extensions/detectRTC.html';
|
|
1312
|
|
- //'https://temasys-cdn.s3.amazonaws.com/skylink/extensions/detection-script-dev/detectRTC.html';
|
|
1313
|
|
- iframe.style.display = 'none';
|
|
1314
|
|
-
|
|
1315
|
|
- (document.body || document.documentElement).appendChild(iframe);
|
|
1316
|
|
-
|
|
1317
|
|
- var postFrameMessage = function (object) {
|
|
1318
|
|
- object = object || {};
|
|
1319
|
|
-
|
|
1320
|
|
- if (!iframe.isLoaded) {
|
|
1321
|
|
- setTimeout(function () {
|
|
1322
|
|
- iframe.contentWindow.postMessage(object, '*');
|
|
1323
|
|
- }, 100);
|
|
1324
|
|
- return;
|
|
1325
|
|
- }
|
|
1326
|
|
-
|
|
1327
|
|
- iframe.contentWindow.postMessage(object, '*');
|
|
1328
|
|
- };
|
|
1329
|
|
- }
|
|
1330
|
|
-})();
|