Quellcode durchsuchen

Fixes crash on "this.rtc" being "undefined" when JitsiLocalTrack.attach is called before it's added to the conference.

master
paweldomas vor 9 Jahren
Ursprung
Commit
3819387f78
2 geänderte Dateien mit 22 neuen und 2 gelöschten Zeilen
  1. 8
    0
      modules/RTC/JitsiLocalTrack.js
  2. 14
    2
      modules/RTC/JitsiTrack.js

+ 8
- 0
modules/RTC/JitsiLocalTrack.js Datei anzeigen

175
  */
175
  */
176
 JitsiLocalTrack.prototype._setRTC = function (rtc) {
176
 JitsiLocalTrack.prototype._setRTC = function (rtc) {
177
     this.rtc = rtc;
177
     this.rtc = rtc;
178
+    // We want to keep up with postponed events which should have been fired
179
+    // on "attach" call, but for local track we not always have the conference
180
+    // before attaching. However this may result in duplicated events if they
181
+    // have been triggered on "attach" already.
182
+    for(var i = 0; i < this.containers.length; i++)
183
+    {
184
+        this._maybeFireTrackAttached(this.containers[i]);
185
+    }
178
 };
186
 };
179
 
187
 
180
 /**
188
 /**

+ 14
- 2
modules/RTC/JitsiTrack.js Datei anzeigen

150
     }
150
     }
151
 };
151
 };
152
 
152
 
153
+/**
154
+ * Eventually will trigger RTCEvents.TRACK_ATTACHED event.
155
+ * @param container the video/audio container to which this stream is attached
156
+ *        and for which event will be fired.
157
+ * @private
158
+ */
159
+JitsiTrack.prototype._maybeFireTrackAttached = function (container) {
160
+    if (this.rtc && container) {
161
+        this.rtc.eventEmitter.emit(RTCEvents.TRACK_ATTACHED, this, container);
162
+    }
163
+};
164
+
153
 /**
165
 /**
154
  * Mutes the track.
166
  * Mutes the track.
155
  */
167
  */
194
     }
206
     }
195
     this.containers.push(container);
207
     this.containers.push(container);
196
 
208
 
197
-    this.rtc.eventEmitter.emit(RTCEvents.TRACK_ATTACHED, this, container);
209
+    this._maybeFireTrackAttached(container);
198
 
210
 
199
     return container;
211
     return container;
200
-}
212
+};
201
 
213
 
202
 /**
214
 /**
203
  * Removes the track from the passed HTML container.
215
  * Removes the track from the passed HTML container.

Laden…
Abbrechen
Speichern