Browse Source

Fixes video mute in Firefox. Disables VideoSSRCHack for Firefox by default.

master
paweldomas 10 years ago
parent
commit
ab4c29eddc
2 changed files with 33 additions and 2 deletions
  1. 4
    2
      modules/RTC/LocalStream.js
  2. 29
    0
      modules/xmpp/VideoSSRCHack.js

+ 4
- 2
modules/RTC/LocalStream.js View File

@@ -66,9 +66,11 @@ LocalStream.prototype.setMute = function (mute)
66 66
     var eventType = isAudio ? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE;
67 67
 
68 68
     if ((window.location.protocol != "https:" && this.isGUMStream) ||
69
-        (isAudio && this.isGUMStream) || this.videoType === "screen") {
70
-        var tracks = this.getTracks();
69
+        (isAudio && this.isGUMStream) || this.videoType === "screen" ||
70
+        // FIXME FF does not support 'removeStream' method used to mute
71
+        RTCBrowserType.isFirefox()) {
71 72
 
73
+        var tracks = this.getTracks();
72 74
         for (var idx = 0; idx < tracks.length; idx++) {
73 75
             tracks[idx].enabled = !mute;
74 76
         }

+ 29
- 0
modules/xmpp/VideoSSRCHack.js View File

@@ -19,6 +19,14 @@
19 19
  */
20 20
 
21 21
 var SDP = require('./SDP');
22
+var RTCBrowserType = require('../RTC/RTCBrowserType');
23
+
24
+/**
25
+ * The hack is enabled on all browsers except FF by default
26
+ * FIXME finish the hack once removeStream method is implemented in FF
27
+ * @type {boolean}
28
+ */
29
+var isEnabled = !RTCBrowserType.isFirefox();
22 30
 
23 31
 /**
24 32
  * Stored SSRC of local video stream.
@@ -94,6 +102,9 @@ var LocalVideoSSRCHack = {
94 102
      *        which will be scanned for local video SSRC.
95 103
      */
96 104
     processSessionInit: function (sessionInit) {
105
+        if (!isEnabled)
106
+            return;
107
+
97 108
         if (localVideoSSRC) {
98 109
             console.error("Local SSRC stored already: " + localVideoSSRC);
99 110
             return;
@@ -109,6 +120,9 @@ var LocalVideoSSRCHack = {
109 120
      * @returns modified <tt>localDescription</tt> object.
110 121
      */
111 122
     mungeLocalVideoSSRC: function (localDescription) {
123
+        if (!isEnabled)
124
+            return localDescription;
125
+
112 126
         // IF we have local video SSRC stored make sure it is replaced
113 127
         // with old SSRC
114 128
         if (localVideoSSRC) {
@@ -144,6 +158,9 @@ var LocalVideoSSRCHack = {
144 158
      *          a Strophe IQ Builder instance, but DOM element tree.
145 159
      */
146 160
     processSourceAdd: function (sourceAdd) {
161
+        if (!isEnabled)
162
+            return sourceAdd;
163
+
147 164
         if (!localVideoSSRC) {
148 165
             // Store local SSRC if available
149 166
             storeLocalVideoSSRC(sourceAdd);
@@ -163,7 +180,19 @@ var LocalVideoSSRCHack = {
163 180
      *          a Strophe IQ Builder instance, but DOM element tree.
164 181
      */
165 182
     processSourceRemove: function (sourceRemove) {
183
+        if (!isEnabled)
184
+            return sourceRemove;
185
+
166 186
         return filterOutSource(sourceRemove, 'source-remove');
187
+    },
188
+
189
+    /**
190
+     * Turns the hack on or off
191
+     * @param enabled <tt>true</tt> to enable the hack or <tt>false</tt>
192
+     *                to disable it
193
+     */
194
+    setEnabled: function (enabled) {
195
+        isEnabled = enabled;
167 196
     }
168 197
 };
169 198
 

Loading…
Cancel
Save