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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ////These lines should be uncommented when require works in app.js
  2. var RTCBrowserType = require("../../service/RTC/RTCBrowserType.js");
  3. var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
  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) {
  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.ssrc = ssrc;
  29. this.type = (this.stream.getVideoTracks().length > 0)?
  30. MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
  31. this.videoType = null;
  32. this.muted = false;
  33. if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
  34. {
  35. if (!this.getVideoTracks)
  36. this.getVideoTracks = function () { return []; };
  37. if (!this.getAudioTracks)
  38. this.getAudioTracks = function () { return []; };
  39. }
  40. }
  41. MediaStream.prototype.getOriginalStream = function()
  42. {
  43. return this.stream;
  44. }
  45. MediaStream.prototype.setMute = function (value)
  46. {
  47. this.stream.muted = value;
  48. this.muted = value;
  49. }
  50. module.exports = MediaStream;