diff --git a/app.js b/app.js index efdd6d14c..a7584d099 100644 --- a/app.js +++ b/app.js @@ -782,20 +782,21 @@ function getConferenceHandler() { function toggleVideo() { 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(); 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() { diff --git a/index.html b/index.html index a2904c8d0..392fbc08e 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,7 @@
- + diff --git a/libs/strophe/strophe.jingle.adapter.js b/libs/strophe/strophe.jingle.adapter.js index 40200040c..b24f82dad 100644 --- a/libs/strophe/strophe.jingle.adapter.js +++ b/libs/strophe/strophe.jingle.adapter.js @@ -189,7 +189,6 @@ TraceablePeerConnection.prototype.setRemoteDescription = function (description, TraceablePeerConnection.prototype.hardMuteVideo = function (muted) { this.pendingop = muted ? 'mute' : 'unmute'; - this.modifySources(); }; TraceablePeerConnection.prototype.enqueueAddSsrc = function(channel, ssrcLines) { @@ -338,9 +337,11 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) { switch(self.pendingop) { case 'mute': sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly'); + console.error("MUTE"); break; case 'unmute': sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv'); + console.error("UNMUTE"); break; } sdp.raw = sdp.session + sdp.media.join(''); diff --git a/libs/strophe/strophe.jingle.sessionbase.js b/libs/strophe/strophe.jingle.sessionbase.js index b35d2a6fe..ac389d2c6 100644 --- a/libs/strophe/strophe.jingle.sessionbase.js +++ b/libs/strophe/strophe.jingle.sessionbase.js @@ -170,11 +170,17 @@ SessionBase.prototype.sendSSRCUpdateIq = function(sdpMediaSsrcs, sid, initiator, // SDP-based mute by going recvonly/sendrecv // 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) { - track.enabled = !muted; - }); + this.peerconnection.hardMuteVideo(!ismuted); + this.modifySources(callback(!ismuted)); }; \ No newline at end of file