From 5939eaf78a388dee02d799a23e43a53a127e6d32 Mon Sep 17 00:00:00 2001 From: Zalmoxisus Date: Tue, 3 Feb 2015 02:08:36 +0200 Subject: [PATCH] Fixes issue with video mute (toggleVideo) on an empty room --- libs/app.bundle.js | 57 ++++++++++++++++++----------------- modules/xmpp/JingleSession.js | 27 ++--------------- modules/xmpp/xmpp.js | 30 ++++++++++++++++-- 3 files changed, 58 insertions(+), 56 deletions(-) diff --git a/libs/app.bundle.js b/libs/app.bundle.js index d189ad33f..e18cfb82e 100644 --- a/libs/app.bundle.js +++ b/libs/app.bundle.js @@ -12360,31 +12360,8 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) { } else if (this.videoMuteByUser) { return; } - - var self = this; - var localCallback = function (mute) { - self.connection.emuc.addVideoInfoToPresence(mute); - self.connection.emuc.sendPresence(); - return callback(mute) - }; - - if (mute == 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); - - this.hardMuteVideo(mute); - - this.modifySources(localCallback(mute)); - } + + APP.xmpp.setVideoMute(mute, callback, options); }; // SDP-based mute by going recvonly/sendrecv @@ -15915,9 +15892,33 @@ var XMPP = { } }, setVideoMute: function (mute, callback, options) { - if(connection && APP.RTC.localVideo && connection.jingle.activecall) - { - connection.jingle.activecall.setVideoMute(mute, callback, options); + if(connection && APP.RTC.localVideo) { + var self = this; + var localCallback = function (mute) { + connection.emuc.addVideoInfoToPresence(mute); + connection.emuc.sendPresence(); + 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) { + connection.jingle.activecall.hardMuteVideo(mute); + + connection.jingle.activecall.modifySources(localCallback(mute)); + } + else localCallback(mute); + } } }, setAudioMute: function (mute, callback) { diff --git a/modules/xmpp/JingleSession.js b/modules/xmpp/JingleSession.js index db1724470..8862ef0a2 100644 --- a/modules/xmpp/JingleSession.js +++ b/modules/xmpp/JingleSession.js @@ -1108,31 +1108,8 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) { } else if (this.videoMuteByUser) { return; } - - var self = this; - var localCallback = function (mute) { - self.connection.emuc.addVideoInfoToPresence(mute); - self.connection.emuc.sendPresence(); - return callback(mute) - }; - - if (mute == 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); - - this.hardMuteVideo(mute); - - this.modifySources(localCallback(mute)); - } + + APP.xmpp.setVideoMute(mute, callback, options); }; // SDP-based mute by going recvonly/sendrecv diff --git a/modules/xmpp/xmpp.js b/modules/xmpp/xmpp.js index 7dcb653d3..d12646119 100644 --- a/modules/xmpp/xmpp.js +++ b/modules/xmpp/xmpp.js @@ -252,9 +252,33 @@ var XMPP = { } }, setVideoMute: function (mute, callback, options) { - if(connection && APP.RTC.localVideo && connection.jingle.activecall) - { - connection.jingle.activecall.setVideoMute(mute, callback, options); + if(connection && APP.RTC.localVideo) { + var self = this; + var localCallback = function (mute) { + connection.emuc.addVideoInfoToPresence(mute); + connection.emuc.sendPresence(); + 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) { + connection.jingle.activecall.hardMuteVideo(mute); + + connection.jingle.activecall.modifySources(localCallback(mute)); + } + else localCallback(mute); + } } }, setAudioMute: function (mute, callback) {