您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MediaStream.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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, eventEmmiter, 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. eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
  34. if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
  35. {
  36. if (!this.getVideoTracks)
  37. this.getVideoTracks = function () { return []; };
  38. if (!this.getAudioTracks)
  39. this.getAudioTracks = function () { return []; };
  40. }
  41. }
  42. MediaStream.prototype.getOriginalStream = function()
  43. {
  44. return this.stream;
  45. }
  46. MediaStream.prototype.setMute = function (value)
  47. {
  48. this.stream.muted = value;
  49. this.muted = value;
  50. }
  51. module.exports = MediaStream;