Skip to content

Commit

Permalink
Fix negotiation problems in Single PeerConnection (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun committed Feb 7, 2019
1 parent 2eb262c commit f2384ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
13 changes: 11 additions & 2 deletions erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const BaseStack = (specInput) => {

const checkOfferQueue = () => {
if (!isNegotiating && offerQueue.length > 0) {
const args = offerQueue.pop();
const args = offerQueue.shift();
if (args[0] === 'local') {
that.createOffer(args[1], args[2], args[3]);
} else {
Expand Down Expand Up @@ -145,8 +145,16 @@ const BaseStack = (specInput) => {
offerQueue.push(['remote', message]);
return;
}
isNegotiating = true;
remoteSdp = SemanticSdp.SDPInfo.processString(msg.sdp);

const sessionVersion = remoteSdp && remoteSdp.origin && remoteSdp.origin.sessionVersion;
if (latestSessionVersion >= sessionVersion) {
Logger.warning(`message: processOffer discarding old sdp sessionVersion: ${sessionVersion}, latestSessionVersion: ${latestSessionVersion}`);
return;
}
isNegotiating = true;
latestSessionVersion = sessionVersion;

SdpHelpers.setMaxBW(remoteSdp, specBase);
msg.sdp = remoteSdp.toString();
that.remoteSdp = remoteSdp;
Expand All @@ -164,6 +172,7 @@ const BaseStack = (specInput) => {
remoteSdp = SemanticSdp.SDPInfo.processString(msg.sdp);
const sessionVersion = remoteSdp && remoteSdp.origin && remoteSdp.origin.sessionVersion;
if (latestSessionVersion >= sessionVersion) {
Logger.warning(`processAnswer discarding old sdp, sessionVersion: ${sessionVersion}, latestSessionVersion: ${latestSessionVersion}`);
return;
}
Logger.info('Set remote and local description');
Expand Down
9 changes: 7 additions & 2 deletions erizo_controller/erizoJS/models/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,17 @@ class Connection extends events.EventEmitter {
if (!this.wrtc.localDescription) {
return;
}
this.wrtc.localDescription = new SessionDescription(this.wrtc.getLocalDescription());
const sdp = this.wrtc.localDescription.getSdp(this.sessionVersion);
this.sessionVersion += 1;
const stream = sdp.getStream(label);
if (stream && removeStream) {
sdp.removeStream(stream);
log.info(`resendLastAnswer: StreamId ${streamId} is stream and removeStream, label ${label}, sessionVersion ${this.sessionVersion}`);
setTimeout(() => {
this._resendLastAnswer(evt, streamId, label, forceOffer, removeStream);
}, 50);
return;
}
this.sessionVersion += 1;
let message = sdp.toString();
message = message.replace(this.options.privateRegexp, this.options.publicIP);

Expand Down
7 changes: 7 additions & 0 deletions erizo_controller/erizoJS/models/SessionDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ class SessionDescription {

getSdp(sessionVersion = 0) {
if (this.sdp) {
this.sdp.setOrigin({
username: '-',
sessionId: 0,
sessionVersion,
netType: 'IN',
ipVer: 4,
address: '127.0.0.1' });
return this.sdp;
}
const info = this.connectionDescription;
Expand Down

0 comments on commit f2384ef

Please sign in to comment.