Skip to content

Commit

Permalink
RTCSession: emit 'sdp' event before creating offer/answer
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaseel authored and jmillan committed Nov 21, 2017
1 parent 28bd62e commit 3de21ef
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,10 +1392,12 @@ module.exports = class RTCSession extends EventEmitter
}

const e = { originator: 'remote', type: 'answer', sdp: request.body };
const answer = new RTCSessionDescription({ type: 'answer', sdp: e.sdp });

debug('emit "sdp"');
this.emit('sdp', e);

const answer = new RTCSessionDescription({ type: 'answer', sdp: e.sdp });

this._connectionPromiseQueue = this._connectionPromiseQueue
.then(() => this._connection.setRemoteDescription(answer))
.then(() =>
Expand Down Expand Up @@ -2033,10 +2035,12 @@ module.exports = class RTCSession extends EventEmitter
}

const e = { originator: 'remote', type: 'offer', sdp: request.body };
const offer = new RTCSessionDescription({ type: 'offer', sdp: e.sdp });

debug('emit "sdp"');
this.emit('sdp', e);

const offer = new RTCSessionDescription({ type: 'offer', sdp: e.sdp });

this._connectionPromiseQueue = this._connectionPromiseQueue
.then(() => this._connection.setRemoteDescription(offer))
.then(doAnswer.bind(this))
Expand Down Expand Up @@ -2648,7 +2652,6 @@ module.exports = class RTCSession extends EventEmitter
const e = { originator: 'remote', type: 'answer', sdp: response.body };

debug('emit "sdp"');

this.emit('sdp', e);

const answer = new RTCSessionDescription({ type: 'answer', sdp: e.sdp });
Expand Down Expand Up @@ -2691,8 +2694,8 @@ module.exports = class RTCSession extends EventEmitter
this._connectionPromiseQueue = this._connectionPromiseQueue
.then(() =>
{
// Be ready for 200 with SDP after a 180/183 with SDP. We created a SDP 'answer'
// for it, so check the current signaling state.
// Be ready for 200 with SDP after a 180/183 with SDP.
// We created a SDP 'answer' for it, so check the current signaling state.
if (this._connection.signalingState === 'stable')
{
return this._connection.createOffer()
Expand Down

0 comments on commit 3de21ef

Please sign in to comment.