Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

JitsiRemoteTrack.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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(conference, ownerJid, stream, track, mediaType, videoType,
  16. ssrc, muted) {
  17. JitsiTrack.call(
  18. this, conference, stream, track, function () {}, mediaType, videoType, ssrc);
  19. this.conference = conference;
  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. * Returns the synchronization source identifier (SSRC) of this remote track.
  61. * @returns {string} the SSRC of this remote track
  62. */
  63. JitsiRemoteTrack.prototype.getSSRC = function () {
  64. return this.ssrc;
  65. };
  66. /**
  67. * Changes the video type of the track
  68. * @param type the new video type("camera", "desktop")
  69. */
  70. JitsiRemoteTrack.prototype._setVideoType = function (type) {
  71. if(this.videoType === type)
  72. return;
  73. this.videoType = type;
  74. this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
  75. };
  76. module.exports = JitsiRemoteTrack;