|
|
@@ -16,20 +16,29 @@ var switchInProgress = false;
|
|
16
|
16
|
*/
|
|
17
|
17
|
var obtainDesktopStream = null;
|
|
18
|
18
|
|
|
|
19
|
+/**
|
|
|
20
|
+ * Flag used to cache desktop sharing enabled state. Do not use directly as it can be <tt>null</tt>.
|
|
|
21
|
+ * @type {null|boolean}
|
|
|
22
|
+ */
|
|
|
23
|
+var _desktopSharingEnabled = null;
|
|
|
24
|
+
|
|
19
|
25
|
/**
|
|
20
|
26
|
* @returns {boolean} <tt>true</tt> if desktop sharing feature is available and enabled.
|
|
21
|
27
|
*/
|
|
22
|
28
|
function isDesktopSharingEnabled() {
|
|
23
|
|
- if(obtainDesktopStream === obtainScreenFromExtension) {
|
|
24
|
|
- // Parse chrome version
|
|
25
|
|
- var userAgent = navigator.userAgent.toLowerCase();
|
|
26
|
|
- // We can assume that user agent is chrome, because it's enforced when 'ext' streaming method is set
|
|
27
|
|
- var ver = parseInt(userAgent.match(/chrome\/(\d+)\./)[1], 10);
|
|
28
|
|
- console.log("Chrome version" + userAgent, ver);
|
|
29
|
|
- return ver >= 35;
|
|
30
|
|
- } else {
|
|
31
|
|
- return obtainDesktopStream === obtainWebRTCScreen;
|
|
|
29
|
+ if(_desktopSharingEnabled === null){
|
|
|
30
|
+ if(obtainDesktopStream === obtainScreenFromExtension) {
|
|
|
31
|
+ // Parse chrome version
|
|
|
32
|
+ var userAgent = navigator.userAgent.toLowerCase();
|
|
|
33
|
+ // We can assume that user agent is chrome, because it's enforced when 'ext' streaming method is set
|
|
|
34
|
+ var ver = parseInt(userAgent.match(/chrome\/(\d+)\./)[1], 10);
|
|
|
35
|
+ console.log("Chrome version" + userAgent, ver);
|
|
|
36
|
+ _desktopSharingEnabled = ver >= 35;
|
|
|
37
|
+ } else {
|
|
|
38
|
+ _desktopSharingEnabled = obtainDesktopStream === obtainWebRTCScreen;
|
|
|
39
|
+ }
|
|
32
|
40
|
}
|
|
|
41
|
+ return _desktopSharingEnabled;
|
|
33
|
42
|
}
|
|
34
|
43
|
|
|
35
|
44
|
/**
|
|
|
@@ -39,21 +48,21 @@ function isDesktopSharingEnabled() {
|
|
39
|
48
|
* must be enabled), pass any other string or nothing in order to disable this feature completely.
|
|
40
|
49
|
*/
|
|
41
|
50
|
function setDesktopSharing(method) {
|
|
42
|
|
- if(method == "ext") {
|
|
43
|
|
- if(RTC.browser === 'chrome') {
|
|
44
|
|
- obtainDesktopStream = obtainScreenFromExtension;
|
|
45
|
|
- console.info("Using Chrome extension for desktop sharing");
|
|
46
|
|
- } else {
|
|
47
|
|
- console.error("Chrome is required to use extension method");
|
|
48
|
|
- obtainDesktopStream = null;
|
|
49
|
|
- }
|
|
50
|
|
- } else if(method == "webrtc") {
|
|
51
|
|
- obtainDesktopStream = obtainWebRTCScreen;
|
|
52
|
|
- console.info("Using WebRTC for desktop sharing");
|
|
53
|
|
- } else {
|
|
|
51
|
+ // Check if we are running chrome
|
|
|
52
|
+ if(!navigator.webkitGetUserMedia){
|
|
54
|
53
|
obtainDesktopStream = null;
|
|
55
|
54
|
console.info("Desktop sharing disabled");
|
|
|
55
|
+ } else if(method == "ext") {
|
|
|
56
|
+ obtainDesktopStream = obtainScreenFromExtension;
|
|
|
57
|
+ console.info("Using Chrome extension for desktop sharing");
|
|
|
58
|
+ } else if(method == "webrtc") {
|
|
|
59
|
+ obtainDesktopStream = obtainWebRTCScreen;
|
|
|
60
|
+ console.info("Using Chrome WebRTC for desktop sharing");
|
|
56
|
61
|
}
|
|
|
62
|
+
|
|
|
63
|
+ // Reset enabled cache
|
|
|
64
|
+ _desktopSharingEnabled = null;
|
|
|
65
|
+
|
|
57
|
66
|
showDesktopSharingButton();
|
|
58
|
67
|
}
|
|
59
|
68
|
|