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.6KB

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