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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 () {}, data.jitsiTrackType);
  15. this.rtc = RTC;
  16. this.sid = sid;
  17. this.stream = data.stream;
  18. this.peerjid = data.peerjid;
  19. this.videoType = data.videoType;
  20. this.ssrc = ssrc;
  21. this.muted = false;
  22. if((this.isAudioTrack() && data.audiomuted)
  23. || (this.isVideoTrack() && data.videomuted)) {
  24. this.muted = true;
  25. }
  26. }
  27. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  28. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  29. /**
  30. * Sets current muted status and fires an events for the change.
  31. * @param value the muted status.
  32. */
  33. JitsiRemoteTrack.prototype.setMute = function (value) {
  34. if(this.muted === value)
  35. return;
  36. // we can have a fake video stream
  37. if(this.stream)
  38. this.stream.muted = value;
  39. this.muted = value;
  40. this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
  41. };
  42. /**
  43. * Returns the current muted status of the track.
  44. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is
  45. * 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.getParticipantId = function() {
  55. return Strophe.getResourceFromJid(this.peerjid);
  56. };
  57. /**
  58. * Return false;
  59. */
  60. JitsiRemoteTrack.prototype.isLocal = function () {
  61. return false;
  62. };
  63. /**
  64. * Return false;
  65. */
  66. JitsiRemoteTrack.prototype.getSSRC = function () {
  67. return this.ssrc;
  68. };
  69. /**
  70. * Changes the video type of the track
  71. * @param type the new video type("camera", "desktop")
  72. */
  73. JitsiRemoteTrack.prototype._setVideoType = function (type) {
  74. if(this.videoType === type)
  75. return;
  76. this.videoType = type;
  77. this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
  78. };
  79. delete JitsiRemoteTrack.prototype.dispose;
  80. module.exports = JitsiRemoteTrack;