fix camera button muted state

This commit is contained in:
Pawel Domas 2021-08-20 14:15:28 -05:00
parent 3327d4cf92
commit e8e2b20758
2 changed files with 16 additions and 7 deletions

View File

@ -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;

View File

@ -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 ];