Turns off the camera when video is muted on https connection.
This commit is contained in:
parent
2568b07075
commit
3a0ee11ccd
|
@ -19,7 +19,7 @@
|
||||||
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
|
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
|
||||||
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
|
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
|
||||||
<script src="interface_config.js?v=5"></script>
|
<script src="interface_config.js?v=5"></script>
|
||||||
<script src="libs/app.bundle.js?v=43"></script>
|
<script src="libs/app.bundle.js?v=44"></script>
|
||||||
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
||||||
<link rel="stylesheet" href="css/font.css?v=6"/>
|
<link rel="stylesheet" href="css/font.css?v=6"/>
|
||||||
<link rel="stylesheet" href="css/toastr.css?v=1">
|
<link rel="stylesheet" href="css/toastr.css?v=1">
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,6 @@
|
||||||
var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
|
var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
|
||||||
|
|
||||||
|
|
||||||
function LocalStream(stream, type, eventEmitter, videoType)
|
function LocalStream(stream, type, eventEmitter, videoType)
|
||||||
{
|
{
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
@ -53,11 +54,30 @@ LocalStream.prototype.mute = function()
|
||||||
|
|
||||||
LocalStream.prototype.setMute = function(mute)
|
LocalStream.prototype.setMute = function(mute)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(window.location.protocol != "https:" ||
|
||||||
|
this.isAudioStream() || this.videoType === "screen")
|
||||||
|
{
|
||||||
var tracks = this.getTracks();
|
var tracks = this.getTracks();
|
||||||
|
|
||||||
for (var idx = 0; idx < tracks.length; idx++) {
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
tracks[idx].enabled = mute;
|
tracks[idx].enabled = mute;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(mute === false) {
|
||||||
|
APP.xmpp.removeStream(this.stream);
|
||||||
|
this.stream.stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
APP.RTC.rtcUtils.obtainAudioAndVideoPermissions(["video"],
|
||||||
|
function (stream) {
|
||||||
|
APP.RTC.changeLocalVideo(stream, false, function () {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalStream.prototype.isMuted = function () {
|
LocalStream.prototype.isMuted = function () {
|
||||||
|
@ -68,6 +88,8 @@ LocalStream.prototype.isMuted = function () {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(this.stream.ended)
|
||||||
|
return true;
|
||||||
tracks = this.stream.getVideoTracks();
|
tracks = this.stream.getVideoTracks();
|
||||||
}
|
}
|
||||||
for (var idx = 0; idx < tracks.length; idx++) {
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
|
@ -81,6 +103,4 @@ LocalStream.prototype.getId = function () {
|
||||||
return this.stream.getTracks()[0].id;
|
return this.stream.getTracks()[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = LocalStream;
|
module.exports = LocalStream;
|
||||||
|
|
|
@ -166,10 +166,18 @@ var RTC = {
|
||||||
changeLocalVideo: function (stream, isUsingScreenStream, callback) {
|
changeLocalVideo: function (stream, isUsingScreenStream, callback) {
|
||||||
var oldStream = this.localVideo.getOriginalStream();
|
var oldStream = this.localVideo.getOriginalStream();
|
||||||
var type = (isUsingScreenStream? "screen" : "video");
|
var type = (isUsingScreenStream? "screen" : "video");
|
||||||
|
var localCallback = callback;
|
||||||
|
if(this.localVideo.isMuted() && this.localVideo.videoType !== type)
|
||||||
|
{
|
||||||
|
localCallback = function() {
|
||||||
|
APP.xmpp.setVideoMute(false, APP.UI.setVideoMuteButtonsState);
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
}
|
||||||
this.localVideo = this.createLocalStream(stream, "video", true, type);
|
this.localVideo = this.createLocalStream(stream, "video", true, type);
|
||||||
// Stop the stream to trigger onended event for old stream
|
// Stop the stream to trigger onended event for old stream
|
||||||
oldStream.stop();
|
oldStream.stop();
|
||||||
APP.xmpp.switchStreams(stream, oldStream,callback);
|
APP.xmpp.switchStreams(stream, oldStream,localCallback);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Checks if video identified by given src is desktop stream.
|
* Checks if video identified by given src is desktop stream.
|
||||||
|
@ -196,6 +204,25 @@ var RTC = {
|
||||||
isDesktop = (stream.videoType === "screen");
|
isDesktop = (stream.videoType === "screen");
|
||||||
|
|
||||||
return isDesktop;
|
return isDesktop;
|
||||||
|
},
|
||||||
|
setVideoMute: function(mute, callback, options) {
|
||||||
|
if(!this.localVideo)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mute == APP.RTC.localVideo.isMuted())
|
||||||
|
{
|
||||||
|
APP.xmpp.sendVideoInfoPresence(mute);
|
||||||
|
if(callback)
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
APP.RTC.localVideo.setMute(!mute);
|
||||||
|
APP.xmpp.setVideoMute(
|
||||||
|
mute,
|
||||||
|
callback,
|
||||||
|
options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -272,13 +272,19 @@ RTCUtils.prototype.getUserMediaWithConstraints = function(
|
||||||
* We ask for audio and video combined stream in order to get permissions and
|
* We ask for audio and video combined stream in order to get permissions and
|
||||||
* not to ask twice.
|
* not to ask twice.
|
||||||
*/
|
*/
|
||||||
RTCUtils.prototype.obtainAudioAndVideoPermissions = function() {
|
RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// Get AV
|
// Get AV
|
||||||
|
|
||||||
|
if(!devices)
|
||||||
|
devices = ['audio', 'video'];
|
||||||
|
|
||||||
this.getUserMediaWithConstraints(
|
this.getUserMediaWithConstraints(
|
||||||
['audio', 'video'],
|
devices,
|
||||||
function (stream) {
|
function (stream) {
|
||||||
|
if(callback)
|
||||||
|
callback(stream);
|
||||||
|
else
|
||||||
self.successCallback(stream);
|
self.successCallback(stream);
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
|
@ -357,6 +363,4 @@ RTCUtils.prototype.handleLocalStream = function(stream)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = RTCUtils;
|
module.exports = RTCUtils;
|
||||||
|
|
|
@ -230,21 +230,8 @@ function registerListeners() {
|
||||||
* contrast to an automatic decision taken by the application logic)
|
* contrast to an automatic decision taken by the application logic)
|
||||||
*/
|
*/
|
||||||
function setVideoMute(mute, options) {
|
function setVideoMute(mute, options) {
|
||||||
APP.xmpp.setVideoMute(
|
APP.RTC.setVideoMute(mute,
|
||||||
mute,
|
UI.setVideoMuteButtonsState,
|
||||||
function (mute) {
|
|
||||||
var video = $('#video');
|
|
||||||
var communicativeClass = "icon-camera";
|
|
||||||
var muteClass = "icon-camera icon-camera-disabled";
|
|
||||||
|
|
||||||
if (mute) {
|
|
||||||
video.removeClass(communicativeClass);
|
|
||||||
video.addClass(muteClass);
|
|
||||||
} else {
|
|
||||||
video.removeClass(muteClass);
|
|
||||||
video.addClass(communicativeClass);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,5 +730,19 @@ UI.dockToolbar = function (isDock) {
|
||||||
return ToolbarToggler.dockToolbar(isDock);
|
return ToolbarToggler.dockToolbar(isDock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI.setVideoMuteButtonsState = function (mute) {
|
||||||
|
var video = $('#video');
|
||||||
|
var communicativeClass = "icon-camera";
|
||||||
|
var muteClass = "icon-camera icon-camera-disabled";
|
||||||
|
|
||||||
|
if (mute) {
|
||||||
|
video.removeClass(communicativeClass);
|
||||||
|
video.addClass(muteClass);
|
||||||
|
} else {
|
||||||
|
video.removeClass(muteClass);
|
||||||
|
video.addClass(communicativeClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = UI;
|
module.exports = UI;
|
||||||
|
|
||||||
|
|
|
@ -1056,26 +1056,6 @@ JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the (local) video is mute i.e. all video tracks are
|
|
||||||
* disabled.
|
|
||||||
*
|
|
||||||
* @return <tt>true</tt> if the (local) video is mute i.e. all video tracks are
|
|
||||||
* disabled; otherwise, <tt>false</tt>
|
|
||||||
*/
|
|
||||||
JingleSession.prototype.isVideoMute = function () {
|
|
||||||
var tracks = APP.RTC.localVideo.getVideoTracks();
|
|
||||||
var mute = true;
|
|
||||||
|
|
||||||
for (var i = 0; i < tracks.length; ++i) {
|
|
||||||
if (tracks[i].enabled) {
|
|
||||||
mute = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mute;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes/unmutes the (local) video i.e. enables/disables all video tracks.
|
* Mutes/unmutes the (local) video i.e. enables/disables all video tracks.
|
||||||
*
|
*
|
||||||
|
@ -1114,12 +1094,6 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
||||||
this.modifySources(callback(mute));
|
this.modifySources(callback(mute));
|
||||||
};
|
};
|
||||||
|
|
||||||
// SDP-based mute by going recvonly/sendrecv
|
|
||||||
// FIXME: should probably black out the screen as well
|
|
||||||
JingleSession.prototype.toggleVideoMute = function (callback) {
|
|
||||||
this.service.setVideoMute(APP.RTC.localVideo.isMuted(), callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
JingleSession.prototype.hardMuteVideo = function (muted) {
|
JingleSession.prototype.hardMuteVideo = function (muted) {
|
||||||
this.pendingop = muted ? 'mute' : 'unmute';
|
this.pendingop = muted ? 'mute' : 'unmute';
|
||||||
};
|
};
|
||||||
|
|
|
@ -202,10 +202,12 @@ var XMPP = {
|
||||||
// FIXME: probably removing streams is not required and close() should
|
// FIXME: probably removing streams is not required and close() should
|
||||||
// be enough
|
// be enough
|
||||||
if (APP.RTC.localAudio) {
|
if (APP.RTC.localAudio) {
|
||||||
handler.peerconnection.removeStream(APP.RTC.localAudio.getOriginalStream(), onUnload);
|
handler.peerconnection.removeStream(
|
||||||
|
APP.RTC.localAudio.getOriginalStream(), onUnload);
|
||||||
}
|
}
|
||||||
if (APP.RTC.localVideo) {
|
if (APP.RTC.localVideo) {
|
||||||
handler.peerconnection.removeStream(APP.RTC.localVideo.getOriginalStream(), onUnload);
|
handler.peerconnection.removeStream(
|
||||||
|
APP.RTC.localVideo.getOriginalStream(), onUnload);
|
||||||
}
|
}
|
||||||
handler.peerconnection.close();
|
handler.peerconnection.close();
|
||||||
}
|
}
|
||||||
|
@ -251,28 +253,19 @@ var XMPP = {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setVideoMute: function (mute, callback, options) {
|
sendVideoInfoPresence: function (mute) {
|
||||||
if(!connection || !APP.RTC.localVideo)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var localCallback = function (mute) {
|
|
||||||
connection.emuc.addVideoInfoToPresence(mute);
|
connection.emuc.addVideoInfoToPresence(mute);
|
||||||
connection.emuc.sendPresence();
|
connection.emuc.sendPresence();
|
||||||
|
},
|
||||||
|
setVideoMute: function (mute, callback, options) {
|
||||||
|
if(!connection)
|
||||||
|
return;
|
||||||
|
var self = this;
|
||||||
|
var localCallback = function (mute) {
|
||||||
|
self.sendVideoInfoPresence(mute);
|
||||||
return callback(mute);
|
return callback(mute);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mute == APP.RTC.localVideo.isMuted())
|
|
||||||
{
|
|
||||||
// Even if no change occurs, the specified callback is to be executed.
|
|
||||||
// The specified callback may, optionally, return a successCallback
|
|
||||||
// which is to be executed as well.
|
|
||||||
var successCallback = localCallback(mute);
|
|
||||||
|
|
||||||
if (successCallback) {
|
|
||||||
successCallback();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
APP.RTC.localVideo.setMute(!mute);
|
|
||||||
if(connection.jingle.activecall)
|
if(connection.jingle.activecall)
|
||||||
{
|
{
|
||||||
connection.jingle.activecall.setVideoMute(
|
connection.jingle.activecall.setVideoMute(
|
||||||
|
@ -282,7 +275,6 @@ var XMPP = {
|
||||||
localCallback(mute);
|
localCallback(mute);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setAudioMute: function (mute, callback) {
|
setAudioMute: function (mute, callback) {
|
||||||
if (!(connection && APP.RTC.localAudio)) {
|
if (!(connection && APP.RTC.localAudio)) {
|
||||||
|
@ -472,8 +464,13 @@ var XMPP = {
|
||||||
},
|
},
|
||||||
getSessions: function () {
|
getSessions: function () {
|
||||||
return connection.jingle.sessions;
|
return connection.jingle.sessions;
|
||||||
|
},
|
||||||
|
removeStream: function (stream) {
|
||||||
|
if(!connection || !connection.jingle.activecall ||
|
||||||
|
!connection.jingle.activecall.peerconnection)
|
||||||
|
return;
|
||||||
|
connection.jingle.activecall.peerconnection.removeStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = XMPP;
|
module.exports = XMPP;
|
||||||
|
|
Loading…
Reference in New Issue