ソースを参照

Do not subscribe each JitsiTrack to RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED, instead subscribe once in RTC

master
tsareg 9年前
コミット
6500f9e1f4
4個のファイルの変更22行の追加13行の削除
  1. 2
    1
      modules/RTC/JitsiLocalTrack.js
  2. 2
    0
      modules/RTC/JitsiRemoteTrack.js
  3. 1
    12
      modules/RTC/JitsiTrack.js
  4. 17
    0
      modules/RTC/RTC.js

+ 2
- 1
modules/RTC/JitsiLocalTrack.js ファイルの表示

36
     this.resolution = resolution;
36
     this.resolution = resolution;
37
     this.deviceId = deviceId;
37
     this.deviceId = deviceId;
38
     this.startMuted = false;
38
     this.startMuted = false;
39
+    this.disposed = false;
39
     //FIXME: This dependacy is not necessary.
40
     //FIXME: This dependacy is not necessary.
40
     this.conference = null;
41
     this.conference = null;
41
     this.initialMSID = this.getMSID();
42
     this.initialMSID = this.getMSID();
282
         this.detach();
283
         this.detach();
283
     }
284
     }
284
 
285
 
285
-    JitsiTrack.prototype.dispose.call(this);
286
+    this.disposed = true;
286
 
287
 
287
     RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
288
     RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
288
         this._onDeviceListChanged);
289
         this._onDeviceListChanged);

+ 2
- 0
modules/RTC/JitsiRemoteTrack.js ファイルの表示

84
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
84
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
85
 };
85
 };
86
 
86
 
87
+delete JitsiRemoteTrack.prototype.dispose;
88
+
87
 module.exports = JitsiRemoteTrack;
89
 module.exports = JitsiRemoteTrack;

+ 1
- 12
modules/RTC/JitsiTrack.js ファイルの表示

70
     this.type = trackMediaType;
70
     this.type = trackMediaType;
71
     this.track = track;
71
     this.track = track;
72
     this.videoType = videoType;
72
     this.videoType = videoType;
73
-    this.disposed = false;
74
 
73
 
75
     if(stream) {
74
     if(stream) {
76
         if (RTCBrowserType.isFirefox()) {
75
         if (RTCBrowserType.isFirefox()) {
78
         }
77
         }
79
         addMediaStreamInactiveHandler(stream, streamInactiveHandler);
78
         addMediaStreamInactiveHandler(stream, streamInactiveHandler);
80
     }
79
     }
81
-
82
-    this._onAudioOutputDeviceChanged = this.setAudioOutput.bind(this);
83
-
84
-    if (this.isAudioTrack()) {
85
-        RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
86
-            this._onAudioOutputDeviceChanged);
87
-    }
88
 }
80
 }
89
 
81
 
90
 /**
82
 /**
225
 
217
 
226
 /**
218
 /**
227
  * Dispose sending the media track. And removes it from the HTML.
219
  * Dispose sending the media track. And removes it from the HTML.
220
+ * NOTE: Works for local tracks only.
228
  */
221
  */
229
 JitsiTrack.prototype.dispose = function () {
222
 JitsiTrack.prototype.dispose = function () {
230
-    RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
231
-        this._onAudioOutputDeviceChanged);
232
-
233
-    this.disposed = true;
234
 };
223
 };
235
 
224
 
236
 /**
225
 /**

+ 17
- 0
modules/RTC/RTC.js ファイルの表示

59
             videoTrack._setVideoType(data.value);
59
             videoTrack._setVideoType(data.value);
60
         }
60
         }
61
     });
61
     });
62
+
63
+    // switch audio output device on all local and remote audio tracks
64
+    RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
65
+        function (deviceId) {
66
+            if (RTCUtils.isDeviceChangeAvailable('output')) {
67
+                if (self.localAudio) {
68
+                    self.localAudio.setAudioOutput(deviceId);
69
+                }
70
+
71
+                for (var key in self.remoteTracks) {
72
+                    if (self.remoteTracks.hasOwnProperty(key)
73
+                        && self.remoteTracks[key].audio) {
74
+                        self.remoteTracks[key].audio.setAudioOutput(deviceId);
75
+                    }
76
+                }
77
+            }
78
+        });
62
 }
79
 }
63
 
80
 
64
 /**
81
 /**

読み込み中…
キャンセル
保存