Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

actions.ts 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import 'image-capture';
  2. import './createImageBitmap';
  3. import { AnyAction } from 'redux';
  4. import {
  5. ADD_FACE_EXPRESSION,
  6. ADD_TO_FACE_EXPRESSIONS_BUFFER,
  7. CLEAR_FACE_EXPRESSIONS_BUFFER,
  8. FACE_LANDMARK_DETECTION_STOPPED,
  9. NEW_FACE_COORDINATES
  10. } from './actionTypes';
  11. import { FaceBox } from './types';
  12. /**
  13. * Adds a new face expression and its duration.
  14. *
  15. * @param {string} faceExpression - Face expression to be added.
  16. * @param {number} duration - Duration in seconds of the face expression.
  17. * @param {number} timestamp - Duration in seconds of the face expression.
  18. * @returns {AnyAction}
  19. */
  20. export function addFaceExpression(faceExpression: string, duration: number, timestamp: number): AnyAction {
  21. return {
  22. type: ADD_FACE_EXPRESSION,
  23. faceExpression,
  24. duration,
  25. timestamp
  26. };
  27. }
  28. /**
  29. * Adds a face expression with its timestamp to the face expression buffer.
  30. *
  31. * @param {Object} faceExpression - Object containing face expression string and its timestamp.
  32. * @returns {AnyAction}
  33. */
  34. export function addToFaceExpressionsBuffer(
  35. faceExpression: {
  36. emotion: string;
  37. timestamp: number;
  38. }
  39. ): AnyAction {
  40. return {
  41. type: ADD_TO_FACE_EXPRESSIONS_BUFFER,
  42. faceExpression
  43. };
  44. }
  45. /**
  46. * Clears the face expressions array in the state.
  47. *
  48. * @returns {Object}
  49. */
  50. export function clearFaceExpressionBuffer() {
  51. return {
  52. type: CLEAR_FACE_EXPRESSIONS_BUFFER
  53. };
  54. }
  55. /**
  56. * Signals that a new face box was obtained for the local participant.
  57. *
  58. * @param {FaceBox} faceBox - The face box of the local participant.
  59. * @returns {AnyAction}
  60. */
  61. export function newFaceBox(faceBox: FaceBox): AnyAction {
  62. return {
  63. type: NEW_FACE_COORDINATES,
  64. faceBox
  65. };
  66. }
  67. /**
  68. * Dispatches the face landmarks detection stopped event in order to be sent to services.
  69. *
  70. * @param {number} timestamp - The timestamp when the camera was off.
  71. * @returns {AnyAction}
  72. */
  73. export function faceLandmarkDetectionStopped(timestamp: number): AnyAction {
  74. return {
  75. type: FACE_LANDMARK_DETECTION_STOPPED,
  76. timestamp
  77. };
  78. }