From 91117979130b764dc0eb086c04bee41b57ba0133 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Thu, 29 Oct 2015 14:30:30 -0500 Subject: [PATCH] Removes a tangle of spaghetti. --- modules/RTC/RTC.js | 25 ------------------------- modules/xmpp/JingleSessionPC.js | 14 ++++++-------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/modules/RTC/RTC.js b/modules/RTC/RTC.js index 901f7fd62..3edf99506 100644 --- a/modules/RTC/RTC.js +++ b/modules/RTC/RTC.js @@ -53,7 +53,6 @@ var RTC = { audio: true, video: true }, - localStreams: [], remoteStreams: {}, localAudio: null, localVideo: null, @@ -74,10 +73,6 @@ var RTC = { var localStream = new LocalStream(stream, type, eventEmitter, videoType, isGUMStream); - //in firefox we have only one stream object - if(this.localStreams.length === 0 || - this.localStreams[0].getOriginalStream() != stream) - this.localStreams.push(localStream); if(isMuted === true) localStream.setMute(true); @@ -93,14 +88,6 @@ var RTC = { eventEmitter.emit(eventType, localStream, isMuted); return localStream; }, - removeLocalStream: function (stream) { - for(var i = 0; i < this.localStreams.length; i++) { - if(this.localStreams[i].getOriginalStream() === stream) { - delete this.localStreams[i]; - return; - } - } - }, createRemoteStream: function (data, ssrc) { var jid = data.peerjid || APP.xmpp.myJid(); @@ -203,16 +190,6 @@ var RTC = { } return false; }, - switchVideoStreams: function (newStream) { - this.localVideo.stream = newStream; - - this.localStreams = []; - - //in firefox we have only one stream object - if (this.localAudio.getOriginalStream() != newStream) - this.localStreams.push(this.localAudio); - this.localStreams.push(this.localVideo); - }, changeLocalVideo: function (stream, isUsingScreenStream, callback) { var oldStream = this.localVideo.getOriginalStream(); var type = (isUsingScreenStream ? "screen" : "camera"); @@ -236,8 +213,6 @@ var RTC = { // Stop the stream to trigger onended event for old stream oldStream.stop(); - this.switchVideoStreams(videoStream); - APP.xmpp.switchStreams(videoStream, oldStream,localCallback); }, changeLocalAudio: function (stream, callback) { diff --git a/modules/xmpp/JingleSessionPC.js b/modules/xmpp/JingleSessionPC.js index 1715da802..cb5b4a30b 100644 --- a/modules/xmpp/JingleSessionPC.js +++ b/modules/xmpp/JingleSessionPC.js @@ -20,7 +20,6 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) { this.state = null; this.localSDP = null; this.remoteSDP = null; - this.relayedStreams = []; this.pc_constraints = null; this.usetrickle = true; @@ -169,13 +168,12 @@ JingleSessionPC.prototype.doInitialize = function () { this.peerconnection.onnegotiationneeded = function (event) { self.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, self); }; - // add any local and relayed stream - APP.RTC.localStreams.forEach(function(stream) { - self.peerconnection.addStream(stream.getOriginalStream()); - }); - this.relayedStreams.forEach(function(stream) { - self.peerconnection.addStream(stream); - }); + if (APP.RTC.localAudio) { + self.peerconnection.addStream(APP.RTC.localAudio.getOriginalStream()); + } + if (APP.RTC.localVideo) { + self.peerconnection.addStream(APP.RTC.localVideo.getOriginalStream()); + } }; function onIceConnectionStateChange(sid, session) {