Creates multiple (Jitsi-Meet) MediaStreams if the RTCMediaStream object

contains both audio and video tracks.
This commit is contained in:
Boris Grozev 2015-10-28 11:24:18 -05:00
parent 14fe5d09d1
commit cd1e761699
2 changed files with 26 additions and 12 deletions

View File

@ -11,7 +11,7 @@ var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
*
* @constructor
*/
function MediaStream(data, ssrc, browser, eventEmitter, muted) {
function MediaStream(data, ssrc, browser, eventEmitter, muted, type) {
// XXX(gp) to minimize headaches in the future, we should build our
// abstractions around tracks and not streams. ORTC is track based API.
@ -23,12 +23,15 @@ function MediaStream(data, ssrc, browser, eventEmitter, muted) {
// Also, we should be able to associate multiple SSRCs with a MediaTrack as
// a track might have an associated RTX and FEC sources.
if (!type) {
console.log("Errrm...some code needs an update...");
}
this.stream = data.stream;
this.peerjid = data.peerjid;
this.videoType = data.videoType;
this.ssrc = ssrc;
this.type = (this.stream.getVideoTracks().length > 0)?
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
this.type = type;
this.muted = muted;
this.eventEmitter = eventEmitter;
}

View File

@ -111,16 +111,27 @@ var RTC = {
muted = pres.videoMuted;
}
var remoteStream = new MediaStream(data, ssrc,
RTCBrowserType.getBrowserType(), eventEmitter, muted);
var self = this;
[MediaStreamType.AUDIO_TYPE, MediaStreamType.VIDEO_TYPE].forEach(
function(type) {
var tracks =
type == MediaStreamType.AUDIO_TYPE
? data.stream.getAudioTracks : data.stream.getVideoTracks();
if (!tracks || !Array.isArray(tracks) || !tracks.length) {
console.log("Not creating a(n) "+type+" stream: no tracks");
return;
}
if(!this.remoteStreams[jid]) {
this.remoteStreams[jid] = {};
}
this.remoteStreams[jid][remoteStream.type]= remoteStream;
eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
remoteStream);
return remoteStream;
var remoteStream = new MediaStream(data, ssrc,
RTCBrowserType.getBrowserType(), eventEmitter, muted, type);
if (!self.remoteStreams[jid]) {
self.remoteStreams[jid] = {};
}
self.remoteStreams[jid][type] = remoteStream;
eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
remoteStream);
});
},
getPCConstraints: function () {
return this.rtcUtils.pc_constraints;