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.

JitsiParticipant.js 4.9KB

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