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.

JitsiTrack.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var RTC = require("./RTCUtils");
  2. /**
  3. * Represents a single media track (either audio or video).
  4. * @constructor
  5. */
  6. function JitsiTrack(RTC, stream)
  7. {
  8. this.rtc = RTC;
  9. this.stream = stream;
  10. this.type = (this.stream.getVideoTracks().length > 0)?
  11. JitsiTrack.VIDEO : JitsiTrack.AUDIO;
  12. if(this.type == "audio") {
  13. this._getTracks = function () {
  14. return this.stream.getAudioTracks();
  15. }.bind(this);
  16. } else {
  17. this._getTracks = function () {
  18. return this.stream.getVideoTracks();
  19. }.bind(this);
  20. }
  21. }
  22. /**
  23. * JitsiTrack video type.
  24. * @type {string}
  25. */
  26. JitsiTrack.VIDEO = "video";
  27. /**
  28. * JitsiTrack audio type.
  29. * @type {string}
  30. */
  31. JitsiTrack.AUDIO = "audio";
  32. /**
  33. * Returns the type (audio or video) of this track.
  34. */
  35. JitsiTrack.prototype.getType = function() {
  36. return this.type;
  37. };
  38. /**
  39. * Returns the RTCMediaStream from the browser (?).
  40. */
  41. JitsiTrack.prototype.getOriginalStream = function() {
  42. return this.stream;
  43. }
  44. /**
  45. * Mutes the track.
  46. */
  47. JitsiTrack.prototype.mute = function () {
  48. this._setMute(true);
  49. }
  50. /**
  51. * Unmutes the stream.
  52. */
  53. JitsiTrack.prototype.unmute = function () {
  54. this._setMute(false);
  55. }
  56. /**
  57. * Attaches the MediaStream of this track to an HTML container (?).
  58. * @param container the HTML container
  59. */
  60. JitsiTrack.prototype.attach = function (container) {
  61. RTC.attachMediaStream(container, this.stream);
  62. }
  63. /**
  64. * Removes the track from the passed HTML container.
  65. * @param container the HTML container
  66. */
  67. JitsiTrack.prototype.detach = function (container) {
  68. $(container).find(">video").remove();
  69. }
  70. /**
  71. * Stops sending the media track. And removes it from the HTML.
  72. * NOTE: Works for local tracks only.
  73. */
  74. JitsiTrack.prototype.stop = function () {
  75. this.detach();
  76. }
  77. /**
  78. * Starts sending the track.
  79. * NOTE: Works for local tracks only.
  80. */
  81. JitsiTrack.prototype.start = function() {
  82. }
  83. /**
  84. * Returns true if this is a video track and the source of the video is a
  85. * screen capture as opposed to a camera.
  86. */
  87. JitsiTrack.prototype.isScreenSharing = function(){
  88. }
  89. /**
  90. * Returns id of the track.
  91. * @returns {string} id of the track or null if this is fake track.
  92. */
  93. JitsiTrack.prototype.getId = function () {
  94. var tracks = this.stream.getTracks();
  95. if(!tracks || tracks.length === 0)
  96. return null;
  97. return tracks[0].id;
  98. };
  99. module.exports = JitsiTrack;