Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

MediaStream.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 ssrc the ssrc corresponding to this MediaStream
  9. * @param mute the whether this MediaStream is muted
  10. *
  11. * @constructor
  12. */
  13. function MediaStream(data, ssrc, browser, eventEmitter, muted, type) {
  14. // XXX(gp) to minimize headaches in the future, we should build our
  15. // abstractions around tracks and not streams. ORTC is track based API.
  16. // Mozilla expects m-lines to represent media tracks.
  17. //
  18. // Practically, what I'm saying is that we should have a MediaTrack class
  19. // and not a MediaStream class.
  20. //
  21. // Also, we should be able to associate multiple SSRCs with a MediaTrack as
  22. // a track might have an associated RTX and FEC sources.
  23. if (!type) {
  24. console.log("Errrm...some code needs an update...");
  25. }
  26. this.stream = data.stream;
  27. this.peerjid = data.peerjid;
  28. this.videoType = data.videoType;
  29. this.ssrc = ssrc;
  30. this.type = type;
  31. this.muted = muted;
  32. this.eventEmitter = eventEmitter;
  33. }
  34. // FIXME duplicated with LocalStream methods - extract base class
  35. MediaStream.prototype.isAudioStream = function () {
  36. return MediaStreamType.AUDIO_TYPE === this.type;
  37. };
  38. MediaStream.prototype.isVideoStream = function () {
  39. return MediaStreamType.VIDEO_TYPE === this.type;
  40. };
  41. MediaStream.prototype.getOriginalStream = function () {
  42. return this.stream;
  43. };
  44. MediaStream.prototype.setMute = function (value) {
  45. this.stream.muted = value;
  46. this.muted = value;
  47. };
  48. module.exports = MediaStream;