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.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @flow
  2. import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
  3. /**
  4. * Searches in the passed in redux state for an active recording session of the
  5. * passed in mode.
  6. *
  7. * @param {Object} state - The redux state to search in.
  8. * @param {string} mode - Find an active recording session of the given mode.
  9. * @returns {Object|undefined}
  10. */
  11. export function getActiveSession(state: Object, mode: string) {
  12. const { sessionDatas } = state['features/recording'];
  13. const { status: statusConstants } = JitsiRecordingConstants;
  14. return sessionDatas.find(sessionData => sessionData.mode === mode
  15. && (sessionData.status === statusConstants.ON
  16. || sessionData.status === statusConstants.PENDING));
  17. }
  18. /**
  19. * Returns an estimated recording duration based on the size of the video file
  20. * in MB. The estimate is calculated under the assumption that 1 min of recorded
  21. * video needs 10MB of storage on avarage.
  22. *
  23. * @param {number} size - The size in MB of the recorded video.
  24. * @returns {number} - The estimated duration in minutes.
  25. */
  26. export function getRecordingDurationEstimation(size: ?number) {
  27. return Math.floor((size || 0) / 10);
  28. }
  29. /**
  30. * Searches in the passed in redux state for a recording session that matches
  31. * the passed in recording session ID.
  32. *
  33. * @param {Object} state - The redux state to search in.
  34. * @param {string} id - The ID of the recording session to find.
  35. * @returns {Object|undefined}
  36. */
  37. export function getSessionById(state: Object, id: string) {
  38. return state['features/recording'].sessionDatas.find(
  39. sessionData => sessionData.id === id);
  40. }