mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
* Add checkboxes to toggle audio settings * Sync checkboxes with audio mixer effect * Add tooltips * Move previewAudioTrack to redux * Add translation * Add audio settings state to redux * Update docs * Apply review comments * Create local track with audio contraints when unmuting * Refactor functions and naming * Add enableAdvancedAudioSettings config * Fix mobile imports * Add tooltips content * Update react/features/base/config/functions.any.ts * Layout checkboxes in a two-column grid * Fix web imports * Sort translation alphabetically * Separate audio mute implementation for mobile and web * Apply review comments * squash: Add imports for middleware.any * squash: fix linter errors * Remove tooltips * Lint * Refactored setting of audio constraints in createLocalTracksF with checks for feature flag and desktop --------- Co-authored-by: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Co-authored-by: Jaya Allamsetty <jaya.allamsetty@8x8.com>
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import { IStore } from '../../app/types';
|
|
import { SET_AUDIO_MUTED } from '../media/actionTypes';
|
|
import {
|
|
MEDIA_TYPE,
|
|
VIDEO_TYPE
|
|
} from '../media/constants';
|
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
|
|
|
import {
|
|
TRACK_UPDATED
|
|
} from './actionTypes';
|
|
import {
|
|
createLocalTracksA,
|
|
toggleScreensharing,
|
|
trackMuteUnmuteFailed
|
|
} from './actions.native';
|
|
import { getLocalTrack, setTrackMuted } from './functions.any';
|
|
|
|
import './middleware.any';
|
|
|
|
/**
|
|
* Middleware that captures LIB_DID_DISPOSE and LIB_DID_INIT actions and,
|
|
* respectively, creates/destroys local media tracks. Also listens to
|
|
* media-related actions and performs corresponding operations with tracks.
|
|
*
|
|
* @param {Store} store - The redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
switch (action.type) {
|
|
case SET_AUDIO_MUTED: {
|
|
_setMuted(store, action);
|
|
break;
|
|
}
|
|
case TRACK_UPDATED: {
|
|
const { jitsiTrack, local } = action.track;
|
|
|
|
if (local && jitsiTrack.isMuted()
|
|
&& jitsiTrack.type === MEDIA_TYPE.VIDEO && jitsiTrack.videoType === VIDEO_TYPE.DESKTOP) {
|
|
store.dispatch(toggleScreensharing(false));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
});
|
|
|
|
/**
|
|
* Mutes or unmutes a local track with a specific media type.
|
|
*
|
|
* @param {Store} store - The redux store in which the specified action is dispatched.
|
|
* @param {Action} action - The redux action dispatched in the specified store.
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
function _setMuted(store: IStore, { ensureTrack, muted }: {
|
|
ensureTrack: boolean; muted: boolean; }) {
|
|
const { dispatch, getState } = store;
|
|
const state = getState();
|
|
const localTrack = getLocalTrack(state['features/base/tracks'], MEDIA_TYPE.AUDIO, /* includePending */ true);
|
|
|
|
if (localTrack) {
|
|
// The `jitsiTrack` property will have a value only for a localTrack for which `getUserMedia` has already
|
|
// completed. If there's no `jitsiTrack`, then the `muted` state will be applied once the `jitsiTrack` is
|
|
// created.
|
|
const { jitsiTrack } = localTrack;
|
|
|
|
if (jitsiTrack) {
|
|
setTrackMuted(jitsiTrack, muted, state, dispatch)
|
|
.catch(() => dispatch(trackMuteUnmuteFailed(localTrack, muted)));
|
|
}
|
|
} else if (!muted && ensureTrack) {
|
|
dispatch(createLocalTracksA({ devices: [ MEDIA_TYPE.AUDIO ] }));
|
|
}
|
|
}
|