Przeglądaj źródła

fix(conference.js): 2 tracks of the same media type

...caused by bad state as a result of timing issue around the prejoin flow.

If get user media call is delayed for a while and if user joins
the conference, when it hasn't completed then confrence.js will not assign
'localAudio' and 'localVideo' variables and will create additional media
tracks on unmute operation and add them to JitsiConference via replaceTracks
operation.
master
Pawel Domas 4 lat temu
rodzic
commit
f88061db06
1 zmienionych plików z 47 dodań i 30 usunięć
  1. 47
    30
      conference.js

+ 47
- 30
conference.js Wyświetl plik

595
         };
595
         };
596
     },
596
     },
597
 
597
 
598
+    /**
599
+     * Displays error notifications according to the state carried by {@code errors} object returned
600
+     * by {@link createInitialLocalTracks}.
601
+     * @param {Object} errors - the errors (if any) returned by {@link createInitialLocalTracks}.
602
+     *
603
+     * @returns {void}
604
+     * @private
605
+     */
606
+    _displayErrorsForCreateInitialLocalTracks(errors) {
607
+        const {
608
+            audioAndVideoError,
609
+            audioOnlyError,
610
+            screenSharingError,
611
+            videoOnlyError
612
+        } = errors;
613
+
614
+        // FIXME If there will be microphone error it will cover any screensharing dialog, but it's still better than in
615
+        // the reverse order where the screensharing dialog will sometimes be closing the microphone alert
616
+        // ($.prompt.close(); is called). Need to figure out dialogs chaining to fix that.
617
+        if (screenSharingError) {
618
+            this._handleScreenSharingError(screenSharingError);
619
+        }
620
+        if (audioAndVideoError || audioOnlyError) {
621
+            if (audioOnlyError || videoOnlyError) {
622
+                // If both requests for 'audio' + 'video' and 'audio' only failed, we assume that there are some
623
+                // problems with user's microphone and show corresponding dialog.
624
+                APP.store.dispatch(notifyMicError(audioOnlyError));
625
+                APP.store.dispatch(notifyCameraError(videoOnlyError));
626
+            } else {
627
+                // If request for 'audio' + 'video' failed, but request for 'audio' only was OK, we assume that we had
628
+                // problems with camera and show corresponding dialog.
629
+                APP.store.dispatch(notifyCameraError(audioAndVideoError));
630
+            }
631
+        }
632
+    },
633
+
598
     /**
634
     /**
599
      * Creates local media tracks and connects to a room. Will show error
635
      * Creates local media tracks and connects to a room. Will show error
600
      * dialogs in case accessing the local microphone and/or camera failed. Will
636
      * dialogs in case accessing the local microphone and/or camera failed. Will
615
      */
651
      */
616
     createInitialLocalTracksAndConnect(roomName, options = {}) {
652
     createInitialLocalTracksAndConnect(roomName, options = {}) {
617
         const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(options);
653
         const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(options);
618
-        const {
619
-            audioAndVideoError,
620
-            audioOnlyError,
621
-            screenSharingError,
622
-            videoOnlyError
623
-        } = errors;
624
 
654
 
625
         return Promise.all([ tryCreateLocalTracks, connect(roomName) ])
655
         return Promise.all([ tryCreateLocalTracks, connect(roomName) ])
626
             .then(([ tracks, con ]) => {
656
             .then(([ tracks, con ]) => {
627
-                // FIXME If there will be microphone error it will cover any
628
-                // screensharing dialog, but it's still better than in
629
-                // the reverse order where the screensharing dialog will
630
-                // sometimes be closing the microphone alert ($.prompt.close();
631
-                // is called). Need to figure out dialogs chaining to fix that.
632
-                if (screenSharingError) {
633
-                    this._handleScreenSharingError(screenSharingError);
634
-                }
635
-                if (audioAndVideoError || audioOnlyError) {
636
-                    if (audioOnlyError || videoOnlyError) {
637
-                        // If both requests for 'audio' + 'video' and 'audio'
638
-                        // only failed, we assume that there are some problems
639
-                        // with user's microphone and show corresponding dialog.
640
-                        APP.store.dispatch(notifyMicError(audioOnlyError));
641
-                        APP.store.dispatch(notifyCameraError(videoOnlyError));
642
-                    } else {
643
-                        // If request for 'audio' + 'video' failed, but request
644
-                        // for 'audio' only was OK, we assume that we had
645
-                        // problems with camera and show corresponding dialog.
646
-                        APP.store.dispatch(
647
-                            notifyCameraError(audioAndVideoError));
648
-                    }
649
-                }
657
+
658
+                this._displayErrorsForCreateInitialLocalTracks(errors);
650
 
659
 
651
                 return [ tracks, con ];
660
                 return [ tracks, con ];
652
             });
661
             });
755
             // they may remain as empty strings.
764
             // they may remain as empty strings.
756
             this._initDeviceList(true);
765
             this._initDeviceList(true);
757
 
766
 
758
-            return APP.store.dispatch(initPrejoin(tracks, errors));
767
+            if (isPrejoinPageVisible(APP.store.getState())) {
768
+                return APP.store.dispatch(initPrejoin(tracks, errors));
769
+            }
770
+
771
+            logger.debug('Prejoin screen no longer displayed at the time when tracks were created');
772
+
773
+            this._displayErrorsForCreateInitialLocalTracks(errors);
774
+
775
+            return this._setLocalAudioVideoStreams(tracks);
759
         }
776
         }
760
 
777
 
761
         const [ tracks, con ] = await this.createInitialLocalTracksAndConnect(
778
         const [ tracks, con ] = await this.createInitialLocalTracksAndConnect(

Ładowanie…
Anuluj
Zapisz