Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

JitsiParticipant.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* global Strophe */
  2. import * as JitsiConferenceEvents from "./JitsiConferenceEvents";
  3. import * as MediaType from "./service/RTC/MediaType";
  4. /**
  5. * Represents a participant in (i.e. a member of) a conference.
  6. */
  7. export default class JitsiParticipant {
  8. /**
  9. * Initializes a new JitsiParticipant instance.
  10. *
  11. * @constructor
  12. * @param jid the conference XMPP jid
  13. * @param conference
  14. * @param displayName
  15. * @param {Boolean} hidden - True if the new JitsiParticipant instance is to
  16. * represent a hidden participant; otherwise, false.
  17. */
  18. constructor(jid, conference, displayName, hidden) {
  19. this._jid = jid;
  20. this._id = Strophe.getResourceFromJid(jid);
  21. this._conference = conference;
  22. this._displayName = displayName;
  23. this._supportsDTMF = false;
  24. this._tracks = [];
  25. this._role = 'none';
  26. this._status = null;
  27. this._availableDevices = {
  28. audio: undefined,
  29. video: undefined
  30. };
  31. this._hidden = hidden;
  32. this._properties = {};
  33. }
  34. /**
  35. * @returns {JitsiConference} The conference that this participant belongs
  36. * to.
  37. */
  38. getConference() {
  39. return this._conference;
  40. }
  41. /**
  42. * Gets the value of a property of this participant.
  43. */
  44. getProperty(name) {
  45. return this._properties[name];
  46. }
  47. /**
  48. * Sets the value of a property of this participant, and fires an event if
  49. * the value has changed.
  50. * @name the name of the property.
  51. * @value the value to set.
  52. */
  53. setProperty(name, value) {
  54. var oldValue = this._properties[name];
  55. if (value !== oldValue) {
  56. this._properties[name] = value;
  57. this._conference.eventEmitter.emit(
  58. JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
  59. this,
  60. name,
  61. oldValue,
  62. value);
  63. }
  64. }
  65. /**
  66. * @returns {Array.<JitsiTrack>} The list of media tracks for this
  67. * participant.
  68. */
  69. getTracks() {
  70. return this._tracks.slice();
  71. }
  72. /**
  73. * @returns {String} The ID of this participant.
  74. */
  75. getId() {
  76. return this._id;
  77. }
  78. /**
  79. * @returns {String} The JID of this participant.
  80. */
  81. getJid() {
  82. return this._jid;
  83. }
  84. /**
  85. * @returns {String} The human-readable display name of this participant.
  86. */
  87. getDisplayName() {
  88. return this._displayName;
  89. }
  90. /**
  91. * @returns {String} The status of the participant.
  92. */
  93. getStatus () {
  94. return this._status;
  95. }
  96. /**
  97. * @returns {Boolean} Whether this participant is a moderator or not.
  98. */
  99. isModerator() {
  100. return this._role === 'moderator';
  101. }
  102. /**
  103. * @returns {Boolean} Whether this participant is a hidden participant. Some
  104. * special system participants may want to join hidden (like for example the
  105. * recorder).
  106. */
  107. isHidden() {
  108. return this._hidden;
  109. }
  110. // Gets a link to an etherpad instance advertised by the participant?
  111. //getEtherpad() {
  112. //}
  113. /**
  114. * @returns {Boolean} Whether this participant has muted their audio.
  115. */
  116. isAudioMuted() {
  117. return this._isMediaTypeMuted(MediaType.AUDIO);
  118. }
  119. /**
  120. * Determines whether all JitsiTracks which are of a specific MediaType and
  121. * which belong to this JitsiParticipant are muted.
  122. *
  123. * @param {MediaType} mediaType - The MediaType of the JitsiTracks to be
  124. * checked.
  125. * @private
  126. * @returns {Boolean} True if all JitsiTracks which are of the specified
  127. * mediaType and which belong to this JitsiParticipant are muted; otherwise,
  128. * false.
  129. */
  130. _isMediaTypeMuted(mediaType) {
  131. return this.getTracks().reduce(
  132. (muted, track) =>
  133. muted && (track.getType() !== mediaType || track.isMuted()),
  134. true);
  135. }
  136. /**
  137. * @returns {Boolean} Whether this participant has muted their video.
  138. */
  139. isVideoMuted() {
  140. return this._isMediaTypeMuted(MediaType.VIDEO);
  141. }
  142. /**
  143. * @returns {???} The latest statistics reported by this participant (i.e.
  144. * info used to populate the GSM bars)
  145. * TODO: do we expose this or handle it internally?
  146. */
  147. getLatestStats() {
  148. }
  149. /**
  150. * @returns {String} The role of this participant.
  151. */
  152. getRole() {
  153. return this._role;
  154. }
  155. /**
  156. * @returns {Boolean} Whether this participant is the conference focus (i.e.
  157. * jicofo).
  158. */
  159. isFocus() {
  160. }
  161. /**
  162. * @returns {Boolean} Whether this participant is a conference recorder
  163. * (i.e. jirecon).
  164. */
  165. isRecorder() {
  166. }
  167. /**
  168. * @returns {Boolean} Whether this participant is a SIP gateway (i.e.
  169. * jigasi).
  170. */
  171. isSipGateway() {
  172. }
  173. /**
  174. * @returns {Boolean} Whether this participant is currently sharing their
  175. * screen.
  176. */
  177. isScreenSharing() {
  178. }
  179. /**
  180. * @returns {String} The user agent of this participant (i.e. browser
  181. * userAgent string).
  182. */
  183. getUserAgent() {
  184. }
  185. /**
  186. * Kicks the participant from the conference (requires certain privileges).
  187. */
  188. kick() {
  189. }
  190. /**
  191. * Asks this participant to mute themselves.
  192. */
  193. askToMute() {
  194. }
  195. supportsDTMF() {
  196. return this._supportsDTMF;
  197. }
  198. }