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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var JitsiTrack = require("./JitsiTrack");
  2. var JitsiTrackEvents = require("../../JitsiTrackEvents");
  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) {
  13. JitsiTrack.call(this, RTC, data.stream,
  14. function () {
  15. this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
  16. }.bind(this));
  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. }
  29. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  30. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  31. /**
  32. * Sets current muted status and fires an events for the change.
  33. * @param value the muted status.
  34. */
  35. JitsiRemoteTrack.prototype.setMute = function (value) {
  36. this.stream.muted = value;
  37. this.muted = value;
  38. this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
  39. };
  40. /**
  41. * Returns the current muted status of the track.
  42. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is muted and <tt>false</tt> otherwise.
  43. */
  44. JitsiRemoteTrack.prototype.isMuted = function () {
  45. return this.muted;
  46. }
  47. /**
  48. * Returns the participant id which owns the track.
  49. * @returns {string} the id of the participants.
  50. */
  51. JitsiRemoteTrack.prototype.getParticipantId = function() {
  52. return Strophe.getResourceFromJid(this.peerjid);
  53. };
  54. /**
  55. * Return false;
  56. */
  57. JitsiRemoteTrack.prototype.isLocal = function () {
  58. return false;
  59. }
  60. delete JitsiRemoteTrack.prototype.stop;
  61. delete JitsiRemoteTrack.prototype.start;
  62. module.exports = JitsiRemoteTrack;