Bläddra i källkod

Fixes broken video muting.

j8
paweldomas 11 år sedan
förälder
incheckning
0da0f865a1
4 ändrade filer med 26 tillägg och 18 borttagningar
  1. 12
    11
      app.js
  2. 1
    1
      index.html
  3. 2
    1
      libs/strophe/strophe.jingle.adapter.js
  4. 11
    5
      libs/strophe/strophe.jingle.sessionbase.js

+ 12
- 11
app.js Visa fil

@@ -782,20 +782,21 @@ function getConferenceHandler() {
782 782
 
783 783
 function toggleVideo() {
784 784
     if (!(connection && connection.jingle.localVideo)) return;
785
-    var ismuted = false;
786
-    var localVideo = connection.jingle.localVideo;
787
-    for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
788
-        ismuted = !localVideo.getVideoTracks()[idx].enabled;
789
-    }
790
-    for (var idx = 0; idx < localVideo.getVideoTracks().length; idx++) {
791
-        localVideo.getVideoTracks()[idx].enabled = !localVideo.getVideoTracks()[idx].enabled;
792
-    }
785
+
793 786
     var sess = getConferenceHandler();
794 787
     if (sess) {
795
-        return;
788
+        sess.toggleVideoMute(
789
+            function(isMuted){
790
+                if(isMuted) {
791
+                    $('#video').removeClass("fa fa-video-camera fa-lg");
792
+                    $('#video').addClass("fa fa-video-camera no-fa-video-camera fa-lg");
793
+                } else {
794
+                    $('#video').removeClass("fa fa-video-camera no-fa-video-camera fa-lg");
795
+                    $('#video').addClass("fa fa-video-camera fa-lg");
796
+                }
797
+            }
798
+        );
796 799
     }
797
-    sess.peerconnection.pendingop = ismuted ? 'unmute' : 'mute';
798
-    sess.peerconnection.modifySources();
799 800
 }
800 801
 
801 802
 function toggleAudio() {

+ 1
- 1
index.html Visa fil

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

+ 2
- 1
libs/strophe/strophe.jingle.adapter.js Visa fil

@@ -189,7 +189,6 @@ TraceablePeerConnection.prototype.setRemoteDescription = function (description,
189 189
 
190 190
 TraceablePeerConnection.prototype.hardMuteVideo = function (muted) {
191 191
     this.pendingop = muted ? 'mute' : 'unmute';
192
-    this.modifySources();
193 192
 };
194 193
 
195 194
 TraceablePeerConnection.prototype.enqueueAddSsrc = function(channel, ssrcLines) {
@@ -338,9 +337,11 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) {
338 337
                             switch(self.pendingop) {
339 338
                                 case 'mute':
340 339
                                     sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
340
+                                    console.error("MUTE");
341 341
                                     break;
342 342
                                 case 'unmute':
343 343
                                     sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
344
+                                    console.error("UNMUTE");
344 345
                                     break;
345 346
                             }
346 347
                             sdp.raw = sdp.session + sdp.media.join('');

+ 11
- 5
libs/strophe/strophe.jingle.sessionbase.js Visa fil

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

Laddar…
Avbryt
Spara