瀏覽代碼

ref(StatusIndicators): Use video muted from redux.

master
Hristo Terezov 5 年之前
父節點
當前提交
ca2343c31a

+ 1
- 1
conference.js 查看文件

@@ -3039,7 +3039,7 @@ export default {
3039 3039
      * @param {boolean} muted - New muted status.
3040 3040
      */
3041 3041
     setVideoMuteStatus(muted) {
3042
-        APP.UI.setVideoMuted(this.getMyUserId(), muted);
3042
+        APP.UI.setVideoMuted(this.getMyUserId());
3043 3043
         APP.API.notifyVideoMutedStatusChanged(muted);
3044 3044
     },
3045 3045
 

+ 2
- 2
modules/UI/UI.js 查看文件

@@ -366,8 +366,8 @@ UI.setAudioMuted = function(id, muted) {
366 366
 /**
367 367
  * Sets muted video state for participant
368 368
  */
369
-UI.setVideoMuted = function(id, muted) {
370
-    VideoLayout.onVideoMute(id, muted);
369
+UI.setVideoMuted = function(id) {
370
+    VideoLayout.onVideoMute(id);
371 371
     if (APP.conference.isLocalId(id)) {
372 372
         APP.conference.updateVideoIconEnabled();
373 373
     }

+ 0
- 1
modules/UI/shared_video/SharedVideoThumb.js 查看文件

@@ -26,7 +26,6 @@ export default class SharedVideoThumb extends SmallVideo {
26 26
         this.$container = $(this.container);
27 27
         this._setThumbnailSize();
28 28
         this.bindHoverHandler();
29
-        this.isVideoMuted = true;
30 29
         this.updateDisplayName();
31 30
         this.container.onclick = this._onContainerClick;
32 31
     }

+ 1
- 0
modules/UI/videolayout/LocalVideo.js 查看文件

@@ -63,6 +63,7 @@ export default class LocalVideo extends SmallVideo {
63 63
 
64 64
         this.addAudioLevelIndicator();
65 65
         this.updateIndicators();
66
+        this.updateStatusBar();
66 67
 
67 68
         this.container.onclick = this._onContainerClick;
68 69
     }

+ 10
- 6
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -12,10 +12,13 @@ import { i18next } from '../../../react/features/base/i18n';
12 12
 import {
13 13
     JitsiParticipantConnectionStatus
14 14
 } from '../../../react/features/base/lib-jitsi-meet';
15
+import { MEDIA_TYPE } from '../../../react/features/base/media';
15 16
 import {
17
+    getParticipantById,
16 18
     getPinnedParticipant,
17 19
     pinParticipant
18 20
 } from '../../../react/features/base/participants';
21
+import { isRemoteTrackMuted } from '../../../react/features/base/tracks';
19 22
 import { PresenceLabel } from '../../../react/features/presence-status';
20 23
 import {
21 24
     REMOTE_CONTROL_MENU_STATES,
@@ -310,11 +313,10 @@ export default class RemoteVideo extends SmallVideo {
310 313
     }
311 314
 
312 315
     /**
313
-     * @inheritDoc
314
-     * @override
316
+     * Video muted status changed handler.
315 317
      */
316
-    setVideoMutedView(isMuted) {
317
-        super.setVideoMutedView(isMuted);
318
+    onVideoMute() {
319
+        super.updateView();
318 320
 
319 321
         // Update 'mutedWhileDisconnected' flag
320 322
         this._figureOutMutedWhileDisconnected();
@@ -328,10 +330,12 @@ export default class RemoteVideo extends SmallVideo {
328 330
      */
329 331
     _figureOutMutedWhileDisconnected() {
330 332
         const isActive = this.isConnectionActive();
333
+        const isVideoMuted
334
+            = isRemoteTrackMuted(APP.store.getState()['features/base/tracks'], MEDIA_TYPE.VIDEO, this.id);
331 335
 
332
-        if (!isActive && this.isVideoMuted) {
336
+        if (!isActive && isVideoMuted) {
333 337
             this.mutedWhileDisconnected = true;
334
-        } else if (isActive && !this.isVideoMuted) {
338
+        } else if (isActive && !isVideoMuted) {
335 339
             this.mutedWhileDisconnected = false;
336 340
         }
337 341
     }

+ 16
- 17
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -11,11 +11,15 @@ import { Provider } from 'react-redux';
11 11
 import { AudioLevelIndicator } from '../../../react/features/audio-level-indicator';
12 12
 import { Avatar as AvatarDisplay } from '../../../react/features/base/avatar';
13 13
 import { i18next } from '../../../react/features/base/i18n';
14
+import { MEDIA_TYPE } from '../../../react/features/base/media';
14 15
 import {
16
+    getLocalParticipant,
17
+    getParticipantById,
15 18
     getParticipantCount,
16 19
     getPinnedParticipant,
17 20
     pinParticipant
18 21
 } from '../../../react/features/base/participants';
22
+import { isLocalTrackMuted, isRemoteTrackMuted } from '../../../react/features/base/tracks';
19 23
 import { ConnectionIndicator } from '../../../react/features/connection-indicator';
20 24
 import { DisplayName } from '../../../react/features/display-name';
21 25
 import {
@@ -82,7 +86,6 @@ export default class SmallVideo {
82 86
      */
83 87
     constructor(VideoLayout) {
84 88
         this.isAudioMuted = false;
85
-        this.isVideoMuted = false;
86 89
         this.isScreenSharing = false;
87 90
         this.videoStream = null;
88 91
         this.audioStream = null;
@@ -242,19 +245,6 @@ export default class SmallVideo {
242 245
         this.updateStatusBar();
243 246
     }
244 247
 
245
-    /**
246
-     * Shows video muted indicator over small videos and disables/enables avatar
247
-     * if video muted.
248
-     *
249
-     * @param {boolean} isMuted indicates if we should set the view to muted view
250
-     * or not
251
-     */
252
-    setVideoMutedView(isMuted) {
253
-        this.isVideoMuted = isMuted;
254
-        this.updateView();
255
-        this.updateStatusBar();
256
-    }
257
-
258 248
     /**
259 249
      * Create or updates the ReactElement for displaying status indicators about
260 250
      * audio mute, video mute, and moderator status.
@@ -274,7 +264,6 @@ export default class SmallVideo {
274 264
                     <StatusIndicators
275 265
                         showAudioMutedIndicator = { this.isAudioMuted }
276 266
                         showScreenShareIndicator = { this.isScreenSharing }
277
-                        showVideoMutedIndicator = { this.isVideoMuted }
278 267
                         participantID = { this.id } />
279 268
                 </I18nextProvider>
280 269
             </Provider>,
@@ -449,7 +438,18 @@ export default class SmallVideo {
449 438
      * or <tt>false</tt> otherwise.
450 439
      */
451 440
     isVideoPlayable() {
452
-        return this.videoStream && !this.isVideoMuted && !APP.conference.isAudioOnly();
441
+        const state = APP.store.getState();
442
+        const tracks = state['features/base/tracks'];
443
+        const participant = this.id ? getParticipantById(state, this.id) : getLocalParticipant(state);
444
+        let isVideoMuted = true;
445
+
446
+        if (participant?.local) {
447
+            isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
448
+        } else if (!participant?.isFakeParticipant) { // remote participants excluding shared video
449
+            isVideoMuted = isRemoteTrackMuted(tracks, MEDIA_TYPE.VIDEO, this.id);
450
+        }
451
+
452
+        return this.videoStream && !isVideoMuted && !APP.conference.isAudioOnly();
453 453
     }
454 454
 
455 455
     /**
@@ -490,7 +490,6 @@ export default class SmallVideo {
490 490
             mutedWhileDisconnected: this.mutedWhileDisconnected,
491 491
             canPlayEventReceived: this._canPlayEventReceived,
492 492
             videoStream: Boolean(this.videoStream),
493
-            isVideoMuted: this.isVideoMuted,
494 493
             isScreenSharing: this.isScreenSharing,
495 494
             videoStreamMuted: this.videoStream ? this.videoStream.isMuted() : 'no stream'
496 495
         };

+ 5
- 5
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -176,7 +176,7 @@ const VideoLayout = {
176 176
         if (stream.getType() === 'audio') {
177 177
             this.onAudioMute(id, stream.isMuted());
178 178
         } else {
179
-            this.onVideoMute(id, stream.isMuted());
179
+            this.onVideoMute(id);
180 180
             remoteVideo.setScreenSharing(stream.videoType === 'desktop');
181 181
         }
182 182
     },
@@ -210,7 +210,7 @@ const VideoLayout = {
210 210
             if (mediaType === 'audio') {
211 211
                 APP.UI.setAudioMuted(participantId, true);
212 212
             } else if (mediaType === 'video') {
213
-                APP.UI.setVideoMuted(participantId, true);
213
+                APP.UI.setVideoMuted(participantId);
214 214
             } else {
215 215
                 logger.error(`Unsupported media type: ${mediaType}`);
216 216
             }
@@ -350,14 +350,14 @@ const VideoLayout = {
350 350
     /**
351 351
      * On video muted event.
352 352
      */
353
-    onVideoMute(id, value) {
353
+    onVideoMute(id) {
354 354
         if (APP.conference.isLocalId(id)) {
355
-            localVideoThumbnail && localVideoThumbnail.setVideoMutedView(value);
355
+            localVideoThumbnail && localVideoThumbnail.updateView();
356 356
         } else {
357 357
             const remoteVideo = remoteVideos[id];
358 358
 
359 359
             if (remoteVideo) {
360
-                remoteVideo.setVideoMutedView(value);
360
+                remoteVideo.onVideoMute();
361 361
             }
362 362
         }
363 363
 

+ 1
- 1
react/features/base/tracks/middleware.js 查看文件

@@ -159,7 +159,7 @@ MiddlewareRegistry.register(store => next => action => {
159 159
                 } else if (jitsiTrack.isLocal()) {
160 160
                     APP.conference.setVideoMuteStatus(muted);
161 161
                 } else {
162
-                    APP.UI.setVideoMuted(participantID, muted);
162
+                    APP.UI.setVideoMuted(participantID);
163 163
                 }
164 164
                 APP.UI.onPeerVideoTypeChanged(participantID, jitsiTrack.videoType);
165 165
             } else if (jitsiTrack.isLocal()) {

+ 22
- 9
react/features/filmstrip/components/web/StatusIndicators.js 查看文件

@@ -2,8 +2,10 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 
5
+import { MEDIA_TYPE } from '../../../base/media';
5 6
 import { getLocalParticipant, getParticipantById, PARTICIPANT_ROLE } from '../../../base/participants';
6 7
 import { connect } from '../../../base/redux';
8
+import { isLocalTrackMuted, isRemoteTrackMuted } from '../../../base/tracks';
7 9
 import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
8 10
 
9 11
 import AudioMutedIndicator from './AudioMutedIndicator';
@@ -28,6 +30,11 @@ type Props = {
28 30
      */
29 31
     _showModeratorIndicator: Boolean,
30 32
 
33
+    /**
34
+     * Indicates if the video muted indicator should be visible or not.
35
+     */
36
+    _showVideoMutedIndicator: Boolean,
37
+
31 38
     /**
32 39
      * Indicates if the audio muted indicator should be visible or not.
33 40
      */
@@ -38,11 +45,6 @@ type Props = {
38 45
      */
39 46
     showScreenShareIndicator: Boolean,
40 47
 
41
-    /**
42
-     * Indicates if the video muted indicator should be visible or not.
43
-     */
44
-    showVideoMutedIndicator: Boolean,
45
-
46 48
     /**
47 49
      * The ID of the participant for which the status bar is rendered.
48 50
      */
@@ -67,7 +69,7 @@ class StatusIndicators extends Component<Props> {
67 69
             _showModeratorIndicator,
68 70
             showAudioMutedIndicator,
69 71
             showScreenShareIndicator,
70
-            showVideoMutedIndicator
72
+            _showVideoMutedIndicator
71 73
         } = this.props;
72 74
         let tooltipPosition;
73 75
 
@@ -86,7 +88,7 @@ class StatusIndicators extends Component<Props> {
86 88
             <div>
87 89
                 { showAudioMutedIndicator ? <AudioMutedIndicator tooltipPosition = { tooltipPosition } /> : null }
88 90
                 { showScreenShareIndicator ? <ScreenShareIndicator tooltipPosition = { tooltipPosition } /> : null }
89
-                { showVideoMutedIndicator ? <VideoMutedIndicator tooltipPosition = { tooltipPosition } /> : null }
91
+                { _showVideoMutedIndicator ? <VideoMutedIndicator tooltipPosition = { tooltipPosition } /> : null }
90 92
                 { _showModeratorIndicator ? <ModeratorIndicator tooltipPosition = { tooltipPosition } /> : null }
91 93
             </div>
92 94
         );
@@ -101,7 +103,8 @@ class StatusIndicators extends Component<Props> {
101 103
  * @private
102 104
  * @returns {{
103 105
  *     _currentLayout: string,
104
- *     _showModeratorIndicator: boolean
106
+ *     _showModeratorIndicator: boolean,
107
+ *     _showVideoMutedIndicator: boolean
105 108
  * }}
106 109
 */
107 110
 function _mapStateToProps(state, ownProps) {
@@ -110,10 +113,20 @@ function _mapStateToProps(state, ownProps) {
110 113
     // Only the local participant won't have id for the time when the conference is not yet joined.
111 114
     const participant = participantID ? getParticipantById(state, participantID) : getLocalParticipant(state);
112 115
 
116
+    const tracks = state['features/base/tracks'];
117
+    let isVideoMuted = true;
118
+
119
+    if (participant?.local) {
120
+        isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
121
+    } else if (!participant?.isFakeParticipant) { // remote participants excluding shared video
122
+        isVideoMuted = isRemoteTrackMuted(tracks, MEDIA_TYPE.VIDEO, participantID);
123
+    }
124
+
113 125
     return {
114 126
         _currentLayout: getCurrentLayout(state),
115 127
         _showModeratorIndicator:
116
-            !interfaceConfig.DISABLE_FOCUS_INDICATOR && participant && participant.role === PARTICIPANT_ROLE.MODERATOR
128
+            !interfaceConfig.DISABLE_FOCUS_INDICATOR && participant && participant.role === PARTICIPANT_ROLE.MODERATOR,
129
+        _showVideoMutedIndicator: isVideoMuted
117 130
     };
118 131
 }
119 132
 

Loading…
取消
儲存