Skip to content

Commit

Permalink
Add a client API to update simulcast layer bitrate (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Aug 2, 2019
1 parent a1cbdeb commit fa5ff61
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
12 changes: 11 additions & 1 deletion doc/client_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ In the next table we can see the functions of this class:
| [setAttributes()](#set-the-attributes-object) | It sets new attributes to the local stream that are spread to the room. |
| [getVideoFrame()](#set-the-attributes-object) | It gets a Bitmap from the video. |
| [getVideoFrameURL()](#get-the-url-of-a-frame-from-the-video) | It gets the URL of a Bitmap from the video. |
| [updateConfiguration(config, callback)](#get-the-url-of-a-frame-from-the-video) | Updates the spec of a stream. |
| [updateConfiguration(config, callback)](#update-the-spec-of-a-stream) | Updates the spec of a stream. |
| [updateSimulcastLayersBitrate(config)](#update-simulcast-layers-bitrate) | Updates the bitrates for each simulcast layer. |

## Check if the stream has audio, video and/or data active

Expand Down Expand Up @@ -311,6 +312,15 @@ console.log(result);
});
```

## Update Simulcast Layers Bitrate

It allows us to change the max bitrate assigned for each spatial layer in Simulcast. It can only be applied to publishers.
```
localStream.updateSimulcastLayersBitrate({0: 80000, 1: 430000});
```

In this example we are configuring 2 spatial layers bitrates, limiting the lower layer to 80 Kbps and the higher to 430 Kbps.

# Room

It represents a Licode Room. It will handle the connection, local stream publication and remote stream subscription.
Expand Down
4 changes: 4 additions & 0 deletions erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class ErizoConnection extends EventEmitterConst {
updateSpec(configInput, streamId, callback) {
this.stack.updateSpec(configInput, streamId, callback);
}

updateSimulcastLayersBitrate(bitrates) {
this.stack.updateSimulcastLayersBitrate(bitrates);
}
}

class ErizoConnectionManager {
Expand Down
6 changes: 6 additions & 0 deletions erizo_controller/erizoClient/src/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ const Stream = (altConnectionHelpers, specInput) => {
controlHandler(handlers, publisherSide, true);
};

that.updateSimulcastLayersBitrate = (bitrates) => {
if (that.pc && that.local) {
that.pc.updateSimulcastLayersBitrate(bitrates);
}
};

that.updateConfiguration = (config, callback = () => {}) => {
if (config === undefined) { return; }
if (that.pc) {
Expand Down
7 changes: 7 additions & 0 deletions erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ const BaseStack = (specInput) => {
return sdpInput;
};

that.updateSimulcastLayersBitrate = (bitrates) => {
if (that.simulcast) {
that.simulcast.spatialLayerBitrates = bitrates;
that.setSimulcastLayersBitrate();
}
};

that.setSimulcastLayersBitrate = () => {
Logger.error('Simulcast not implemented');
};
Expand Down
2 changes: 1 addition & 1 deletion erizo_controller/erizoJS/erizoJSController.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ exports.ErizoJSController = (erizoJSId, threadPool, ioThreadPool) => {
return;
}

if (publisher.cliendId === clientId) {
if (publisher.clientId === clientId) {
node = publisher;
} else if (publisher.hasSubscriber(clientId)) {
node = publisher.getSubscriber(clientId);
Expand Down
4 changes: 2 additions & 2 deletions erizo_controller/test/erizoJS/erizoJSController.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ describe('Erizo JS Controller', () => {
});

it('should mute and unmute publisher stream', () => {
controller.processStreamMessage(kArbitraryErizoControllerId, undefined,
controller.processStreamMessage(kArbitraryErizoControllerId, kArbitraryClientId,
kArbitraryStreamId, {
type: 'updatestream',
config: {
Expand All @@ -583,7 +583,7 @@ describe('Erizo JS Controller', () => {
},
} });

controller.processStreamMessage(kArbitraryErizoControllerId, undefined,
controller.processStreamMessage(kArbitraryErizoControllerId, kArbitraryClientId,
kArbitraryStreamId, {
type: 'updatestream',
config: {
Expand Down

0 comments on commit fa5ff61

Please sign in to comment.