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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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), data.jitsiTrackType);
  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. if(this.muted === value)
  37. return;
  38. // we can have a fake video stream
  39. if(this.stream)
  40. this.stream.muted = value;
  41. this.muted = value;
  42. this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
  43. };
  44. /**
  45. * Returns the current muted status of the track.
  46. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is muted and <tt>false</tt> otherwise.
  47. */
  48. JitsiRemoteTrack.prototype.isMuted = function () {
  49. return this.muted;
  50. };
  51. /**
  52. * Returns the participant id which owns the track.
  53. * @returns {string} the id of the participants.
  54. */
  55. JitsiRemoteTrack.prototype.getParticipantId = function() {
  56. return Strophe.getResourceFromJid(this.peerjid);
  57. };
  58. /**
  59. * Return false;
  60. */
  61. JitsiRemoteTrack.prototype.isLocal = function () {
  62. return false;
  63. };
  64. delete JitsiRemoteTrack.prototype.stop;
  65. module.exports = JitsiRemoteTrack;