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.

FeatureFlags.ts 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import browser from '../browser';
  2. /**
  3. * A global module for accessing information about different feature flags state.
  4. */
  5. class FeatureFlags {
  6. private _runInLiteMode: boolean;
  7. private _ssrcRewriting: boolean;
  8. /**
  9. * Configures the module.
  10. *
  11. * @param {object} flags - The feature flags.
  12. * @param {boolean=} flags.runInLiteMode - Enables lite mode for testing to disable media decoding.
  13. * @param {boolean=} flags.ssrcRewritingEnabled - Use SSRC rewriting.
  14. */
  15. init(flags: { runInLiteMode?: boolean | undefined; ssrcRewritingEnabled?: boolean | undefined; }) {
  16. this._runInLiteMode = Boolean(flags.runInLiteMode);
  17. this._ssrcRewriting = Boolean(flags.ssrcRewritingEnabled);
  18. }
  19. /**
  20. * Checks if the run in lite mode is enabled.
  21. * This will cause any media to be received and not decoded. (Insertable streams are used to discard
  22. * all media before it is decoded). This can be used for various test scenarios.
  23. *
  24. * @returns {boolean}
  25. */
  26. isRunInLiteModeEnabled(): boolean {
  27. return this._runInLiteMode && browser.supportsInsertableStreams();
  28. }
  29. /**
  30. * Checks if the clients supports re-writing of the SSRCs on the media streams by the bridge.
  31. * @returns {boolean}
  32. */
  33. isSsrcRewritingSupported(): boolean {
  34. return this._ssrcRewriting;
  35. }
  36. }
  37. export default new FeatureFlags();