Browse Source

ref(large-video): combine selectParticipant logic from web (#3266)

* ref(large-video): combine selectParticipant logic from web

Currently native/middleware/redux has its own logic for selecting a participant
on the bridge. To have the logic web respect that logic, a few changes are
needed.
- Web no longer has its own call to selectParticipant.
- To keep in line with web logic selectParticipant action should act even when
  there is no track. This makes it so that when a participant does get a track
  that the bridge will send high quality. The bridge can already handle when the
  selected participant does not have a video track.
- The timing of web is such that on joining an existing conference, a
  participant joins and the participant's tracks get updated and then the
  conference is joined. The result is selectParticipant does not get fired
  because it no-ops when there is no conference. To avoid having to make
  uncertain changes (to be lazy), update the selected participant on conference
  join as well.

* squash: update comment, pass message to error handler
j8
virtuacoplenny 6 years ago
parent
commit
afd2aea79c

+ 0
- 21
conference.js View File

7
 
7
 
8
 import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
8
 import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
9
 
9
 
10
-import { reportError } from './modules/util/helpers';
11
-
12
 import * as RemoteControlEvents
10
 import * as RemoteControlEvents
13
     from './service/remotecontrol/RemoteControlEvents';
11
     from './service/remotecontrol/RemoteControlEvents';
14
 import UIEvents from './service/UI/UIEvents';
12
 import UIEvents from './service/UI/UIEvents';
18
 import {
16
 import {
19
     createDeviceChangedEvent,
17
     createDeviceChangedEvent,
20
     createScreenSharingEvent,
18
     createScreenSharingEvent,
21
-    createSelectParticipantFailedEvent,
22
     createStreamSwitchDelayEvent,
19
     createStreamSwitchDelayEvent,
23
     createTrackMutedEvent,
20
     createTrackMutedEvent,
24
     sendAnalytics
21
     sendAnalytics
1813
                     room.sendTextMessage(message);
1810
                     room.sendTextMessage(message);
1814
                 });
1811
                 });
1815
             }
1812
             }
1816
-
1817
-            APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, id => {
1818
-                APP.API.notifyOnStageParticipantChanged(id);
1819
-                try {
1820
-                    // do not try to select participant if there is none (we
1821
-                    // are alone in the room), otherwise an error will be
1822
-                    // thrown cause reporting mechanism is not available
1823
-                    // (datachannels currently)
1824
-                    if (room.getParticipants().length === 0) {
1825
-                        return;
1826
-                    }
1827
-
1828
-                    room.selectParticipant(id);
1829
-                } catch (e) {
1830
-                    sendAnalytics(createSelectParticipantFailedEvent(e));
1831
-                    reportError(e);
1832
-                }
1833
-            });
1834
         }
1813
         }
1835
 
1814
 
1836
         room.on(JitsiConferenceEvents.CONNECTION_INTERRUPTED, () => {
1815
         room.on(JitsiConferenceEvents.CONNECTION_INTERRUPTED, () => {

+ 1
- 1
modules/UI/videolayout/VideoLayout.js View File

960
             // FIXME video type is not the same thing as container type
960
             // FIXME video type is not the same thing as container type
961
 
961
 
962
             if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
962
             if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
963
-                eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
963
+                APP.API.notifyOnStageParticipantChanged(id);
964
             }
964
             }
965
 
965
 
966
             let oldSmallVideo;
966
             let oldSmallVideo;

+ 19
- 13
react/features/large-video/actions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import {
4
+    createSelectParticipantFailedEvent,
5
+    sendAnalytics
6
+} from '../analytics';
3
 import { _handleParticipantError } from '../base/conference';
7
 import { _handleParticipantError } from '../base/conference';
4
-import { MEDIA_TYPE, VIDEO_TYPE } from '../base/media';
5
-import { getTrackByMediaTypeAndParticipant } from '../base/tracks';
8
+import { MEDIA_TYPE } from '../base/media';
6
 
9
 
7
 import {
10
 import {
8
     SELECT_LARGE_VIDEO_PARTICIPANT,
11
     SELECT_LARGE_VIDEO_PARTICIPANT,
9
     UPDATE_KNOWN_LARGE_VIDEO_RESOLUTION
12
     UPDATE_KNOWN_LARGE_VIDEO_RESOLUTION
10
 } from './actionTypes';
13
 } from './actionTypes';
11
 
14
 
15
+declare var APP: Object;
16
+
12
 /**
17
 /**
13
  * Signals conference to select a participant.
18
  * Signals conference to select a participant.
14
  *
19
  *
21
 
26
 
22
         if (conference) {
27
         if (conference) {
23
             const largeVideo = state['features/large-video'];
28
             const largeVideo = state['features/large-video'];
24
-            const tracks = state['features/base/tracks'];
25
-
26
             const id = largeVideo.participantId;
29
             const id = largeVideo.participantId;
27
-            const videoTrack
28
-                = getTrackByMediaTypeAndParticipant(
29
-                    tracks,
30
-                    MEDIA_TYPE.VIDEO,
31
-                    id);
32
 
30
 
33
             try {
31
             try {
34
-                conference.selectParticipant(
35
-                    videoTrack && videoTrack.videoType === VIDEO_TYPE.CAMERA
36
-                        ? id
37
-                        : null);
32
+                conference.selectParticipant(id);
38
             } catch (err) {
33
             } catch (err) {
39
                 _handleParticipantError(err);
34
                 _handleParticipantError(err);
35
+
36
+                sendAnalytics(createSelectParticipantFailedEvent(err));
37
+
38
+                if (typeof APP === 'object' && window.onerror) {
39
+                    window.onerror(
40
+                        `Failed to select participant ${id}`,
41
+                        null, // source
42
+                        null, // lineno
43
+                        null, // colno
44
+                        err);
45
+                }
40
             }
46
             }
41
         }
47
         }
42
     };
48
     };

+ 8
- 0
react/features/large-video/middleware.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { CONFERENCE_JOINED } from '../base/conference';
3
 import {
4
 import {
4
     DOMINANT_SPEAKER_CHANGED,
5
     DOMINANT_SPEAKER_CHANGED,
5
     PARTICIPANT_JOINED,
6
     PARTICIPANT_JOINED,
46
         store.dispatch(selectParticipantInLargeVideo());
47
         store.dispatch(selectParticipantInLargeVideo());
47
         break;
48
         break;
48
 
49
 
50
+    case CONFERENCE_JOINED:
51
+        // Ensure a participant is selected on conference join. This addresses
52
+        // the case where video tracks were received before CONFERENCE_JOINED
53
+        // fired; without the conference selection may not happen.
54
+        store.dispatch(selectParticipant());
55
+        break;
56
+
49
     case TRACK_UPDATED:
57
     case TRACK_UPDATED:
50
         // In order to minimize re-calculations, we need to select participant
58
         // In order to minimize re-calculations, we need to select participant
51
         // only if the videoType of the current participant rendered in
59
         // only if the videoType of the current participant rendered in

+ 0
- 1
service/UI/UIEvents.js View File

1
 export default {
1
 export default {
2
     NICKNAME_CHANGED: 'UI.nickname_changed',
2
     NICKNAME_CHANGED: 'UI.nickname_changed',
3
-    SELECTED_ENDPOINT: 'UI.selected_endpoint',
4
     PINNED_ENDPOINT: 'UI.pinned_endpoint',
3
     PINNED_ENDPOINT: 'UI.pinned_endpoint',
5
 
4
 
6
     /**
5
     /**

Loading…
Cancel
Save