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.

MockClasses.ts 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { JitsiConferenceEvents } from '../../JitsiConferenceEvents';
  2. import { VideoType } from '../../service/RTC/VideoType';
  3. import { MockRTC, MockSignalingLayerImpl } from '../RTC/MockClasses';
  4. import Listenable from '../util/Listenable';
  5. import JingleSessionPC from '../xmpp/JingleSessionPC';
  6. /**
  7. * MockParticipant
  8. */
  9. export class MockParticipant {
  10. id: string;
  11. /**
  12. * A constructor...
  13. */
  14. constructor(id: string) {
  15. this.id = id;
  16. }
  17. /**
  18. * Returns the endpoint id of the participant.
  19. * @returns <string>
  20. */
  21. getId() {
  22. return this.id;
  23. }
  24. }
  25. /**
  26. * MockLocalTrack
  27. */
  28. export class MockLocalTrack {
  29. maxEnabledResolution: number;
  30. rtcId: string;
  31. videoType: VideoType;
  32. captureResolution: number;
  33. /**
  34. * Constructor
  35. * @param {number} resolution
  36. * @param {VideoType} videoType
  37. */
  38. constructor(id: string, resolution: number, videoType: VideoType) {
  39. this.rtcId = id;
  40. this.captureResolution = resolution;
  41. this.maxEnabledResolution = resolution;
  42. this.videoType = videoType;
  43. }
  44. getCaptureResolution(): number {
  45. return this.captureResolution;
  46. }
  47. /**
  48. * Returns the video type of the mock local track.
  49. * @returns {VideoType}
  50. */
  51. getVideoType(): VideoType {
  52. return this.videoType;
  53. }
  54. }
  55. /**
  56. * MockConference
  57. */
  58. export class MockConference extends Listenable {
  59. options: { config: {}; };
  60. activeMediaSession: JingleSessionPC;
  61. jvbJingleSession: JingleSessionPC;
  62. mediaSessions: JingleSessionPC[];
  63. participants: MockParticipant[];
  64. rtc: MockRTC;
  65. _signalingLayer: MockSignalingLayerImpl;
  66. /**
  67. * A constructor...
  68. */
  69. constructor(rtc: MockRTC) {
  70. super();
  71. this.options = {
  72. config: {}
  73. };
  74. this.activeMediaSession = undefined;
  75. this.jvbJingleSession = null;
  76. this.mediaSessions = [];
  77. this.participants = [];
  78. this.rtc = rtc;
  79. this._signalingLayer = new MockSignalingLayerImpl();
  80. }
  81. /**
  82. * Add a mock participant to the conference
  83. * @param {MockParticipant} participant
  84. * @param {Array<string>} codecList
  85. * @param {String} codecType
  86. */
  87. addParticipant(participant: MockParticipant, codecList: Array<string>, codecType: string): void {
  88. this.participants.push(participant);
  89. this._signalingLayer.setPeerMediaInfo(true, participant.getId(), codecList, codecType);
  90. this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED);
  91. }
  92. /**
  93. * Returns the active media session.
  94. * @returns {JingleSessionPC}
  95. */
  96. getActiveMediaSession(): JingleSessionPC {
  97. return this.jvbJingleSession;
  98. }
  99. /**
  100. * Returns a list of forwarded sources.
  101. * @returns {Array<string>}
  102. */
  103. getForwardedSources(): string[] {
  104. return this.rtc.getForwardedSources();
  105. }
  106. /**
  107. * Returns the list of participants.
  108. * @returns Array<MockParticipant>
  109. */
  110. getParticipants(): Array<MockParticipant> {
  111. return this.participants;
  112. }
  113. /**
  114. * Checks if E2EE is enabled.
  115. * @returns {boolean}
  116. */
  117. isE2EEEnabled(): boolean {
  118. return false;
  119. }
  120. /**
  121. * Removes the participant from the conference.
  122. * @param {MockParticipant} endpoint
  123. */
  124. removeParticipant(endpoint: MockParticipant): void {
  125. this.participants = this.participants.filter(p => p !== endpoint);
  126. this._signalingLayer.setPeerMediaInfo(false, endpoint.getId(), undefined, undefined);
  127. this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT);
  128. }
  129. }