Files
jitsi-meet/react/features/base/tracks/functions.native.ts
luzpaz 30595584a3 chore(typos) fix various typos
Found via `codespell -q 3 -S "*.svg,./lang" -L anser,bu,dialin,goup,miliseconds,nd,vew`
2024-12-20 07:58:31 +01:00

45 lines
1.7 KiB
TypeScript

import { IStore } from '../../app/types';
import JitsiMeetJS from '../lib-jitsi-meet';
import { getCameraFacingMode } from './functions.any';
import { ITrackOptions } from './types';
export * from './functions.any';
/**
* Create local tracks of specific types.
*
* @param {Object} options - The options with which the local tracks are to be
* created.
* @param {string|null} [options.cameraDeviceId] - Camera device id or
* {@code undefined} to use app's settings.
* @param {string[]} options.devices - Required track types such as 'audio'
* and/or 'video'.
* @param {string|null} [options.micDeviceId] - Microphone device id or
* {@code undefined} to use app's settings.
* @param {number|undefined} [options.timeout] - A timeout for JitsiMeetJS.createLocalTracks used to create the tracks.
* @param {IStore} store - The redux store in the context of which the function
* is to execute and from which state such as {@code config} is to be retrieved.
* @returns {Promise<JitsiLocalTrack[]>}
*/
export function createLocalTracksF(options: ITrackOptions = {}, store: IStore) {
const { cameraDeviceId, micDeviceId } = options;
const state = store.getState();
const {
resolution
} = state['features/base/config'];
const constraints = options.constraints ?? state['features/base/config'].constraints;
return JitsiMeetJS.createLocalTracks(
{
cameraDeviceId,
constraints,
// Copy array to avoid mutations inside library.
devices: options.devices?.slice(0),
facingMode: options.facingMode || getCameraFacingMode(state),
micDeviceId,
resolution
});
}