|
|
|
|
@ -23,22 +23,32 @@ define(['underscore', 'webrtc.adapter'], function(_) {
@@ -23,22 +23,32 @@ define(['underscore', 'webrtc.adapter'], function(_) {
|
|
|
|
|
// screensharing
|
|
|
|
|
return ["$window", "$q", "chromeExtension", function($window, $q, chromeExtension) { |
|
|
|
|
|
|
|
|
|
var Screensharing = function() { |
|
|
|
|
this.initialize(); |
|
|
|
|
chromeExtension.e.on("available", _.bind(function() { |
|
|
|
|
this.initialize(); |
|
|
|
|
}, this)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Screensharing.prototype.initialize = function() { |
|
|
|
|
|
|
|
|
|
// Check if we can do screensharing.
|
|
|
|
|
var supported = false; |
|
|
|
|
this.supported = false; |
|
|
|
|
|
|
|
|
|
// Define our helpers.
|
|
|
|
|
var prepare = null; |
|
|
|
|
var cancel = null; |
|
|
|
|
this.prepare = null; |
|
|
|
|
this.cancel = null; |
|
|
|
|
|
|
|
|
|
// Chrome support.
|
|
|
|
|
if ($window.webrtcDetectedBrowser === "chrome") { |
|
|
|
|
|
|
|
|
|
if ($window.webrtcDetectedVersion >= 32 && |
|
|
|
|
$window.webrtcDetectedVersion < 37) { |
|
|
|
|
// Support for flag based developer screen sharing came in Chrome 32.
|
|
|
|
|
// It was removed in Chrome 37 in favour of chrome.chooseDesktopMedia
|
|
|
|
|
// https://code.google.com/p/chromium/issues/detail?id=347641
|
|
|
|
|
supported = true; |
|
|
|
|
prepare = function(options) { |
|
|
|
|
this.supported = true; |
|
|
|
|
this.prepare = function(options) { |
|
|
|
|
// This generates constrains for the flag based screen screensharing
|
|
|
|
|
// support in Chrome 31+ to 36. Flag to be enabled is found at:
|
|
|
|
|
// chrome://flags/#enable-usermedia-screen-capture
|
|
|
|
|
@ -56,9 +66,9 @@ define(['underscore', 'webrtc.adapter'], function(_) {
@@ -56,9 +66,9 @@ define(['underscore', 'webrtc.adapter'], function(_) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (chromeExtension.available) { |
|
|
|
|
supported = true; |
|
|
|
|
this.supported = true; |
|
|
|
|
var pending = null; |
|
|
|
|
prepare = function(options) { |
|
|
|
|
this.prepare = function(options) { |
|
|
|
|
var select = chromeExtension.call({ |
|
|
|
|
Type: "Action", |
|
|
|
|
Action: "chooseDesktopMedia" |
|
|
|
|
@ -87,7 +97,7 @@ define(['underscore', 'webrtc.adapter'], function(_) {
@@ -87,7 +97,7 @@ define(['underscore', 'webrtc.adapter'], function(_) {
|
|
|
|
|
}); |
|
|
|
|
return d.promise; |
|
|
|
|
}; |
|
|
|
|
cancel = function() { |
|
|
|
|
this.cancel = function() { |
|
|
|
|
if (pending !== null) { |
|
|
|
|
chromeExtension.call({ |
|
|
|
|
Type: "Action", |
|
|
|
|
@ -105,24 +115,29 @@ define(['underscore', 'webrtc.adapter'], function(_) {
@@ -105,24 +115,29 @@ define(['underscore', 'webrtc.adapter'], function(_) {
|
|
|
|
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=923225
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// public API.
|
|
|
|
|
return { |
|
|
|
|
supported: supported, |
|
|
|
|
getScreen: function(options) { |
|
|
|
|
if (prepare) { |
|
|
|
|
return prepare(options); |
|
|
|
|
console.log("Screensharing support", this.supported); |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Screensharing.prototype.getScreen = function(options) { |
|
|
|
|
if (this.prepare) { |
|
|
|
|
return this.prepare(options); |
|
|
|
|
} else { |
|
|
|
|
var d = $q.defer() |
|
|
|
|
d.reject("No implementation to get screen."); |
|
|
|
|
return d.promise; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
cancelGetScreen: function() { |
|
|
|
|
if (cancel) { |
|
|
|
|
cancel(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Screensharing.prototype.cancelGetScreen = function() { |
|
|
|
|
if (this.cancel) { |
|
|
|
|
this.cancel(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Expose.
|
|
|
|
|
var screensharing = new Screensharing(); |
|
|
|
|
return screensharing; |
|
|
|
|
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|