You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.native.ts 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { IStore } from '../../app/types';
  2. import JitsiMeetJS from '../lib-jitsi-meet';
  3. import { getCameraFacingMode } from './functions.any';
  4. import { ITrackOptions } from './types';
  5. export * from './functions.any';
  6. /**
  7. * Create local tracks of specific types.
  8. *
  9. * @param {Object} options - The options with which the local tracks are to be
  10. * created.
  11. * @param {string|null} [options.cameraDeviceId] - Camera device id or
  12. * {@code undefined} to use app's settings.
  13. * @param {string[]} options.devices - Required track types such as 'audio'
  14. * and/or 'video'.
  15. * @param {string|null} [options.micDeviceId] - Microphone device id or
  16. * {@code undefined} to use app's settings.
  17. * @param {number|undefined} [oprions.timeout] - A timeout for JitsiMeetJS.createLocalTracks used to create the tracks.
  18. * @param {boolean} [options.firePermissionPromptIsShownEvent] - Whether lib-jitsi-meet
  19. * should check for a {@code getUserMedia} permission prompt and fire a
  20. * corresponding event.
  21. * @param {IStore} store - The redux store in the context of which the function
  22. * is to execute and from which state such as {@code config} is to be retrieved.
  23. * @returns {Promise<JitsiLocalTrack[]>}
  24. */
  25. export function createLocalTracksF(options: ITrackOptions = {}, store: IStore) {
  26. const { cameraDeviceId, micDeviceId } = options;
  27. const state = store.getState();
  28. const {
  29. resolution
  30. } = state['features/base/config'];
  31. const constraints = options.constraints ?? state['features/base/config'].constraints;
  32. return JitsiMeetJS.createLocalTracks(
  33. {
  34. cameraDeviceId,
  35. constraints,
  36. // Copy array to avoid mutations inside library.
  37. devices: options.devices?.slice(0),
  38. facingMode: options.facingMode || getCameraFacingMode(state),
  39. micDeviceId,
  40. resolution
  41. });
  42. }