From 346f93dd16aeb00a12658023037c56394834a0af Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Thu, 10 Sep 2020 01:13:15 +0200 Subject: [PATCH] Maintain information about whether renegotiation is permitted. Renegotiation is not correct when the stream is fresh, for example after the user has switched the camera. --- static/protocol.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/protocol.js b/static/protocol.js index b64a89d..787d9a6 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -701,6 +701,13 @@ function Stream(sc, id, pc) { * @type {Array.} */ this.iceCandidates = []; + /** + * Indicates whether it is legal to renegotiate at this point. If + * this is false, a new connection must be negotiated. + * + * @type {boolean} + */ + this.renegotiate = false; /** * The statistics last computed by the stats handler. This is * a dictionary indexed by track id, with each value a disctionary of @@ -854,11 +861,12 @@ Stream.prototype.negotiate = async function (restartIce) { c.sc.send({ type: 'offer', - kind: 'renegotiate', + kind: this.renegotiate ? 'renegotiate' : '', id: c.id, labels: c.labelsByMid, offer: offer, }); + this.renegotiate = true; } /**