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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. this.rtc = RTC;
  15. this.sid = sid;
  16. this.stream = data.stream;
  17. this.peerjid = data.peerjid;
  18. this.videoType = data.videoType;
  19. this.ssrc = ssrc;
  20. this.muted = false;
  21. if((this.type === JitsiTrack.AUDIO && data.audiomuted)
  22. || (this.type === JitsiTrack.VIDEO && data.videomuted)) {
  23. this.muted = true
  24. }
  25. this.eventEmitter = eventEmitter;
  26. var self = this;
  27. if(this.stream)
  28. this.stream.onended = function () {
  29. eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_ENDED, self);
  30. }
  31. }
  32. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  33. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  34. /**
  35. * Sets current muted status and fires an events for the change.
  36. * @param value the muted status.
  37. */
  38. JitsiRemoteTrack.prototype.setMute = function (value) {
  39. this.stream.muted = value;
  40. this.muted = value;
  41. this.eventEmitter.emit(StreamEventTypes.TRACK_MUTE_CHANGED, this);
  42. };
  43. /**
  44. * Returns the current muted status of the track.
  45. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is muted and <tt>false</tt> otherwise.
  46. */
  47. JitsiRemoteTrack.prototype.isMuted = function () {
  48. return this.muted;
  49. }
  50. /**
  51. * Returns the participant id which owns the track.
  52. * @returns {string} the id of the participants.
  53. */
  54. JitsiRemoteTrack.prototype.getParitcipantId = function() {
  55. return Strophe.getResourceFromJid(this.peerjid);
  56. };
  57. delete JitsiRemoteTrack.prototype.stop;
  58. delete JitsiRemoteTrack.prototype.start;
  59. module.exports = JitsiRemoteTrack;