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

JitsiRemoteTrack.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 () {
  15. this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
  16. }.bind(this), data.type);
  17. this.rtc = RTC;
  18. this.sid = sid;
  19. this.stream = data.stream;
  20. this.peerjid = data.peerjid;
  21. this.videoType = data.videoType;
  22. this.ssrc = ssrc;
  23. this.muted = false;
  24. if((this.type === JitsiTrack.AUDIO && data.audiomuted)
  25. || (this.type === JitsiTrack.VIDEO && data.videomuted)) {
  26. this.muted = true;
  27. }
  28. }
  29. JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
  30. JitsiRemoteTrack.prototype.constructor = JitsiRemoteTrack;
  31. /**
  32. * Sets current muted status and fires an events for the change.
  33. * @param value the muted status.
  34. */
  35. JitsiRemoteTrack.prototype.setMute = function (value) {
  36. if(this.muted === value)
  37. return;
  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. delete JitsiRemoteTrack.prototype.stop;
  63. module.exports = JitsiRemoteTrack;