選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.js 4.1KB

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