您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

JitsiRemoteTrack.js 2.6KB

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. * @param isFake true if the track is not associated with Media Stream.
  14. * @constructor
  15. */
  16. function JitsiRemoteTrack(RTC, ownerJid, stream, track, mediaType, videoType,
  17. ssrc, muted, isFake) {
  18. JitsiTrack.call(
  19. this, RTC, stream, track, function () {}, mediaType, videoType, ssrc);
  20. this.rtc = RTC;
  21. this.peerjid = ownerJid;
  22. this.muted = muted;
  23. this.isFake = isFake? isFake : false;
  24. }
  25. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  26. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  27. /**
  28. * Sets current muted status and fires an events for the change.
  29. * @param value the muted status.
  30. */
  31. JitsiRemoteTrack.prototype.setMute = function (value) {
  32. if(this.muted === value)
  33. return;
  34. // we can have a fake video stream
  35. if(this.stream)
  36. this.stream.muted = value;
  37. this.muted = value;
  38. this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
  39. };
  40. /**
  41. * Returns the current muted status of the track.
  42. * @returns {boolean|*|JitsiRemoteTrack.muted} <tt>true</tt> if the track is
  43. * muted and <tt>false</tt> otherwise.
  44. */
  45. JitsiRemoteTrack.prototype.isMuted = function () {
  46. return this.muted;
  47. };
  48. /**
  49. * Returns the participant id which owns the track.
  50. * @returns {string} the id of the participants.
  51. */
  52. JitsiRemoteTrack.prototype.getParticipantId = function() {
  53. return Strophe.getResourceFromJid(this.peerjid);
  54. };
  55. /**
  56. * Return false;
  57. */
  58. JitsiRemoteTrack.prototype.isLocal = function () {
  59. return false;
  60. };
  61. /**
  62. * Returns the synchronization source identifier (SSRC) of this remote track.
  63. * @returns {string} the SSRC of this remote track
  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. module.exports = JitsiRemoteTrack;