From b5f50fd580659bd1de15cf98905910f5037dd87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5var=20Aamb=C3=B8=20Fosstveit?= Date: Fri, 26 Oct 2018 20:18:55 +0200 Subject: [PATCH] Fixed problems with paused consumers --- app/lib/LastN.js | 12 ++++++++++++ app/lib/RoomClient.js | 13 ++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/lib/LastN.js b/app/lib/LastN.js index 7534d16..99b2e7f 100644 --- a/app/lib/LastN.js +++ b/app/lib/LastN.js @@ -31,6 +31,18 @@ export default class LastN extends EventEmitter this._lastNUpdated(); } + peerInLastN(peerName) + { + if (this._started) + { + return this._currentLastN.indexOf(peerName) !== -1; + } + else + { + return false; + } + } + _handleRoom() { this._room.on('newpeer', (peer) => diff --git a/app/lib/RoomClient.js b/app/lib/RoomClient.js index d3ad99e..45e0b8b 100644 --- a/app/lib/RoomClient.js +++ b/app/lib/RoomClient.js @@ -353,9 +353,7 @@ export default class RoomClient { for (const consumer of peer.consumers) { - if (consumer.appData.source !== 'webcam' || - !consumer.supported || - !consumer.locallyPaused) + if (consumer.kind !== 'video' || !consumer.supported) continue; await consumer.resume(); @@ -365,12 +363,10 @@ export default class RoomClient { for (const consumer of peer.consumers) { - if (consumer.appData.source !== 'webcam' || - !consumer.supported || - consumer.locallyPaused) + if (consumer.kind !== 'video') continue; - await consumer.pause(); + await consumer.pause('not-speaker'); } } } @@ -1835,8 +1831,7 @@ export default class RoomClient // Receive the consumer (if we can). if (consumer.supported) { - if (consumer.kind === 'video' && - Object.keys(this._room.peers).length > this._lastNSpeakers) + if (consumer.kind === 'video' && !this._lastN.peerInLastN(consumer.peer.name)) { // Start paused logger.debug( 'consumer paused by default');