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.

actions.ts 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { IStore } from '../app/types';
  2. import {
  3. SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_LARGE_VIDEO,
  4. SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_SCREEN_SHARING_FILMSTRIP,
  5. SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_STAGE_FILMSTRIP,
  6. SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_TILE_VIEW,
  7. SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_VERTICAL_FILMSTRIP,
  8. SET_PREFERRED_VIDEO_QUALITY
  9. } from './actionTypes';
  10. import { MAX_VIDEO_QUALITY, VIDEO_QUALITY_LEVELS } from './constants';
  11. import logger from './logger';
  12. /**
  13. * Sets the max frame height that should be received for the large video.
  14. *
  15. * @param {number} maxReceiverVideoQuality - The max video frame height to
  16. * receive.
  17. * @returns {{
  18. * type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_LARGE_VIDEO,
  19. * maxReceiverVideoQuality: number
  20. * }}
  21. */
  22. export function setMaxReceiverVideoQualityForLargeVideo(maxReceiverVideoQuality: number) {
  23. return {
  24. type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_LARGE_VIDEO,
  25. maxReceiverVideoQuality
  26. };
  27. }
  28. /**
  29. * Sets the max frame height that should be received for the screen sharing filmstrip particpant.
  30. *
  31. * @param {number} maxReceiverVideoQuality - The max video frame height to
  32. * receive.
  33. * @returns {{
  34. * type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_SCREEN_SHARING_FILMSTRIP,
  35. * maxReceiverVideoQuality: number
  36. * }}
  37. */
  38. export function setMaxReceiverVideoQualityForScreenSharingFilmstrip(maxReceiverVideoQuality: number) {
  39. return {
  40. type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_SCREEN_SHARING_FILMSTRIP,
  41. maxReceiverVideoQuality
  42. };
  43. }
  44. /**
  45. * Sets the max frame height that should be received from remote videos for the stage filmstrip.
  46. *
  47. * @param {number} maxReceiverVideoQuality - The max video frame height to
  48. * receive.
  49. * @returns {{
  50. * type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_STAGE_FILMSTRIP,
  51. * maxReceiverVideoQuality: number
  52. * }}
  53. */
  54. export function setMaxReceiverVideoQualityForStageFilmstrip(maxReceiverVideoQuality: number) {
  55. return {
  56. type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_STAGE_FILMSTRIP,
  57. maxReceiverVideoQuality
  58. };
  59. }
  60. /**
  61. * Sets the max frame height that should be received from remote videos in tile view.
  62. *
  63. * @param {number} maxReceiverVideoQuality - The max video frame height to
  64. * receive.
  65. * @returns {{
  66. * type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_TILE_VIEW,
  67. * maxReceiverVideoQuality: number
  68. * }}
  69. */
  70. export function setMaxReceiverVideoQualityForTileView(maxReceiverVideoQuality: number) {
  71. return {
  72. type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_TILE_VIEW,
  73. maxReceiverVideoQuality
  74. };
  75. }
  76. /**
  77. * Sets the max frame height that should be received from remote videos for the vertical filmstrip.
  78. *
  79. * @param {number} maxReceiverVideoQuality - The max video frame height to
  80. * receive.
  81. * @returns {{
  82. * type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_VERTICAL_FILMSTRIP,
  83. * maxReceiverVideoQuality: number
  84. * }}
  85. */
  86. export function setMaxReceiverVideoQualityForVerticalFilmstrip(maxReceiverVideoQuality: number) {
  87. return {
  88. type: SET_MAX_RECEIVER_VIDEO_QUALITY_FOR_VERTICAL_FILMSTRIP,
  89. maxReceiverVideoQuality
  90. };
  91. }
  92. /**
  93. * Sets the max frame height the user prefers to send and receive from the
  94. * remote participants.
  95. *
  96. * @param {number} preferredVideoQuality - The max video resolution to send and
  97. * receive.
  98. * @returns {{
  99. * type: SET_PREFERRED_VIDEO_QUALITY,
  100. * preferredVideoQuality: number
  101. * }}
  102. */
  103. export function setPreferredVideoQuality(preferredVideoQuality: number) {
  104. return {
  105. type: SET_PREFERRED_VIDEO_QUALITY,
  106. preferredVideoQuality
  107. };
  108. }
  109. /**
  110. * Sets the maximum video size the local participant should send and receive from
  111. * remote participants.
  112. *
  113. * @param {number} frameHeight - The user preferred max frame height for send and
  114. * receive video.
  115. * @returns {void}
  116. */
  117. export function setVideoQuality(frameHeight: number) {
  118. return (dispatch: IStore['dispatch']) => {
  119. if (frameHeight < VIDEO_QUALITY_LEVELS.LOW) {
  120. logger.error(`Invalid frame height for video quality - ${frameHeight}`);
  121. return;
  122. }
  123. dispatch(setPreferredVideoQuality(Math.min(frameHeight, MAX_VIDEO_QUALITY)));
  124. };
  125. }