diff --git a/erizo/src/erizo/SdpInfo.cpp b/erizo/src/erizo/SdpInfo.cpp index ce98c55976..299cf6a326 100644 --- a/erizo/src/erizo/SdpInfo.cpp +++ b/erizo/src/erizo/SdpInfo.cpp @@ -312,7 +312,7 @@ namespace erizo { if (isFingerprint) { sdp << "a=fingerprint:sha-256 "<< fingerprint << endl; } - switch (this->direction){ + switch (this->audioDirection){ case SENDONLY: sdp << "a=sendonly" << endl; break; @@ -409,7 +409,7 @@ namespace erizo { if (isFingerprint) { sdp << "a=fingerprint:sha-256 "<< fingerprint << endl; } - switch (this->direction){ + switch (this->videoDirection){ case SENDONLY: sdp << "a=sendonly" << endl; break; @@ -522,18 +522,32 @@ namespace erizo { this->hasVideo = offerSdp.hasVideo; this->hasAudio = offerSdp.hasAudio; this->bundleTags = offerSdp.bundleTags; - switch(offerSdp.direction){ + switch(offerSdp.videoDirection){ case SENDONLY: - this->direction = RECVONLY; + this->videoDirection = RECVONLY; break; case RECVONLY: - this->direction = SENDONLY; + this->videoDirection = SENDONLY; break; case SENDRECV: - this->direction = SENDRECV; + this->videoDirection = SENDRECV; break; default: - this->direction = SENDRECV; + this->videoDirection = SENDRECV; + break; + } + switch(offerSdp.audioDirection){ + case SENDONLY: + this->audioDirection = RECVONLY; + break; + case RECVONLY: + this->audioDirection = SENDONLY; + break; + case SENDRECV: + this->audioDirection = SENDRECV; + break; + default: + this->audioDirection = SENDRECV; break; } if (offerSdp.videoRtxSsrc != 0){ @@ -586,13 +600,25 @@ namespace erizo { // At this point we support only one direction per SDP // Any other combination does not make sense at this point in Licode if (isRecvOnly != std::string::npos){ - ELOG_DEBUG("RecvOnly sdp") - this->direction = RECVONLY; + ELOG_DEBUG("RecvOnly sdp") + if (mtype == AUDIO_TYPE){ + this->audioDirection = RECVONLY; + }else{ + this->videoDirection = RECVONLY; + } }else if(isSendOnly != std::string::npos){ - this->direction = SENDONLY; - ELOG_DEBUG("SendOnly sdp") + ELOG_DEBUG("SendOnly sdp") + if (mtype == AUDIO_TYPE){ + this->audioDirection = SENDONLY; + }else{ + this->videoDirection = SENDONLY; + } }else if (isSendRecv != std::string::npos){ - this->direction = SENDRECV; + if (mtype == AUDIO_TYPE){ + this->audioDirection = SENDRECV; + }else{ + this->videoDirection = SENDRECV; + } ELOG_DEBUG("SendRecv sdp") } diff --git a/erizo/src/erizo/SdpInfo.h b/erizo/src/erizo/SdpInfo.h index b466c456d2..9f1b575e4f 100644 --- a/erizo/src/erizo/SdpInfo.h +++ b/erizo/src/erizo/SdpInfo.h @@ -219,7 +219,7 @@ class SdpInfo { */ bool isRtcpMux; - StreamDirection direction; + StreamDirection videoDirection, audioDirection; /** * RTP Profile type */ diff --git a/erizo_controller/erizoClient/extras/firefox-extension/README.txt b/erizo_controller/erizoClient/extras/firefox-extension/README.txt new file mode 100644 index 0000000000..e3d9713912 --- /dev/null +++ b/erizo_controller/erizoClient/extras/firefox-extension/README.txt @@ -0,0 +1,13 @@ +Instructions to create your own Firefox Screensharing Extension: + +1. Modify bootstrap.js file, updating the variable domainsUsed with your own domains. + +2. Modify install.rdf with your own extension information + +3. Choose your icon (48x48) and name it icon.png + +4. Run createExtension.sh script to create your .xpi containing the three files. + +5. Install the .xpi file in Firefox + +6. Enjoy Firefox Screensharing with Licode! \ No newline at end of file diff --git a/erizo_controller/erizoClient/extras/firefox-extension/bootstrap.js b/erizo_controller/erizoClient/extras/firefox-extension/bootstrap.js new file mode 100644 index 0000000000..2e56c9d3f7 --- /dev/null +++ b/erizo_controller/erizoClient/extras/firefox-extension/bootstrap.js @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * The source code can be found here: HenrikJoreteg/getScreenMedia/firefox-extension-sample + */ + +var domainsUsed = ["*.dit.upm.es"]; +var addon_domains = []; +var allowed_domains = "media.getusermedia.screensharing.allowed_domains"; + +function startup(data, reason) { + if (reason === APP_STARTUP) { + return; + } + var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); + var values = prefs.getCharPref(allowed_domains).split(','); + domainsUsed.forEach(function (domain) { + if (values.indexOf(domain) === -1) { + values.push(domain); + addon_domains.push(domain); + } + }); + prefs.setCharPref(allowed_domains, values.join(',')); +} + +function shutdown(data, reason) { + if (reason === APP_SHUTDOWN) { + return; + } + var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); + var values = prefs.getCharPref(allowed_domains).split(','); + values = values.filter(function (value) { + return addon_domains.indexOf(value) === -1; + }); + prefs.setCharPref(allowed_domains, values.join(',')); +} + +function install(data, reason) {} + +function uninstall(data, reason) {} \ No newline at end of file diff --git a/erizo_controller/erizoClient/extras/firefox-extension/createExtension.sh b/erizo_controller/erizoClient/extras/firefox-extension/createExtension.sh new file mode 100755 index 0000000000..e264f89980 --- /dev/null +++ b/erizo_controller/erizoClient/extras/firefox-extension/createExtension.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Creating FirefoxExtension.xpi..." + +zip ./FirefoxExtension.xpi icon.png bootstrap.js install.rdf + +echo "FirefoxExtension.xpi ready!" diff --git a/erizo_controller/erizoClient/extras/firefox-extension/icon.png b/erizo_controller/erizoClient/extras/firefox-extension/icon.png new file mode 100644 index 0000000000..6c44491ec0 Binary files /dev/null and b/erizo_controller/erizoClient/extras/firefox-extension/icon.png differ diff --git a/erizo_controller/erizoClient/extras/firefox-extension/install.rdf b/erizo_controller/erizoClient/extras/firefox-extension/install.rdf new file mode 100644 index 0000000000..3a8db25e35 --- /dev/null +++ b/erizo_controller/erizoClient/extras/firefox-extension/install.rdf @@ -0,0 +1,21 @@ + + + + lynckia@lynckia.com + 2 + Lynckia Screensharing + Extension to allow screen sharing in Licode applications. + 1.0 + true + Lynckia + lynckia.com/licode + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 33.0 + 100000.* + + + + diff --git a/erizo_controller/erizoClient/src/Connection.js b/erizo_controller/erizoClient/src/Connection.js index 6413c35437..0295ae0f87 100644 --- a/erizo_controller/erizoClient/src/Connection.js +++ b/erizo_controller/erizoClient/src/Connection.js @@ -65,38 +65,44 @@ Erizo.GetUserMedia = function (config, callback, error) { navigator.msGetUserMedia); if (config.screen){ - L.Logger.debug("Screen access requested"); - if (!window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1] >= 34){ - error({code:"This browser does not support screen sharing"}); - return; - } - // Default extensionId - this extension is only usable in our server, please make your own extension - // based on the code in erizo_controller/erizoClient/extras/chrome-extension - var extensionId = "okeephmleflklcdebijnponpabbmmgeo"; - if (config.extensionId){ - L.Logger.debug("extensionId supplied, using " + config.extensionId); - extensionId = config.extensionId; - } - L.Logger.debug("Screen access on chrome stable, looking for extension"); - try{ - chrome.runtime.sendMessage(extensionId,{getStream:true}, function (response){ - if (response==undefined){ - L.Logger.debug("Access to screen denied"); - var theError = {code:"Access to screen denied"}; - error(theError); - return; - } - var theId = response.streamId; - config = {video: {mandatory: {chromeMediaSource: 'desktop', chromeMediaSourceId: theId }}}; - navigator.getMedia(config,callback,error); - }); - } catch (e){ - L.Logger.debug("Lynckia screensharing plugin is not accessible "); - var theError = {code:"no_plugin_present"}; - error(theError); - return; + if (Erizo.getBrowser() === "mozilla"){ + L.Logger.debug("Screen access requested"); + config = { video: { mediaSource: 'window' || 'screen' }}; + navigator.getMedia(config,callback,error); + } else { + L.Logger.debug("Screen access requested"); + if (!window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1] >= 34){ + error({code:"This browser does not support screen sharing"}); + return; + } + // Default extensionId - this extension is only usable in our server, please make your own extension + // based on the code in erizo_controller/erizoClient/extras/chrome-extension + var extensionId = "okeephmleflklcdebijnponpabbmmgeo"; + if (config.extensionId){ + L.Logger.debug("extensionId supplied, using " + config.extensionId); + extensionId = config.extensionId; + } + L.Logger.debug("Screen access on chrome stable, looking for extension"); + try{ + chrome.runtime.sendMessage(extensionId,{getStream:true}, function (response){ + if (response==undefined){ + L.Logger.debug("Access to screen denied"); + var theError = {code:"Access to screen denied"}; + error(theError); + return; + } + var theId = response.streamId; + config = {video: {mandatory: {chromeMediaSource: 'desktop', chromeMediaSourceId: theId }}}; + navigator.getMedia(config,callback,error); + }); + } catch (e){ + L.Logger.debug("Lynckia screensharing plugin is not accessible "); + var theError = {code:"no_plugin_present"}; + error(theError); + return; + } } - }else{ + } else { if (typeof module !== 'undefined' && module.exports) { L.Logger.error('Video/audio streams not supported in erizofc yet'); } else { diff --git a/erizo_controller/erizoClient/src/webrtc-stacks/FirefoxStack.js b/erizo_controller/erizoClient/src/webrtc-stacks/FirefoxStack.js index 0b964adb0f..acfa769879 100644 --- a/erizo_controller/erizoClient/src/webrtc-stacks/FirefoxStack.js +++ b/erizo_controller/erizoClient/src/webrtc-stacks/FirefoxStack.js @@ -103,10 +103,23 @@ Erizo.FirefoxStack = function (spec) { var setLocalDesc = function (sessionDescription) { sessionDescription.sdp = setMaxBW(sessionDescription.sdp); sessionDescription.sdp = sessionDescription.sdp.replace(/a=ice-options:google-ice\r\n/g, ""); + sessionDescription = changeOrder(sessionDescription); spec.callback(sessionDescription); localDesc = sessionDescription; } + var changeOrder = function(sessionDescription) { + var matches = sessionDescription.sdp.match(/^.*(rtcp-fb).*$/gm); + var lines = ""; + for (var i in matches){ + if (i == 0) lines += matches[i]; + else lines += "\n\r" + matches[i]; + } + sessionDescription.sdp = sessionDescription.sdp.replace(/^.*(rtcp-fb).*$\r\n/gm, ""); + sessionDescription.sdp += lines; + return sessionDescription; + } + var setLocalDescp2p = function (sessionDescription) { sessionDescription.sdp = setMaxBW(sessionDescription.sdp); sessionDescription.sdp = sessionDescription.sdp.replace(/a=ice-options:google-ice\r\n/g, ""); diff --git a/erizo_controller/erizoController/erizoController.js b/erizo_controller/erizoController/erizoController.js index 140eb51852..0ca37f5aab 100644 --- a/erizo_controller/erizoController/erizoController.js +++ b/erizo_controller/erizoController/erizoController.js @@ -489,14 +489,14 @@ var listen = function () { socket.emit('connection_failed',{}); socket.state = 'sleeping'; if (!socket.room.p2p) { - socket.room.controller.removePublisher(streamId); + socket.room.controller.removePublisher(id); if (GLOBAL.config.erizoController.report.session_events) { var timeStamp = new Date(); - amqper.broadcast('event', {room: socket.room.id, user: socket.id, type: 'failed', stream: streamId, timestamp: timeStamp.getTime()}); + amqper.broadcast('event', {room: socket.room.id, user: socket.id, type: 'failed', stream: id, timestamp: timeStamp.getTime()}); } } - var index = socket.streams.indexOf(streamId); + var index = socket.streams.indexOf(id); if (index !== -1) { socket.streams.splice(index, 1); }