Creates multiple (Jitsi-Meet) MediaStreams if the RTCMediaStream object
contains both audio and video tracks.
This commit is contained in:
parent
14fe5d09d1
commit
cd1e761699
|
@ -11,7 +11,7 @@ var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
|
||||||
*
|
*
|
||||||
* @constructor
|
* @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
|
// XXX(gp) to minimize headaches in the future, we should build our
|
||||||
// abstractions around tracks and not streams. ORTC is track based API.
|
// 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
|
// Also, we should be able to associate multiple SSRCs with a MediaTrack as
|
||||||
// a track might have an associated RTX and FEC sources.
|
// 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.stream = data.stream;
|
||||||
this.peerjid = data.peerjid;
|
this.peerjid = data.peerjid;
|
||||||
this.videoType = data.videoType;
|
this.videoType = data.videoType;
|
||||||
this.ssrc = ssrc;
|
this.ssrc = ssrc;
|
||||||
this.type = (this.stream.getVideoTracks().length > 0)?
|
this.type = type;
|
||||||
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
|
|
||||||
this.muted = muted;
|
this.muted = muted;
|
||||||
this.eventEmitter = eventEmitter;
|
this.eventEmitter = eventEmitter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,16 +111,27 @@ var RTC = {
|
||||||
muted = pres.videoMuted;
|
muted = pres.videoMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
var remoteStream = new MediaStream(data, ssrc,
|
var self = this;
|
||||||
RTCBrowserType.getBrowserType(), eventEmitter, muted);
|
[MediaStreamType.AUDIO_TYPE, MediaStreamType.VIDEO_TYPE].forEach(
|
||||||
|
function(type) {
|
||||||
if(!this.remoteStreams[jid]) {
|
var tracks =
|
||||||
this.remoteStreams[jid] = {};
|
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;
|
||||||
}
|
}
|
||||||
this.remoteStreams[jid][remoteStream.type]= 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,
|
eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
|
||||||
remoteStream);
|
remoteStream);
|
||||||
return remoteStream;
|
});
|
||||||
},
|
},
|
||||||
getPCConstraints: function () {
|
getPCConstraints: function () {
|
||||||
return this.rtcUtils.pc_constraints;
|
return this.rtcUtils.pc_constraints;
|
||||||
|
|
Loading…
Reference in New Issue