Browse Source

Merge pull request #16 from paweldomas/fix_local_track_attach

Fixes crash on "this.rtc" being "undefined" when JitsiLocalTrack.atta…
master
hristoterezov 9 years ago
parent
commit
6d5c36bfc6
2 changed files with 22 additions and 2 deletions
  1. 8
    0
      modules/RTC/JitsiLocalTrack.js
  2. 14
    2
      modules/RTC/JitsiTrack.js

+ 8
- 0
modules/RTC/JitsiLocalTrack.js View File

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 View File

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.

Loading…
Cancel
Save