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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -111,16 +111,27 @@ var RTC = {
|
|||
muted = pres.videoMuted;
|
||||
}
|
||||
|
||||
var remoteStream = new MediaStream(data, ssrc,
|
||||
RTCBrowserType.getBrowserType(), eventEmitter, muted);
|
||||
|
||||
if(!this.remoteStreams[jid]) {
|
||||
this.remoteStreams[jid] = {};
|
||||
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;
|
||||
}
|
||||
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,
|
||||
remoteStream);
|
||||
return remoteStream;
|
||||
});
|
||||
},
|
||||
getPCConstraints: function () {
|
||||
return this.rtcUtils.pc_constraints;
|
||||
|
|
Loading…
Reference in New Issue