2015-01-28 14:35:22 +00:00
|
|
|
var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
|
2014-12-19 13:59:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a MediaStream object for the given data, session id and ssrc.
|
|
|
|
* It is a wrapper class for the MediaStream.
|
|
|
|
*
|
|
|
|
* @param data the data object from which we obtain the stream,
|
|
|
|
* the peerjid, etc.
|
|
|
|
* @param ssrc the ssrc corresponding to this MediaStream
|
2015-09-02 21:05:00 +00:00
|
|
|
* @param mute the whether this MediaStream is muted
|
2014-12-19 13:59:08 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
2015-10-01 20:10:55 +00:00
|
|
|
function MediaStream(data, ssrc, browser, eventEmitter, muted) {
|
2014-12-22 14:08:49 +00:00
|
|
|
|
|
|
|
// XXX(gp) to minimize headaches in the future, we should build our
|
|
|
|
// abstractions around tracks and not streams. ORTC is track based API.
|
|
|
|
// Mozilla expects m-lines to represent media tracks.
|
|
|
|
//
|
|
|
|
// Practically, what I'm saying is that we should have a MediaTrack class
|
|
|
|
// and not a MediaStream class.
|
|
|
|
//
|
|
|
|
// Also, we should be able to associate multiple SSRCs with a MediaTrack as
|
|
|
|
// a track might have an associated RTX and FEC sources.
|
|
|
|
|
2014-12-19 13:59:08 +00:00
|
|
|
this.stream = data.stream;
|
|
|
|
this.peerjid = data.peerjid;
|
2015-07-14 13:35:13 +00:00
|
|
|
this.videoType = data.videoType;
|
2014-12-19 13:59:08 +00:00
|
|
|
this.ssrc = ssrc;
|
|
|
|
this.type = (this.stream.getVideoTracks().length > 0)?
|
|
|
|
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
|
2015-10-01 20:10:55 +00:00
|
|
|
this.muted = muted;
|
2015-03-17 16:46:08 +00:00
|
|
|
this.eventEmitter = eventEmitter;
|
2014-12-19 13:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-28 19:42:01 +00:00
|
|
|
MediaStream.prototype.getOriginalStream = function() {
|
2014-12-19 13:59:08 +00:00
|
|
|
return this.stream;
|
2015-03-17 16:46:08 +00:00
|
|
|
};
|
2014-12-19 13:59:08 +00:00
|
|
|
|
2015-07-28 19:42:01 +00:00
|
|
|
MediaStream.prototype.setMute = function (value) {
|
2014-12-19 13:59:08 +00:00
|
|
|
this.stream.muted = value;
|
|
|
|
this.muted = value;
|
2015-03-17 16:46:08 +00:00
|
|
|
};
|
|
|
|
|
2014-12-19 13:59:08 +00:00
|
|
|
module.exports = MediaStream;
|