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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 sid the session id
  9. * @param ssrc the ssrc corresponding to this MediaStream
  10. *
  11. * @constructor
  12. */
  13. function MediaStream(data, sid, ssrc, browser, eventEmitter) {
  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.sid = sid;
  24. this.stream = data.stream;
  25. this.peerjid = data.peerjid;
  26. this.videoType = data.videoType;
  27. this.ssrc = ssrc;
  28. this.type = (this.stream.getVideoTracks().length > 0)?
  29. MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
  30. this.muted = false;
  31. this.eventEmitter = eventEmitter;
  32. }
  33. MediaStream.prototype.getOriginalStream = function() {
  34. return this.stream;
  35. };
  36. MediaStream.prototype.setMute = function (value) {
  37. this.stream.muted = value;
  38. this.muted = value;
  39. };
  40. module.exports = MediaStream;