Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // @flow
  2. import {
  3. CONFERENCE_JOINED,
  4. VIDEO_QUALITY_LEVELS,
  5. getNearestReceiverVideoQualityLevel,
  6. setMaxReceiverVideoQuality,
  7. setPreferredVideoQuality
  8. } from '../base/conference';
  9. import { getParticipantCount } from '../base/participants';
  10. import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
  11. import { shouldDisplayTileView } from '../video-layout';
  12. import logger from './logger';
  13. /**
  14. * Implements the middleware of the feature video-quality.
  15. *
  16. * @param {Store} store - The redux store.
  17. * @returns {Function}
  18. */
  19. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  20. const result = next(action);
  21. switch (action.type) {
  22. case CONFERENCE_JOINED: {
  23. if (navigator.product === 'ReactNative') {
  24. const { resolution } = getState()['features/base/config'];
  25. if (typeof resolution !== 'undefined') {
  26. dispatch(setPreferredVideoQuality(Number.parseInt(resolution, 10)));
  27. logger.info(`Configured preferred receiver video frame height to: ${resolution}`);
  28. }
  29. }
  30. break;
  31. }
  32. }
  33. return result;
  34. });
  35. /**
  36. * Implements a state listener in order to calculate max receiver video quality.
  37. */
  38. StateListenerRegistry.register(
  39. /* selector */ state => {
  40. const { reducedUI } = state['features/base/responsive-ui'];
  41. const _shouldDisplayTileView = shouldDisplayTileView(state);
  42. const thumbnailSize = state['features/filmstrip']?.tileViewDimensions?.thumbnailSize;
  43. const participantCount = getParticipantCount(state);
  44. return {
  45. displayTileView: _shouldDisplayTileView,
  46. participantCount,
  47. reducedUI,
  48. thumbnailHeight: thumbnailSize?.height
  49. };
  50. },
  51. /* listener */ ({ displayTileView, participantCount, reducedUI, thumbnailHeight }, { dispatch, getState }) => {
  52. const state = getState();
  53. const { maxReceiverVideoQuality } = state['features/base/conference'];
  54. const { maxFullResolutionParticipants = 2 } = state['features/base/config'];
  55. let newMaxRecvVideoQuality = VIDEO_QUALITY_LEVELS.HIGH;
  56. if (reducedUI) {
  57. newMaxRecvVideoQuality = VIDEO_QUALITY_LEVELS.LOW;
  58. } else if (displayTileView && !Number.isNaN(thumbnailHeight)) {
  59. newMaxRecvVideoQuality = getNearestReceiverVideoQualityLevel(thumbnailHeight);
  60. // Override HD level calculated for the thumbnail height when # of participants threshold is exceeded
  61. if (maxReceiverVideoQuality !== newMaxRecvVideoQuality && maxFullResolutionParticipants !== -1) {
  62. const override
  63. = participantCount > maxFullResolutionParticipants
  64. && newMaxRecvVideoQuality > VIDEO_QUALITY_LEVELS.STANDARD;
  65. logger.info(`The nearest receiver video quality level for thumbnail height: ${thumbnailHeight}, `
  66. + `is: ${newMaxRecvVideoQuality}, `
  67. + `override: ${String(override)}, `
  68. + `max full res N: ${maxFullResolutionParticipants}`);
  69. if (override) {
  70. newMaxRecvVideoQuality = VIDEO_QUALITY_LEVELS.STANDARD;
  71. }
  72. }
  73. }
  74. if (maxReceiverVideoQuality !== newMaxRecvVideoQuality) {
  75. dispatch(setMaxReceiverVideoQuality(newMaxRecvVideoQuality));
  76. }
  77. }, {
  78. deepEquals: true
  79. });