Skip to content

Commit

Permalink
Fix initializing connection target bw (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Jul 14, 2021
1 parent 802e42b commit 1a85da4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions erizo_controller/erizoController/models/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class Client extends events.EventEmitter {
this.options = options;
this.options.streamPriorityStrategy =
Client.getStreamPriorityStrategy(options.streamPriorityStrategy);
this.options.connectionTargetBw = Number.isInteger(options.connectionTargetBw) ?
options.connectionTargetBw : this.options.streamPriorityStrategy.connectionTargetBw;
this.options.connectionTargetBw =
(this.getStreamPriorityStrategyDefinition() &&
this.getStreamPriorityStrategyDefinition().connectionTargetBw)
|| 0;
this.socketEventListeners = new Map();
this.listenToSocketEvents();
this.user = { name: token.userName, role: token.role, permissions: {} };
Expand Down Expand Up @@ -60,6 +62,15 @@ class Client extends events.EventEmitter {
this.channel.socketRemoveListener(key, value);
});
}

getStreamPriorityStrategyDefinition() {
if (this.options.streamPriorityStrategy) {
return global.bwDistributorConfig
.strategyDefinitions[this.options.streamPriorityStrategy];
}
return false;
}

static getStreamPriorityStrategy(streamPriorityStrategy) {
log.debug(`message: getting streamPriorityStrategy configuration, streamPriorityStrategy: ${streamPriorityStrategy}`);
const isStrategyIsDefined = streamPriorityStrategy
Expand Down Expand Up @@ -720,7 +731,8 @@ class Client extends events.EventEmitter {
onSetStreamPriorityStrategy(strategyId, callback = () => {}) {
this.options.streamPriorityStrategy =
Client.getStreamPriorityStrategy(strategyId);
this.options.connectionTargetBw = this.options.streamPriorityStrategy.connectionTargetBw;
this.options.connectionTargetBw =
this.getStreamPriorityStrategyDefinition().connectionTargetBw || 0;
this.room.amqper.broadcast('ErizoJS', { method: 'setClientStreamPriorityStrategy', args: [this.id, strategyId] });
callback();
}
Expand Down

0 comments on commit 1a85da4

Please sign in to comment.