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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 ownerJid the MUC JID of the track owner
  7. * @param stream WebRTC MediaStream, parent of the track
  8. * @param track underlying WebRTC MediaStreamTrack for new JitsiRemoteTrack
  9. * @param mediaType the MediaType of the JitsiRemoteTrack
  10. * @param videoType the VideoType of the JitsiRemoteTrack
  11. * @param ssrc the SSRC number of the Media Stream
  12. * @param muted intial muted state of the JitsiRemoteTrack
  13. * @constructor
  14. */
  15. function JitsiRemoteTrack(RTC, ownerJid, stream, track, mediaType, videoType,
  16. ssrc, muted) {
  17. JitsiTrack.call(
  18. this, RTC, stream, track, function () {}, mediaType, videoType, ssrc);
  19. this.rtc = RTC;
  20. this.peerjid = ownerJid;
  21. this.muted = muted;
  22. }
  23. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  24. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  25. /**
  26. * Sets current muted status and fires an events for the change.
  27. * @param value the muted status.
  28. */
  29. JitsiRemoteTrack.prototype.setMute = function (value) {
  30. if(this.muted === value)
  31. return;
  32. // we can have a fake video stream
  33. if(this.stream)
  34. this.stream.muted = value;
  35. this.muted = value;
  36. this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
  37. };
  38. /**
  39. * Returns the current muted status of the track.
  40. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is
  41. * muted and <tt>false</tt> otherwise.
  42. */
  43. JitsiRemoteTrack.prototype.isMuted = function () {
  44. return this.muted;
  45. };
  46. /**
  47. * Returns the participant id which owns the track.
  48. * @returns {string} the id of the participants.
  49. */
  50. JitsiRemoteTrack.prototype.getParticipantId = function() {
  51. return Strophe.getResourceFromJid(this.peerjid);
  52. };
  53. /**
  54. * Return false;
  55. */
  56. JitsiRemoteTrack.prototype.isLocal = function () {
  57. return false;
  58. };
  59. /**
  60. * Return false;
  61. */
  62. JitsiRemoteTrack.prototype.getSSRC = function () {
  63. return this.ssrc;
  64. };
  65. /**
  66. * Changes the video type of the track
  67. * @param type the new video type("camera", "desktop")
  68. */
  69. JitsiRemoteTrack.prototype._setVideoType = function (type) {
  70. if(this.videoType === type)
  71. return;
  72. this.videoType = type;
  73. this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
  74. };
  75. delete JitsiRemoteTrack.prototype.dispose;
  76. module.exports = JitsiRemoteTrack;