FS-7509: choose a camera as share source as well as screen

This commit is contained in:
Anthony Minessale 2015-03-04 15:13:35 -06:00 committed by Michael Jerris
parent 6e05e09e9a
commit db191452d6
3 changed files with 45 additions and 3 deletions

View File

@ -278,6 +278,9 @@ if ($('#devices').is(':visible')) {
<div id="camdiv">
<legend><b>Camera</b>:</legend><select data-theme="a" data-overlay-theme="a" data-native-menu="false" id="usecamera"></select>
<br>
<legend><b>Share Device</b>:</legend><select data-theme="a" data-overlay-theme="a" data-native-menu="false" id="useshare"></select>
<br><br></div>
<legend><b>Microphone</b>:</legend><select data-theme="a" data-overlay-theme="a" data-native-menu="false" id="usemic"></select>

View File

@ -34,12 +34,12 @@ if(self.options.localVideoStream){self.options.localVideoStream.stop();}
if(self.peer){console.log("stopping peer");self.peer.stop();}};$.FSRTC.prototype.createAnswer=function(params){var self=this;self.type="answer";self.remoteSDP=params.sdp;console.debug("inbound sdp: ",params.sdp);self.options.useCamera=params.useCamera||"any";self.options.useMic=params.useMic||"any";function onSuccess(stream){self.localStream=stream;self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:function(stream){return onRemoteStream(self,stream);},onICESDP:function(sdp){return onICESDP(self,sdp);},onChannelError:function(e){return onChannelError(self,e);},constraints:self.constraints,iceServers:self.options.iceServers,offerSDP:{type:"offer",sdp:self.remoteSDP}});onStreamSuccess(self);}
function onError(e){onStreamError(self,e);}
var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);if(self.options.useVideo&&self.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:self.options.videoParams,optional:[]},},localVideo:self.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.videoParams&&obj.options.videoParams.chromeMediaSource=='desktop'){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:obj.options.audioParams,optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}}
getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:obj.options.audioParams,optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}}
if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:obj.options.videoParams,optional:[]},},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={mandatory:obj.options.videoParams,optional:[]}
var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(obj.options.useCamera!=="any"){video.optional=[{sourceId:obj.options.useCamera}]}}else{video=null;useVideo=null;}
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.videoParams.chromeMediaSource=='desktop'){screen=true;}
$.FSRTC.prototype.call=function(profile){checkCompat();var self=this;var screen=false;self.type="offer";if(self.options.videoParams&&self.options.screenShare){screen=true;}
function onSuccess(stream){self.localStream=stream;self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:screen?function(stream){console.error("SKIP");}:function(stream){return onRemoteStream(self,stream);},onOfferSDP:function(sdp){return onOfferSDP(self,sdp);},onICESDP:function(sdp){return onICESDP(self,sdp);},onChannelError:function(e){return onChannelError(self,e);},constraints:self.constraints,iceServers:self.options.iceServers,});onStreamSuccess(self,stream);}
function onError(e){onStreamError(self,e);}
var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};window.moz=!!navigator.mozGetUserMedia;function RTCPeerConnection(options){var w=window,PeerConnection=w.mozRTCPeerConnection||w.webkitRTCPeerConnection,SessionDescription=w.mozRTCSessionDescription||w.RTCSessionDescription,IceCandidate=w.mozRTCIceCandidate||w.RTCIceCandidate;var STUN={url:!moz?'stun:stun.l.google.com:19302':'stun:23.21.150.121'};var TURN={url:'turn:homeo@turn.bistri.com:80',credential:'homeo'};var iceServers=null;if(options.iceServers){var tmp=options.iceServers;if(typeof(tmp)==="boolean"){tmp=null;}

View File

@ -573,9 +573,31 @@ function doshare(on) {
if (share_call) {
return;
}
var sharedev = $("#useshare").find(":selected").val();
if (sharedev !== "screen") {
share_call = verto.newCall({
destination_number: $("#ext").val() + "-screen",
caller_id_name: $("#cidname").val() + " (Screen)",
caller_id_number: $("#cid").val() + " (screen)",
outgoingBandwidth: outgoingBandwidth,
incomingBandwidth: incomingBandwidth,
useCamera: sharedev,
useVideo: true,
screenShare: true
});
return;
}
console.log("Attempting Screen Capture....");
getScreenId(function (error, sourceId, screen_constraints) {
share_call = verto.newCall({
destination_number: $("#ext").val() + "-screen",
caller_id_name: $("#cidname").val() + " (Screen)",
@ -639,6 +661,7 @@ var devinit = false;
function refresh_devices()
{
if (devinit) {
$("#useshare").empty();
$("#usecamera").empty();
$("#usemic").empty();
}
@ -647,14 +670,22 @@ function refresh_devices()
$.verto.findDevices(function() {
var x = 0;
$("#usecamera").append(new Option("No Camera", "none"));
for (var i in $.verto.videoDevices) {
var source = $.verto.videoDevices[i];
var o = new Option(source.label, source.id);
if (!x++) {
if (!x) {
o.selected = true;
}
$("#usecamera").append(o);
var oo = new Option(source.label, source.id);
if (!x++) {
o.selected = true;
}
$("#useshare").append(oo);
}
x = 0;
@ -667,9 +698,17 @@ function refresh_devices()
}
$("#usemic").append(o);
}
var o = new Option("Screen", "screen");
o.selected = true;
$("#useshare").append(o);
$("#usecamera").selectmenu('refresh', true);
$("#usemic").selectmenu('refresh', true);
$("#useshare").selectmenu('refresh', true);
//console.error($("#usecamera").find(":selected").val());