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.

JitsiRemoteTrack.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. var JitsiTrack = require("./JitsiTrack");
  2. var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
  3. /**
  4. * Represents a single media track (either audio or video).
  5. * @param RTC the rtc instance.
  6. * @param data object with the stream and some details about it(participant id, video type, etc.)
  7. * @param sid sid for the Media Stream
  8. * @param ssrc ssrc for the Media Stream
  9. * @param eventEmitter the event emitter
  10. * @constructor
  11. */
  12. function JitsiRemoteTrack(RTC, data, sid, ssrc, eventEmitter) {
  13. JitsiTrack.call(this, RTC, data.stream,
  14. function () {
  15. eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_ENDED, self);
  16. });
  17. this.rtc = RTC;
  18. this.sid = sid;
  19. this.stream = data.stream;
  20. this.peerjid = data.peerjid;
  21. this.videoType = data.videoType;
  22. this.ssrc = ssrc;
  23. this.muted = false;
  24. if((this.type === JitsiTrack.AUDIO && data.audiomuted)
  25. || (this.type === JitsiTrack.VIDEO && data.videomuted)) {
  26. this.muted = true
  27. }
  28. this.eventEmitter = eventEmitter;
  29. var self = this;
  30. }
  31. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  32. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  33. /**
  34. * Sets current muted status and fires an events for the change.
  35. * @param value the muted status.
  36. */
  37. JitsiRemoteTrack.prototype.setMute = function (value) {
  38. this.stream.muted = value;
  39. this.muted = value;
  40. this.eventEmitter.emit(StreamEventTypes.TRACK_MUTE_CHANGED, this);
  41. };
  42. /**
  43. * Returns the current muted status of the track.
  44. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is muted and <tt>false</tt> otherwise.
  45. */
  46. JitsiRemoteTrack.prototype.isMuted = function () {
  47. return this.muted;
  48. }
  49. /**
  50. * Returns the participant id which owns the track.
  51. * @returns {string} the id of the participants.
  52. */
  53. JitsiRemoteTrack.prototype.getParitcipantId = function() {
  54. return Strophe.getResourceFromJid(this.peerjid);
  55. };
  56. delete JitsiRemoteTrack.prototype.stop;
  57. delete JitsiRemoteTrack.prototype.start;
  58. module.exports = JitsiRemoteTrack;