listen only, microphone, watch only

This commit is contained in:
perroned 2015-09-22 09:09:29 -07:00
parent 576acf0902
commit bc1c86ba52
7 changed files with 167 additions and 50 deletions

View File

@ -31,12 +31,12 @@
return false
# join the conference. If listen only send the request to the server
@joinVoiceCall = (event, {isListenOnly} = {}) ->
@joinVoiceCall = (event, options) ->
if !isWebRTCAvailable()
notification_WebRTCNotSupported()
return
isListenOnly ?= true
# isListenOnly ?= trueoptions
if not Meteor.config.useSIPAudio
#
@ -52,11 +52,11 @@
# Always fail the first time. Retry on failure.
#
if !!navigator.mozGetUserMedia and message.errorcode is 1001
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, ((m) -> console.log("CALLBACK: "+JSON.stringify(m))), "webcam", isListenOnly)
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, ((m) -> console.log("CALLBACK: "+JSON.stringify(m))), "webcam", options)
#
# End of hacky method
#
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, debuggerCallback, "webcam", isListenOnly);
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, debuggerCallback, "webcam", options);
return
else
# create voice call params

View File

@ -324,7 +324,7 @@ var iceTimer;
$.FSRTC.prototype.setMute = function(what) {
var self = this;
var audioTracks = self.localStream.getAudioTracks();
var audioTracks = self.localStream.getAudioTracks();
for (var i = 0, len = audioTracks.length; i < len; i++ ) {
switch(what) {
@ -481,9 +481,9 @@ var iceTimer;
video = {
mandatory: obj.options.videoParams,
optional: []
}
}
}
var useVideo = obj.options.useVideo;
if (useVideo && obj.options.useCamera && obj.options.useCamera !== "none") {
@ -506,12 +506,12 @@ var iceTimer;
return {audio: audio, video: video, useVideo: useVideo};
}
$.FSRTC.prototype.call = function(profile) {
checkCompat();
var self = this;
var screen = false;
@ -562,7 +562,12 @@ var iceTimer;
console.log("Video constraints", mediaParams.video);
if (window.isListenOnly) {
//
// watchOnly
// listenOnly
// joinAudio
//
if (window.watchOnly && !window.listenOnly && !window.joinAudio) {
var stream = null;
if (typeof webkitMediaStream !== 'undefined') {
// Google Chrome
@ -573,7 +578,22 @@ var iceTimer;
stream = audioContext.createMediaStreamDestination().stream;
}
onSuccess(stream);
} else {
return;
}
if (window.listenOnly && !window.watchOnly && !window.joinAudio) {
var stream = null;
if (typeof webkitMediaStream !== 'undefined') {
// Google Chrome
stream = new webkitMediaStream;
} else {
// Firefox
audioContext = new window.AudioContext;
stream = audioContext.createMediaStreamDestination().stream;
}
onSuccess(stream);
return;
}
if (window.joinAudio && !window.watchOnly && !window.listenOnly) {
getUserMedia({
constraints: {
audio: mediaParams.audio,
@ -583,11 +603,9 @@ var iceTimer;
onsuccess: onSuccess,
onerror: onError
});
return;
}
/*
navigator.getUserMedia({
video: self.options.useVideo,
@ -669,8 +687,8 @@ var iceTimer;
}
if (options.type == "offer") {
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
to handle partial setups to maybe save 100m
*/
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
@ -715,8 +733,8 @@ var iceTimer;
}
if (options.type == "offer") {
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
to handle partial setups to maybe save 100m
*/
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
@ -752,7 +770,7 @@ var iceTimer;
}
}
};
// attachStream = MediaStream;
if (options.attachStream) peer.addStream(options.attachStream);
@ -782,7 +800,7 @@ var iceTimer;
var constraints = options.constraints || {
offerToReceiveAudio: true,
offerToReceiveVideo: true
offerToReceiveVideo: true
};
// onOfferSDP(RTCSessionDescription)
@ -1064,12 +1082,12 @@ var iceTimer;
var video = {
mandatory: {},
optional: []
}
}
if (cam) {
video.optional = [{sourceId: cam}];
}
w = resList[resI][0];
h = resList[resI][1];
resI++;
@ -1091,13 +1109,13 @@ var iceTimer;
getUserMedia({
constraints: {
audio: ttl++ == 0,
video: video
video: video
},
onsuccess: function(e) {e.stop(); console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
onerror: function(e) {console.error( w + "x" + h + " not supported."); checkRes(cam, func);}
});
}
$.FSRTC.getValidRes = function (cam, func) {
var used = [];

View File

@ -40,7 +40,7 @@ $.verto.prototype.hangup = function(callID, userCallback) {
}
// main entry point to making a verto call
this.callIntoConference_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, videoTag, isListenOnly) {
this.callIntoConference_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, videoTag, options) {
window.videoTag = videoTag;
// stores the user's callback in the global scope
if (userCallback) {
@ -72,7 +72,7 @@ this.callIntoConference_verto = function(voiceBridge, conferenceUsername, confer
console.log("starting call");
toDisplayDisconnectCallback = true; // yes, display an error if the socket closes
wasCallSuccessful = true; // yes, a call was successfully established through the websocket
webrtc_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, isListenOnly);
webrtc_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, options);
} else {
callback({'status':'failed', 'errorcode': '10XX'}); // eror logging verto into freeswitch
}
@ -82,7 +82,7 @@ this.callIntoConference_verto = function(voiceBridge, conferenceUsername, confer
init(videoTag);
} else {
console.log("already logged into verto, going straight to making a call");
webrtc_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, isListenOnly);
webrtc_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, options);
}
}
@ -134,7 +134,7 @@ this.configStuns = function(callbacks, callback, videoTag) {
});
}
this.docall_verto = function(extension, conferenceUsername, conferenceIdNumber, callbacks, isListenOnly) {
this.docall_verto = function(extension, conferenceUsername, conferenceIdNumber, callbacks, options) {
console.log(extension + ", " + conferenceUsername + ", " + conferenceIdNumber);
if (cur_call) { // only allow for one call
@ -146,22 +146,87 @@ this.docall_verto = function(extension, conferenceUsername, conferenceIdNumber,
outgoingBandwidth = "default";
incomingBandwidth = "default";
console.log("Making a call isListenOnly: "+isListenOnly);
window.isListenOnly = isListenOnly;
// listenOnly
// useVideo: false
// useCamera: false
// useMic: false
// window.useRealMic = false
//
// Mic
// useVideo: false
// useCamera: false
// useMic: true
// window.useRealMic = true
//
// view deskshare
// useVideo: true
// useCamera: false
// useMic: false
// window.useRealMic = false
cur_call = verto.newCall({
destination_number: extension,
caller_id_name: conferenceUsername,
caller_id_number: conferenceIdNumber,
outgoingBandwidth: outgoingBandwidth,
incomingBandwidth: incomingBandwidth,
useVideo: false,
useStereo: true,
useCamera: false,
useMic: isListenOnly,
dedEnc: false,
mirrorInput: false
});
//
// options
// window.viewScreenShareOnly = true;
if(options.watchOnly) {
window.watchOnly = true;
window.listenOnly = false;
window.joinAudio = false;
cur_call = verto.newCall({
destination_number: extension,
caller_id_name: conferenceUsername,
caller_id_number: conferenceIdNumber,
outgoingBandwidth: outgoingBandwidth,
incomingBandwidth: incomingBandwidth,
useStereo: true,
useVideo: true,
useCamera: false,
useMic: false,
dedEnc: false,
mirrorInput: false
});
return;
}
if(options.listenOnly) {
window.listenOnly = true;
window.watchOnly = false;
window.joinAudio = false;
cur_call = verto.newCall({
destination_number: extension,
caller_id_name: conferenceUsername,
caller_id_number: conferenceIdNumber,
outgoingBandwidth: outgoingBandwidth,
incomingBandwidth: incomingBandwidth,
useStereo: true,
useVideo: false,
useCamera: false,
useMic: false,
dedEnc: false,
mirrorInput: false
});
return;
}
if(options.joinAudio) {
window.joinAudio = true;
window.watchOnly = false;
window.listenOnly = false;
cur_call = verto.newCall({
destination_number: extension,
caller_id_name: conferenceUsername,
caller_id_number: conferenceIdNumber,
outgoingBandwidth: outgoingBandwidth,
incomingBandwidth: incomingBandwidth,
useStereo: true,
useVideo: false,
useCamera: false,
useMic: true,
dedEnc: false,
mirrorInput: false
});
return;
}
if (callbacks != null) { // add user supplied callbacks to the current call
cur_call.rtc.options.callbacks = $.extend(cur_call.rtc.options.callbacks, callbacks);
@ -234,7 +299,7 @@ this.leaveWebRTCVoiceConference_verto = function() {
webrtc_hangup_verto();
}
this.make_call_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, server, recall, isListenOnly) {
this.make_call_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, server, recall, options) {
if (userCallback) {
callback = userCallback;
}
@ -298,7 +363,7 @@ this.make_call_verto = function(voiceBridge, conferenceUsername, conferenceIdNum
console.log("Verto is logged into FreeSWITCH, socket is available, making call");
callICEConnected = false;
docall_verto(voiceBridge, conferenceUsername, conferenceIdNumber, myRTCCallbacks, isListenOnly);
docall_verto(voiceBridge, conferenceUsername, conferenceIdNumber, myRTCCallbacks, options);
if(recall === false) {
console.log('call connecting');
@ -404,7 +469,7 @@ var RTCPeerConnectionCallbacks = {
};
this.RTCPeerConnectionCallbacks = RTCPeerConnectionCallbacks;
this.webrtc_call_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, isListenOnly) {
this.webrtc_call_verto = function(voiceBridge, conferenceUsername, conferenceIdNumber, userCallback, options) {
if (userCallback) {
callback = userCallback;
}
@ -418,7 +483,7 @@ this.webrtc_call_verto = function(voiceBridge, conferenceUsername, conferenceIdN
var server = window.document.location.hostname;
console.log("user " + conferenceUsername + " calling to " + voiceBridge);
if (isLoggedIntoVerto()) {
make_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, "", false, isListenOnly);
make_call_verto(voiceBridge, conferenceUsername, conferenceIdNumber, callback, "", false, options);
}
}

View File

@ -72,6 +72,10 @@ this.doshare = function(on, callback, videoTag) {
console.log("new screen constraints");
console.log(selectedDeskshareConstraints);
window.listenOnly = false;
window.watchOnly = false;
window.joinAudio = true;
share_call = verto.newCall({
destination_number: extension + "-screen",
caller_id_name: conferenceUsername + " (Screen)",
@ -169,7 +173,8 @@ this.screenStart = function(state, callback, videoTag) {
console.log("logged in. starting screenshare");
}
// set up verto
$.verto.init({}, init);
// $.verto.init({}, init);
init(window.videoTag);
} else {
console.log("already logged into verto, going straight to making a call");
doshare(state, callback, videoTag);

View File

@ -19,6 +19,16 @@ Template.vertoDeskshareMenu.events
$("#screenshareStart").show()
$("#screenshareStop").hide()
"click #screenshareSubscribe": (event) ->
joinVoiceCall @, {
# useVideo: true
# useCamera: false
# useMic: false
# useRealMic: false
watchOnly: true
}
return false
Template.deskshareModal.events
"click .screenshareStart": (event) ->
$("#deskshareModal").foundation('reveal', 'close')

View File

@ -1,6 +1,8 @@
<template name="vertoDeskshareMenu">
{{> makeButton id="screenshareShow" btn_class="screenshareShow vertoButton settingsButton" i_class="fi-monitor" rel="tooltip" data_placement="bottom" title="Share your screen"}}
{{> makeButton id="screenshareHide" btn_class="screenshareHide vertoButton settingsButton" i_class="fi-monitor" rel="tooltip" data_placement="bottom" title="Stop sharing your screen"}}
<!-- -->
{{> makeButton id="screenshareSubscribe" btn_class="" i_class="fi-monitor" rel="tooltip" data_placement="bottom" title="view deskshare"}}
</template>
<template name="vertoWebcamMenu">

View File

@ -13,9 +13,26 @@ Template.settingsAudio.events
"click .joinAudioButton": (event) -> $("#settingsModal").foundation('reveal', 'close')
"click #joinListenOnly": (event) -> joinVoiceCall @, isListenOnly: true
"click #joinListenOnly": (event) ->
# joinVoiceCall @, isListenOnly: true
joinVoiceCall @, {
# useVideo: true
# useCamera: false
# useMic: false
# useRealMic: false
listenOnly: true
}
"click #joinMicrophone": (event) -> joinVoiceCall @, isListenOnly: false
"click #joinMicrophone": (event) ->
# joinVoiceCall @, isListenOnly: false
joinVoiceCall @, {
# useVideo: true
# useCamera: false
# useMic: false
# useRealMic: false
joinAudio: true
}
"click #hangupVerto": (event) -> exitVoiceCall()