Fixes broken video muting.

This commit is contained in:
paweldomas 2014-03-13 14:01:54 +01:00
parent 3e34df8730
commit 0da0f865a1
4 changed files with 26 additions and 18 deletions

23
app.js
View File

@ -782,20 +782,21 @@ function getConferenceHandler() {
function toggleVideo() { function toggleVideo() {
if (!(connection && connection.jingle.localVideo)) return; if (!(connection && connection.jingle.localVideo)) return;
var ismuted = false;
var localVideo = connection.jingle.localVideo;
for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
ismuted = !localVideo.getVideoTracks()[idx].enabled;
}
for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
localVideo.getVideoTracks()[idx].enabled = !localVideo.getVideoTracks()[idx].enabled;
}
var sess = getConferenceHandler(); var sess = getConferenceHandler();
if (sess) { if (sess) {
return; sess.toggleVideoMute(
function(isMuted){
if(isMuted) {
$('#video').removeClass("fa fa-video-camera fa-lg");
$('#video').addClass("fa fa-video-camera no-fa-video-camera fa-lg");
} else {
$('#video').removeClass("fa fa-video-camera no-fa-video-camera fa-lg");
$('#video').addClass("fa fa-video-camera fa-lg");
}
}
);
} }
sess.peerconnection.pendingop = ismuted ? 'unmute' : 'mute';
sess.peerconnection.modifySources();
} }
function toggleAudio() { function toggleAudio() {

View File

@ -38,7 +38,7 @@
<a class="button" onclick='buttonClick("#mute", "fa fa-microphone fa-lg fa fa-microphone-slash fa-lg");toggleAudio();'> <a class="button" onclick='buttonClick("#mute", "fa fa-microphone fa-lg fa fa-microphone-slash fa-lg");toggleAudio();'>
<i id="mute" title="Mute / unmute" class="fa fa-microphone fa-lg"></i></a> <i id="mute" title="Mute / unmute" class="fa fa-microphone fa-lg"></i></a>
<div class="header_button_separator"></div> <div class="header_button_separator"></div>
<a class="button" onclick='buttonClick("#video", "fa fa-video-camera fa-lg fa fa-video-camera no-fa-video-camera fa-lg");toggleVideo();'> <a class="button" onclick='buttonClick("#video");toggleVideo();'>
<i id="video" title="Start / stop camera" class="fa fa-video-camera fa-lg"></i></a> <i id="video" title="Start / stop camera" class="fa fa-video-camera fa-lg"></i></a>
<div class="header_button_separator"></div> <div class="header_button_separator"></div>
<a class="button" onclick="openLockDialog();"><i id="lockIcon" title="Lock/unlock room" class="fa fa-unlock fa-lg"></i></a> <a class="button" onclick="openLockDialog();"><i id="lockIcon" title="Lock/unlock room" class="fa fa-unlock fa-lg"></i></a>

View File

@ -189,7 +189,6 @@ TraceablePeerConnection.prototype.setRemoteDescription = function (description,
TraceablePeerConnection.prototype.hardMuteVideo = function (muted) { TraceablePeerConnection.prototype.hardMuteVideo = function (muted) {
this.pendingop = muted ? 'mute' : 'unmute'; this.pendingop = muted ? 'mute' : 'unmute';
this.modifySources();
}; };
TraceablePeerConnection.prototype.enqueueAddSsrc = function(channel, ssrcLines) { TraceablePeerConnection.prototype.enqueueAddSsrc = function(channel, ssrcLines) {
@ -338,9 +337,11 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) {
switch(self.pendingop) { switch(self.pendingop) {
case 'mute': case 'mute':
sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly'); sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
console.error("MUTE");
break; break;
case 'unmute': case 'unmute':
sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv'); sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
console.error("UNMUTE");
break; break;
} }
sdp.raw = sdp.session + sdp.media.join(''); sdp.raw = sdp.session + sdp.media.join('');

View File

@ -170,11 +170,17 @@ SessionBase.prototype.sendSSRCUpdateIq = function(sdpMediaSsrcs, sid, initiator,
// SDP-based mute by going recvonly/sendrecv // SDP-based mute by going recvonly/sendrecv
// FIXME: should probably black out the screen as well // FIXME: should probably black out the screen as well
SessionBase.prototype.hardMuteVideo = function (muted) { SessionBase.prototype.toggleVideoMute = function (callback) {
this.peerconnection.hardMuteVideo(muted); var ismuted = false;
var localVideo = connection.jingle.localVideo;
for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
ismuted = !localVideo.getVideoTracks()[idx].enabled;
}
for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
localVideo.getVideoTracks()[idx].enabled = !localVideo.getVideoTracks()[idx].enabled;
}
this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) { this.peerconnection.hardMuteVideo(!ismuted);
track.enabled = !muted; this.modifySources(callback(!ismuted));
});
}; };