您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MockClasses.ts 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. /**
  45. * Gets the capture resolution of the mock local track.
  46. * @returns - The capture resolution.
  47. */
  48. getCaptureResolution(): number {
  49. return this.captureResolution;
  50. }
  51. /**
  52. * Returns the video type of the mock local track.
  53. * @returns {VideoType}
  54. */
  55. getVideoType(): VideoType {
  56. return this.videoType;
  57. }
  58. }
  59. /**
  60. * MockConference
  61. */
  62. export class MockConference extends Listenable {
  63. options: { config: {}; };
  64. activeMediaSession: JingleSessionPC;
  65. jvbJingleSession: JingleSessionPC;
  66. mediaSessions: JingleSessionPC[];
  67. participants: MockParticipant[];
  68. rtc: MockRTC;
  69. _signalingLayer: MockSignalingLayerImpl;
  70. /**
  71. * A constructor...
  72. */
  73. constructor(rtc: MockRTC) {
  74. super();
  75. this.options = {
  76. config: {}
  77. };
  78. this.activeMediaSession = undefined;
  79. this.jvbJingleSession = null;
  80. this.mediaSessions = [];
  81. this.participants = [];
  82. this.rtc = rtc;
  83. this._signalingLayer = new MockSignalingLayerImpl();
  84. }
  85. /**
  86. * Add a mock participant to the conference
  87. * @param {MockParticipant} participant
  88. * @param {Array<string>} codecList
  89. * @param {String} codecType
  90. */
  91. addParticipant(participant: MockParticipant, codecList: Array<string>, codecType: string): void {
  92. this.participants.push(participant);
  93. this._signalingLayer.setPeerMediaInfo(true, participant.getId(), codecList, codecType);
  94. this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED);
  95. }
  96. /**
  97. * Returns the active media session.
  98. * @returns {JingleSessionPC}
  99. */
  100. getActiveMediaSession(): JingleSessionPC {
  101. return this.jvbJingleSession;
  102. }
  103. /**
  104. * Returns a list of forwarded sources.
  105. * @returns {Array<string>}
  106. */
  107. getForwardedSources(): string[] {
  108. return this.rtc.getForwardedSources();
  109. }
  110. /**
  111. * Returns the list of participants.
  112. * @returns Array<MockParticipant>
  113. */
  114. getParticipants(): Array<MockParticipant> {
  115. return this.participants;
  116. }
  117. /**
  118. * Checks if E2EE is enabled.
  119. * @returns {boolean}
  120. */
  121. isE2EEEnabled(): boolean {
  122. return false;
  123. }
  124. /**
  125. * Removes the participant from the conference.
  126. * @param {MockParticipant} endpoint
  127. */
  128. removeParticipant(endpoint: MockParticipant): void {
  129. this.participants = this.participants.filter(p => p !== endpoint);
  130. this._signalingLayer.setPeerMediaInfo(false, endpoint.getId(), undefined, undefined);
  131. this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT);
  132. }
  133. }