Browse Source

Fixes video mute when the user is alone in the room.

master
hristoterezov 10 years ago
parent
commit
44e558e5a0
6 changed files with 69 additions and 61 deletions
  1. 1
    1
      index.html
  2. 34
    30
      libs/app.bundle.js
  3. 0
    2
      modules/UI/UI.js
  4. 1
    1
      modules/UI/videolayout/VideoLayout.js
  5. 2
    23
      modules/xmpp/JingleSession.js
  6. 31
    4
      modules/xmpp/xmpp.js

+ 1
- 1
index.html View File

19
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
19
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
20
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
20
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
21
     <script src="interface_config.js?v=5"></script>
21
     <script src="interface_config.js?v=5"></script>
22
-    <script src="libs/app.bundle.js?v=39"></script>
22
+    <script src="libs/app.bundle.js?v=40"></script>
23
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
23
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
24
     <link rel="stylesheet" href="css/font.css?v=6"/>
24
     <link rel="stylesheet" href="css/font.css?v=6"/>
25
     <link rel="stylesheet" href="css/toastr.css?v=1">
25
     <link rel="stylesheet" href="css/toastr.css?v=1">

+ 34
- 30
libs/app.bundle.js View File

1937
  * Mutes/unmutes the local video.
1937
  * Mutes/unmutes the local video.
1938
  */
1938
  */
1939
 UI.toggleVideo = function () {
1939
 UI.toggleVideo = function () {
1940
-    UIUtil.buttonClick("#video", "icon-camera icon-camera-disabled");
1941
-
1942
     setVideoMute(!APP.RTC.localVideo.isMuted());
1940
     setVideoMute(!APP.RTC.localVideo.isMuted());
1943
 };
1941
 };
1944
 
1942
 
8295
      */
8293
      */
8296
     $(document).bind('videomuted.muc', function (event, jid, value) {
8294
     $(document).bind('videomuted.muc', function (event, jid, value) {
8297
         var isMuted = (value === "true");
8295
         var isMuted = (value === "true");
8298
-        if(!APP.RTC.muteRemoteVideoStream(jid, isMuted))
8296
+        if(jid !== APP.xmpp.myJid() && !APP.RTC.muteRemoteVideoStream(jid, isMuted))
8299
             return;
8297
             return;
8300
 
8298
 
8301
         Avatar.showUserAvatar(jid, isMuted);
8299
         Avatar.showUserAvatar(jid, isMuted);
13177
         return;
13175
         return;
13178
     }
13176
     }
13179
 
13177
 
13180
-    var self = this;
13181
-    var localCallback = function (mute) {
13182
-        self.connection.emuc.addVideoInfoToPresence(mute);
13183
-        self.connection.emuc.sendPresence();
13184
-        return callback(mute)
13185
-    };
13186
-
13187
-    if (mute == APP.RTC.localVideo.isMuted())
13188
-    {
13189
-        // Even if no change occurs, the specified callback is to be executed.
13190
-        // The specified callback may, optionally, return a successCallback
13191
-        // which is to be executed as well.
13192
-        var successCallback = localCallback(mute);
13193
-
13194
-        if (successCallback) {
13195
-            successCallback();
13196
-        }
13197
-    } else {
13198
-        APP.RTC.localVideo.setMute(!mute);
13199
-
13200
-        this.hardMuteVideo(mute);
13178
+    this.hardMuteVideo(mute);
13201
 
13179
 
13202
-        this.modifySources(localCallback(mute));
13203
-    }
13180
+    this.modifySources(callback(mute));
13204
 };
13181
 };
13205
 
13182
 
13206
 // SDP-based mute by going recvonly/sendrecv
13183
 // SDP-based mute by going recvonly/sendrecv
16933
         }
16910
         }
16934
     },
16911
     },
16935
     setVideoMute: function (mute, callback, options) {
16912
     setVideoMute: function (mute, callback, options) {
16936
-       if(connection && APP.RTC.localVideo && connection.jingle.activecall)
16937
-       {
16938
-           connection.jingle.activecall.setVideoMute(mute, callback, options);
16939
-       }
16913
+        if(!connection || !APP.RTC.localVideo)
16914
+            return;
16915
+
16916
+        var localCallback = function (mute) {
16917
+            connection.emuc.addVideoInfoToPresence(mute);
16918
+            connection.emuc.sendPresence();
16919
+            return callback(mute);
16920
+        };
16921
+
16922
+        if (mute == APP.RTC.localVideo.isMuted())
16923
+        {
16924
+            // Even if no change occurs, the specified callback is to be executed.
16925
+            // The specified callback may, optionally, return a successCallback
16926
+            // which is to be executed as well.
16927
+            var successCallback = localCallback(mute);
16928
+
16929
+            if (successCallback) {
16930
+                successCallback();
16931
+            }
16932
+        } else {
16933
+            APP.RTC.localVideo.setMute(!mute);
16934
+            if(connection.jingle.activecall)
16935
+            {
16936
+                connection.jingle.activecall.setVideoMute(
16937
+                    mute, localCallback, options);
16938
+            }
16939
+            else {
16940
+                localCallback(mute);
16941
+            }
16942
+
16943
+        }
16940
     },
16944
     },
