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 StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
  4. //var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
  5. /**
  6. * Creates a MediaStream object for the given data, session id and ssrc.
  7. * It is a wrapper class for the MediaStream.
  8. *
  9. * @param data the data object from which we obtain the stream,
  10. * the peerjid, etc.
  11. * @param sid the session id
  12. * @param ssrc the ssrc corresponding to this MediaStream
  13. *
  14. * @constructor
  15. */
  16. function MediaStream(data, sid, ssrc, browser) {
  17. // XXX(gp) to minimize headaches in the future, we should build our
  18. // abstractions around tracks and not streams. ORTC is track based API.
  19. // Mozilla expects m-lines to represent media tracks.
  20. //
  21. // Practically, what I'm saying is that we should have a MediaTrack class
  22. // and not a MediaStream class.
  23. //
  24. // Also, we should be able to associate multiple SSRCs with a MediaTrack as
  25. // a track might have an associated RTX and FEC sources.
  26. this.sid = sid;
  27. this.stream = data.stream;
  28. this.peerjid = data.peerjid;
  29. this.ssrc = ssrc;
  30. this.type = (this.stream.getVideoTracks().length > 0)?
  31. MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
  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;