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.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import browser from '../browser';
  2. /**
  3. * A global module for accessing information about different feature flags state.
  4. */
  5. class FeatureFlags {
  6. /**
  7. * Configures the module.
  8. *
  9. * @param {object} flags - The feature flags.
  10. * @param {boolean=} flags.runInLiteMode - Enables lite mode for testing to disable media decoding.
  11. * @param {boolean=} flags.ssrcRewritingEnabled - Use SSRC rewriting. Requires sourceNameSignaling to be enabled.
  12. * @param {boolean=} flags.enableJoinAsVisitor - Enable joining as a visitor.
  13. */
  14. init(flags) {
  15. this._runInLiteMode = Boolean(flags.runInLiteMode);
  16. this._ssrcRewriting = Boolean(flags.ssrcRewritingEnabled);
  17. this._joinAsVisitor = Boolean(flags.enableJoinAsVisitor ?? true);
  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() {
  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() {
  34. return this._ssrcRewriting;
  35. }
  36. /**
  37. * Checks if the clients supports joining as a visitor.
  38. * @returns {boolean}
  39. */
  40. isJoinAsVisitorSupported() {
  41. return this._joinAsVisitor;
  42. }
  43. }
  44. export default new FeatureFlags();