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.

MediaStream.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
  2. /**
  3. * Creates a MediaStream object for the given data, session id and ssrc.
  4. * It is a wrapper class for the MediaStream.
  5. *
  6. * @param data the data object from which we obtain the stream,
  7. * the peerjid, etc.
  8. * @param ssrc the ssrc corresponding to this MediaStream
  9. * @param mute the whether this MediaStream is muted
  10. *
  11. * @constructor
  12. */
  13. function MediaStream(data, ssrc, browser, eventEmitter, muted) {
  14. // XXX(gp) to minimize headaches in the future, we should build our
  15. // abstractions around tracks and not streams. ORTC is track based API.
  16. // Mozilla expects m-lines to represent media tracks.
  17. //
  18. // Practically, what I'm saying is that we should have a MediaTrack class
  19. // and not a MediaStream class.
  20. //
  21. // Also, we should be able to associate multiple SSRCs with a MediaTrack as
  22. // a track might have an associated RTX and FEC sources.
  23. this.stream = data.stream;
  24. this.peerjid = data.peerjid;
  25. this.videoType = data.videoType;
  26. this.ssrc = ssrc;
  27. this.type = (this.stream.getVideoTracks().length > 0)?
  28. MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
  29. this.muted = muted;
  30. this.eventEmitter = eventEmitter;
  31. }
  32. MediaStream.prototype.getOriginalStream = function() {
  33. return this.stream;
  34. };
  35. MediaStream.prototype.setMute = function (value) {
  36. this.stream.muted = value;
  37. this.muted = value;
  38. };
  39. module.exports = MediaStream;