modified lib-jitsi-meet dev repo
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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.type === JitsiTrack.AUDIO && data.audiomuted)
  23. || (this.type === JitsiTrack.VIDEO && 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 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.getParticipantId = function() {
  54. return Strophe.getResourceFromJid(this.peerjid);
  55. };
  56. /**
  57. * Return false;
  58. */
  59. JitsiRemoteTrack.prototype.isLocal = function () {
  60. return false;
  61. };
  62. /**
  63. * Return false;
  64. */
  65. JitsiRemoteTrack.prototype.getSSRC = function () {
  66. return this.ssrc;
  67. };
  68. /**
  69. * Changes the video type of the track
  70. * @param type the new video type("camera", "desktop")
  71. */
  72. JitsiRemoteTrack.prototype._setVideoType = function (type) {
  73. if(this.videoType === type)
  74. return;
  75. this.videoType = type;
  76. this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
  77. }
  78. delete JitsiRemoteTrack.prototype.dispose;
  79. module.exports = JitsiRemoteTrack;