|
|
@@ -308,17 +308,27 @@ JitsiConference.prototype.setSubject = function (subject) {
|
|
308
|
308
|
* Adds JitsiLocalTrack object to the conference.
|
|
309
|
309
|
* @param track the JitsiLocalTrack object.
|
|
310
|
310
|
* @returns {Promise<JitsiLocalTrack>}
|
|
311
|
|
- * @throws will throw and error if track is video track
|
|
312
|
|
- * and there is already another video track in the conference.
|
|
|
311
|
+ * @throws {Error} if the specified track is a video track and there is already
|
|
|
312
|
+ * another video track in the conference.
|
|
313
|
313
|
*/
|
|
314
|
314
|
JitsiConference.prototype.addTrack = function (track) {
|
|
315
|
|
- if(track.disposed)
|
|
316
|
|
- {
|
|
|
315
|
+ if (track.disposed) {
|
|
317
|
316
|
throw new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED);
|
|
318
|
317
|
}
|
|
319
|
318
|
|
|
320
|
|
- if (track.isVideoTrack() && this.rtc.getLocalVideoTrack()) {
|
|
321
|
|
- throw new Error("cannot add second video track to the conference");
|
|
|
319
|
+ if (track.isVideoTrack()) {
|
|
|
320
|
+ // Ensure there's exactly 1 local video track in the conference.
|
|
|
321
|
+ var localVideoTrack = this.rtc.getLocalVideoTrack();
|
|
|
322
|
+ if (localVideoTrack) {
|
|
|
323
|
+ // Don't be excessively harsh and severe if the API client happens
|
|
|
324
|
+ // to attempt to add the same local video track twice.
|
|
|
325
|
+ if (track === localVideoTrack) {
|
|
|
326
|
+ return Promise.resolve(track);
|
|
|
327
|
+ } else {
|
|
|
328
|
+ throw new Error(
|
|
|
329
|
+ "cannot add second video track to the conference");
|
|
|
330
|
+ }
|
|
|
331
|
+ }
|
|
322
|
332
|
}
|
|
323
|
333
|
|
|
324
|
334
|
track.ssrcHandler = function (conference, ssrcMap) {
|