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

MediaStream.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * @param mute the whether this MediaStream is muted
  11. *
  12. * @constructor
  13. */
  14. function MediaStream(data, sid, ssrc, browser, eventEmitter, mute) {
  15. // XXX(gp) to minimize headaches in the future, we should build our
  16. // abstractions around tracks and not streams. ORTC is track based API.
  17. // Mozilla expects m-lines to represent media tracks.
  18. //
  19. // Practically, what I'm saying is that we should have a MediaTrack class
  20. // and not a MediaStream class.
  21. //
  22. // Also, we should be able to associate multiple SSRCs with a MediaTrack as
  23. // a track might have an associated RTX and FEC sources.
  24. this.sid = sid;
  25. this.stream = data.stream;
  26. this.peerjid = data.peerjid;
  27. this.videoType = data.videoType;
  28. this.ssrc = ssrc;
  29. this.type = (this.stream.getVideoTracks().length > 0)?
  30. MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
  31. this.muted = mute;
  32. this.eventEmitter = eventEmitter;
  33. }
  34. MediaStream.prototype.getOriginalStream = function() {
  35. return this.stream;
  36. };
  37. MediaStream.prototype.setMute = function (value) {
  38. this.stream.muted = value;
  39. this.muted = value;
  40. };
  41. module.exports = MediaStream;