diff --git a/html5/verto/js/src/jquery.FSRTC.js b/html5/verto/js/src/jquery.FSRTC.js
index 5cfd11bd05..832a9a3fb7 100644
--- a/html5/verto/js/src/jquery.FSRTC.js
+++ b/html5/verto/js/src/jquery.FSRTC.js
@@ -520,8 +520,17 @@
if (obj.options.screenShare) {
// fix for chrome to work for now, will need to change once we figure out how to do this in a non-mandatory style constraint.
+ var opt = [];
+ opt.push({sourceId: obj.options.useCamera});
+
+ if (bestFrameRate) {
+ opt.push({minFrameRate: bestFrameRate});
+ opt.push({maxFrameRate: bestFrameRate});
+ }
+
video = {
- mandatory: obj.options.videoParams
+ mandatory: obj.options.videoParams,
+ optional: opt
};
} else {
diff --git a/html5/verto/verto_communicator/src/vertoService/services/vertoService.js b/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
index 788653f2a4..c5c2fd9025 100644
--- a/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
+++ b/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
@@ -824,9 +824,63 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
},
screenshare: function(destination, callback) {
- console.log('share screen video');
- var that = this;
+
+ var that = this;
+
+ if (storage.data.selectedShare !== "screen") {
+
+ console.log('share screen from device ' + storage.data.selectedShare);
+
+ var call = data.instance.newCall({
+ destination_number: destination + "-screen",
+ caller_id_name: data.name + " (Screen)",
+ caller_id_number: data.login + " (screen)",
+ outgoingBandwidth: storage.data.outgoingBandwidth,
+ incomingBandwidth: storage.data.incomingBandwidth,
+ useCamera: storage.data.selectedShare,
+ useVideo: true,
+ screenShare: true,
+ dedEnc: storage.data.useDedenc,
+ mirrorInput: storage.data.mirrorInput,
+ userVariables: {
+ email : storage.data.email,
+ avatar: "http://gravatar.com/avatar/" + md5(storage.data.email) + ".png?s=600"
+ }
+ });
+
+ // Override onStream callback in $.FSRTC instance
+ call.rtc.options.callbacks.onStream = function(rtc, stream) {
+ if(stream) {
+ var StreamTrack = stream.getVideoTracks()[0];
+ StreamTrack.addEventListener('ended', stopSharing);
+ // (stream.getVideoTracks()[0]).onended = stopSharing;
+ }
+
+ console.log("screenshare started");
+
+ function stopSharing() {
+ if(that.data.shareCall) {
+ that.screenshareHangup();
+ console.log("screenshare ended");
+ }
+ }
+ };
+
+ data.shareCall = call;
+
+ console.log('shareCall', data);
+
+ data.mutedMic = false;
+ data.mutedVideo = false;
+
+ that.refreshDevices();
+
+ return;
+ }
+
+
+ console.log('share screen from plugin');
getScreenId(function(error, sourceId, screen_constraints) {
@@ -842,7 +896,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
outgoingBandwidth: storage.data.outgoingBandwidth,
incomingBandwidth: storage.data.incomingBandwidth,
videoParams: screen_constraints.video.mandatory,
- useVideo: storage.data.useVideo,
+ useVideo: true,
screenShare: true,
dedEnc: storage.data.useDedenc,
mirrorInput: storage.data.mirrorInput,
diff --git a/html5/verto/video_demo/js/verto-min.js b/html5/verto/video_demo/js/verto-min.js
index 52f165af51..7764aa28b4 100644
--- a/html5/verto/video_demo/js/verto-min.js
+++ b/html5/verto/video_demo/js/verto-min.js
@@ -46,7 +46,8 @@ var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams
getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.useMic&&obj.options.useMic==="none"){console.log("Microphone Disabled");audio=false;}else if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE",obj.options.videoParams);audio=false;}else{audio={advanced:[]};if(obj.options.useMic!=="any"){audio.deviceId={exact:obj.options.useMic};}
if(obj.options.audioParams){for(var key in obj.options.audioParams){var con={};if(obj.options.audioParams[key]){con.exact=key;audio.advanced.push(con);}}}}
if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audio:false,video:obj.options.videoParams},localVideo:obj.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
-var video={};var bestFrameRate=obj.options.videoParams.vertoBestFrameRate;var minFrameRate=obj.options.videoParams.minFrameRate||15;delete obj.options.videoParams.vertoBestFrameRate;if(obj.options.screenShare){video={mandatory:obj.options.videoParams};}else{video={width:{min:obj.options.videoParams.minWidth,max:obj.options.videoParams.maxWidth},height:{min:obj.options.videoParams.minHeight,max:obj.options.videoParams.maxHeight}};var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(obj.options.useCamera!=="any"){video.deviceId=obj.options.useCamera;}
+var video={};var bestFrameRate=obj.options.videoParams.vertoBestFrameRate;var minFrameRate=obj.options.videoParams.minFrameRate||15;delete obj.options.videoParams.vertoBestFrameRate;if(obj.options.screenShare){var opt=[];opt.push({sourceId:obj.options.useCamera});if(bestFrameRate){opt.push({minFrameRate:bestFrameRate});opt.push({maxFrameRate:bestFrameRate});}
+video={mandatory:obj.options.videoParams,optional:opt};}else{video={width:{min:obj.options.videoParams.minWidth,max:obj.options.videoParams.maxWidth},height:{min:obj.options.videoParams.minHeight,max:obj.options.videoParams.maxHeight}};var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(obj.options.useCamera!=="any"){video.deviceId=obj.options.useCamera;}
if(bestFrameRate){video.frameRate={ideal:bestFrameRate,min:minFrameRate,max:30};}}else{console.log("Camera Disabled");video=false;useVideo=false;}}
return{audio:audio,video:video,useVideo:useVideo};}
$.FSRTC.prototype.call=function(profile){checkCompat();var self=this;var screen=false;self.type="offer";if(self.options.videoParams&&self.options.screenShare){screen=true;}
diff --git a/html5/verto/video_demo/verto.js b/html5/verto/video_demo/verto.js
index 7b6adc13b5..a4bfbf68d3 100644
--- a/html5/verto/video_demo/verto.js
+++ b/html5/verto/video_demo/verto.js
@@ -1091,6 +1091,13 @@ function refresh_devices()
pop_select("#usecamera","verto_demo_camera_selected", tmp);
}
+ var tmp;
+ tmp = $.cookie("verto_demo_share_selected") || "false";
+ if (tmp) {
+ $('#useshare option[value=' + tmp + ']').prop('selected', 'selected').change();
+ pop_select("#useshare","verto_demo_share_selected", tmp);
+ }
+
tmp = $.cookie("verto_demo_mic_selected") || "false";
if (tmp) {
$('#usemic option[value=' + tmp + ']').prop('selected', 'selected').change();