diff --git a/react/features/base/tracks/functions.js b/react/features/base/tracks/functions.js index b49045623..c1af20478 100644 --- a/react/features/base/tracks/functions.js +++ b/react/features/base/tracks/functions.js @@ -346,6 +346,12 @@ export function getLocalVideoTrack(tracks) { return getLocalTrack(tracks, MEDIA_TYPE.VIDEO); } +// eslint-disable-next-line require-jsdoc +export function getLocalCameraTrack(tracks) { + return getLocalTracks(tracks, false) + .find(t => t.videoType === VIDEO_TYPE.CAMERA); +} + /** * Returns the media type of the local video, presenter or video. * @@ -463,16 +469,15 @@ export function getTracksByMediaType(tracks, mediaType) { */ export function isLocalCameraTrackMuted(tracks) { const presenterTrack = getLocalTrack(tracks, MEDIA_TYPE.PRESENTER); - const videoTrack = getLocalTrack(tracks, MEDIA_TYPE.VIDEO); + const localCameraTrack = getLocalCameraTrack(tracks); // Make sure we check the mute status of only camera tracks, i.e., // presenter track when it exists, camera track when the presenter // track doesn't exist. if (presenterTrack) { return isLocalTrackMuted(tracks, MEDIA_TYPE.PRESENTER); - } else if (videoTrack) { - return videoTrack.videoType === 'camera' - ? isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO) : true; + } else if (localCameraTrack) { + return localCameraTrack.muted; } return true; diff --git a/react/features/base/tracks/reducer.js b/react/features/base/tracks/reducer.js index ad0af451a..af4059005 100644 --- a/react/features/base/tracks/reducer.js +++ b/react/features/base/tracks/reducer.js @@ -130,9 +130,13 @@ ReducerRegistry.register('features/base/tracks', (state = [], action) => { let withoutTrackStub = state; if (action.track.local) { - withoutTrackStub - = state.filter( - t => !t.local || t.mediaType !== action.track.mediaType); + // FIXME verify if it's working as expected + // The track stubs were introduced to track get user media in progress state. + // Now this check will be over complicated with multiple tracks per type. + withoutTrackStub = state.filter( + t => !t.local + || t.mediaType !== action.track.mediaType + || (t.jitsiTrack && t.jitsiTrack !== action.track.jitsiTrack)); } return [ ...withoutTrackStub, action.track ];