Skip to content

Commit

Permalink
cleanup console logs and non-config properties (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdumaine authored and tgabi333 committed May 17, 2016
1 parent 7bfb948 commit 1f1acda
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions rtcpeerconnection.js
Expand Up @@ -146,14 +146,17 @@ function PeerConnection(config, constraints) {

this.config = {
debug: false,
ice: {},
remoteIce: {},
sid: '',
isInitiator: true,
sdpSessionID: Date.now(),
useJingle: false
};

this.iceCredentials = {
local: {},
remote: {}
};

// apply our config
for (item in config) {
this.config[item] = config[item];
Expand Down Expand Up @@ -282,9 +285,8 @@ PeerConnection.prototype.processIce = function (update, cb) {
cb();
};

if (self.config.remoteIce[content.name] && transport.ufrag &&
self.config.remoteIce[content.name].ufrag !== transport.ufrag) {
console.log('ice restart needed', transport);
if (self.iceCredentials.remote[content.name] && transport.ufrag &&
self.iceCredentials.remote[content.name].ufrag !== transport.ufrag) {
if (remoteContent) {
remoteContent.transport.ufrag = transport.ufrag;
remoteContent.transport.pwd = transport.pwd;
Expand All @@ -299,15 +301,14 @@ PeerConnection.prototype.processIce = function (update, cb) {
});
self.pc.setRemoteDescription(new RTCSessionDescription(offer),
function () {
console.log('ice success updating remote desctipion');
processCandidates();
},
function (err) {
console.error('ice failed to update remote description', err);
self.emit('error', err);
}
);
} else {
console.error('ice failed to find matching content');
self.emit('error', 'ice restart failed to find matching content');
}
} else {
processCandidates();
Expand Down Expand Up @@ -381,7 +382,7 @@ PeerConnection.prototype.offer = function (constraints, cb) {
each(jingle.contents, function (content) {
var transport = content.transport || {};
if (transport.ufrag) {
self.config.ice[content.name] = {
self.iceCredentials.local[content.name] = {
ufrag: transport.ufrag,
pwd: transport.pwd
};
Expand Down Expand Up @@ -473,7 +474,7 @@ PeerConnection.prototype.handleOffer = function (offer, cb) {
each(offer.jingle.contents, function (content) {
var transport = content.transport || {};
if (transport.ufrag) {
self.config.remoteIce[content.name] = {
self.iceCredentials.remote[content.name] = {
ufrag: transport.ufrag,
pwd: transport.pwd
};
Expand Down Expand Up @@ -551,7 +552,7 @@ PeerConnection.prototype.handleAnswer = function (answer, cb) {
each(answer.jingle.contents, function (content) {
var transport = content.transport || {};
if (transport.ufrag) {
self.config.remoteIce[content.name] = {
self.iceCredentials.remote[content.name] = {
ufrag: transport.ufrag,
pwd: transport.pwd
};
Expand Down Expand Up @@ -793,15 +794,15 @@ PeerConnection.prototype._onIce = function (event) {
ice.sdpMid = self.localDescription.contents[ice.sdpMLineIndex].name;
}
}
if (!self.config.ice[ice.sdpMid]) {
if (!self.iceCredentials.local[ice.sdpMid]) {
var jingle = SJJ.toSessionJSON(self.pc.localDescription.sdp, {
role: self._role(),
direction: 'outgoing'
});
each(jingle.contents, function (content) {
var transport = content.transport || {};
if (transport.ufrag) {
self.config.ice[content.name] = {
self.iceCredentials.local[content.name] = {
ufrag: transport.ufrag,
pwd: transport.pwd
};
Expand All @@ -814,8 +815,8 @@ PeerConnection.prototype._onIce = function (event) {
creator: self._role(),
transport: {
transportType: 'iceUdp',
ufrag: self.config.ice[ice.sdpMid].ufrag,
pwd: self.config.ice[ice.sdpMid].pwd,
ufrag: self.iceCredentials.local[ice.sdpMid].ufrag,
pwd: self.iceCredentials.local[ice.sdpMid].pwd,
candidates: [
cand
]
Expand Down

0 comments on commit 1f1acda

Please sign in to comment.