16941
     setAudioMute: function (mute, callback) {
16945
     setAudioMute: function (mute, callback) {
16942
         if (!(connection && APP.RTC.localAudio)) {
16946
         if (!(connection && APP.RTC.localAudio)) {

+ 0
- 2
modules/UI/UI.js View File

694
  * Mutes/unmutes the local video.
694
  * Mutes/unmutes the local video.
695
  */
695
  */
696
 UI.toggleVideo = function () {
696
 UI.toggleVideo = function () {
697
-    UIUtil.buttonClick("#video", "icon-camera icon-camera-disabled");
698
-
699
     setVideoMute(!APP.RTC.localVideo.isMuted());
697
     setVideoMute(!APP.RTC.localVideo.isMuted());
700
 };
698
 };
701
 
699
 

+ 1
- 1
modules/UI/videolayout/VideoLayout.js View File

1787
      */
1787
      */
1788
     $(document).bind('videomuted.muc', function (event, jid, value) {
1788
     $(document).bind('videomuted.muc', function (event, jid, value) {
1789
         var isMuted = (value === "true");
1789
         var isMuted = (value === "true");
1790
-        if(!APP.RTC.muteRemoteVideoStream(jid, isMuted))
1790
+        if(jid !== APP.xmpp.myJid() && !APP.RTC.muteRemoteVideoStream(jid, isMuted))
1791
             return;
1791
             return;
1792
 
1792
 
1793
         Avatar.showUserAvatar(jid, isMuted);
1793
         Avatar.showUserAvatar(jid, isMuted);

+ 2
- 23
modules/xmpp/JingleSession.js View File

1109
         return;
1109
         return;
1110
     }
1110
     }
1111
 
1111
 
1112
-    var self = this;
1113
-    var localCallback = function (mute) {
1114
-        self.connection.emuc.addVideoInfoToPresence(mute);
1115
-        self.connection.emuc.sendPresence();
1116
-        return callback(mute)
1117
-    };
1118
-
1119
-    if (mute == APP.RTC.localVideo.isMuted())
1120
-    {
1121
-        // Even if no change occurs, the specified callback is to be executed.
1122
-        // The specified callback may, optionally, return a successCallback
1123
-        // which is to be executed as well.
1124
-        var successCallback = localCallback(mute);
1125
-
1126
-        if (successCallback) {
1127
-            successCallback();
1128
-        }
1129
-    } else {
1130
-        APP.RTC.localVideo.setMute(!mute);
1112
+    this.hardMuteVideo(mute);
1131
 
1113
 
1132
-        this.hardMuteVideo(mute);
1133
-
1134
-        this.modifySources(localCallback(mute));
1135
-    }
1114
+    this.modifySources(callback(mute));
1136
 };
1115
 };
1137
 
1116
 
1138
 // SDP-based mute by going recvonly/sendrecv
1117
 // SDP-based mute by going recvonly/sendrecv

+ 31
- 4
modules/xmpp/xmpp.js View File

252
         }
252
         }
253
     },
253
     },
254
     setVideoMute: function (mute, callback, options) {
254
     setVideoMute: function (mute, callback, options) {
255
-       if(connection && APP.RTC.localVideo && connection.jingle.activecall)
256
-       {
257
-           connection.jingle.activecall.setVideoMute(mute, callback, options);
258
-       }
255
+        if(!connection || !APP.RTC.localVideo)
256
+            return;
257
+
258
+        var localCallback = function (mute) {
259
+            connection.emuc.addVideoInfoToPresence(mute);
260
+            connection.emuc.sendPresence();
261
+            return callback(mute);
262
+        };
263
+
264
+        if (mute == APP.RTC.localVideo.isMuted())
265
+        {
266
+            // Even if no change occurs, the specified callback is to be executed.
267
+            // The specified callback may, optionally, return a successCallback
268
+            // which is to be executed as well.
269
+            var successCallback = localCallback(mute);
270
+
271
+            if (successCallback) {
272
+                successCallback();
273
+            }
274
+        } else {
275
+            APP.RTC.localVideo.setMute(!mute);
276
+            if(connection.jingle.activecall)
277
+            {
278
+                connection.jingle.activecall.setVideoMute(
279
+                    mute, localCallback, options);
280
+            }
281
+            else {
282
+                localCallback(mute);
283
+            }
284
+
285
+        }
259
     },
286
     },
260
     setAudioMute: function (mute, callback) {
287
     setAudioMute: function (mute, callback) {
261
         if (!(connection && APP.RTC.localAudio)) {
288
         if (!(connection && APP.RTC.localAudio)) {

Loading…
Cancel
Save