diff --git a/chrome-extension/background.js b/chrome-extension/background.js new file mode 100644 index 0000000..b5cee2b --- /dev/null +++ b/chrome-extension/background.js @@ -0,0 +1,25 @@ +/* background page, responsible for actually choosing media */ +chrome.runtime.onConnect.addListener(function (channel) { + channel.onMessage.addListener(function (message) { + switch(message.type) { + case 'getScreen': + var pending = chrome.desktopCapture.chooseDesktopMedia(message.options || ['screen', 'window'], + channel.sender.tab, function (streamid) { + // communicate this string to the app so it can call getUserMedia with it + message.type = 'gotScreen'; + message.sourceId = streamid; + channel.postMessage(message); + }); + // let the app know that it can cancel the timeout + message.type = 'getScreenPending'; + message.request = pending; + channel.postMessage(message); + break; + case 'cancelGetScreen': + chrome.desktopCapture.cancelChooseDesktopMedia(message.request); + message.type = 'canceledGetScreen'; + channel.postMessage(message); + break; + } + }); +}); diff --git a/chrome-extension/content.js b/chrome-extension/content.js new file mode 100644 index 0000000..009df3d --- /dev/null +++ b/chrome-extension/content.js @@ -0,0 +1,14 @@ +/* the chrome content script which can listen to the page dom events */ +var channel = chrome.runtime.connect(); +channel.onMessage.addListener(function (message) { + console.log('channel message', message); + window.postMessage(message, '*'); +}); + +window.addEventListener('message', function (event) { + if (event.source != window) + return; + if (!event.data && (event.data.type == 'getScreen' || event.data.type == 'cancelGetScreen')) + return; + channel.postMessage(event.data); +}); diff --git a/chrome-extension/manifest.json b/chrome-extension/manifest.json new file mode 100644 index 0000000..0b6a381 --- /dev/null +++ b/chrome-extension/manifest.json @@ -0,0 +1,19 @@ +{ + "name": "Screen sharing for VROOM", + "description": "Allow screen sharing in the VROOM WebRTC visio conference app", + "version": "0.0.1", + "manifest_version": 2, + "minimum_chrome_version": "34", + "icons": { + }, + "permissions": [ + "desktopCapture" + ], + "background": { + "scripts": ["background.js"] + }, + "content_scripts": [ { + "js": [ "content.js" ], + "matches": ["https://*/*"] + }] +} diff --git a/conf/vroom.conf.sample b/conf/vroom.conf.sample index 57dc21b..1ef72b0 100644 --- a/conf/vroom.conf.sample +++ b/conf/vroom.conf.sample @@ -24,6 +24,9 @@ secret => 'ChangeMe!', inactivityTimeout => 3600, logLevel => 'info', +# ID of the Chrome extension for screen sharing +chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn', + # Various sendmail => '/sbin/sendmail' }; diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index b0608e5..16dafdb 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -49,6 +49,9 @@ our %Lexicon = ( "CAM_RESUMED" => "Your webcam is on again", "SHARE_YOUR_SCREEN" => "Share your screen with the other members of this room", "CANT_SHARE_SCREEN" => "Sorry, your configuration does not allow screen sharing", + "SCREEN_SHARING_ONLY_FOR_CHROME" => "Sorry, but you can't share your screen. Only Google Chrome supports this feature for now", + "SCREEN_SHARING_CANCELLED" => "Screen sharing has been cancelled", + "VROOM_CHROME_EXTENSION" => "To enable screen sharing, you need to install an extension. Click on the following link and refresh this page", "EVERYONE_CAN_SEE_YOUR_SCREEN" => "All other participants can see your screen now", "SCREEN_UNSHARED" => "You do no longer share your screen", "ERROR_MAIL_INVALID" => "Please enter a valid email address", @@ -79,6 +82,7 @@ our %Lexicon = ( "SCREEN_SHARING" => "Screen Sharing", "HELP_SCREEN_SHARING" => "VROOM lets you share your screen with the other members of the room. For now " . "this feature is only available in Google Chrome, and you need to change the following setting " . + "(since version 34, this setting isn't needed anymore)" . "