Skip to content

Commit

Permalink
Add start and hard min bitrate (lynckia#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Apr 4, 2018
1 parent 1a41464 commit 02c24ce
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
8 changes: 8 additions & 0 deletions doc/client_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ We can also force the client to use a TURN server when publishing by setting the
room.publish(localStream, {forceTurn: true});
```

There are two options that allow advance control of video bitrate in Chrome:
- `startVideoBW`: Configures Chrome to start sending video at the specified bitrate instead of the default one.
- `hardMinVideoBW`: Configures a hard limit for the minimum video bitrate.

```
room.publish(localStream, {startVideoBW: 1000, hardMinVideoBW:500});
```

In `room.publish` you can include a callback with two parameters, `id` and `error`. If the stream has been published, `id` contains the id of that stream. On the other hand, if there has been any kind of error, `id` is `undefined` and the error is described in `error`.

<example>
Expand Down
4 changes: 4 additions & 0 deletions erizo_controller/common/semanticSdp/CodecInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class CodecInfo {
return this.params;
}

setParam(paramName, value) {
this.params[paramName] = value;
}

hasRTX() {
return this.rtx;
}
Expand Down
5 changes: 4 additions & 1 deletion erizo_controller/erizoClient/src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,12 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
limitMaxVideoBW: spec.maxVideoBW,
label: stream.getLabel(),
iceServers: that.iceServers,
forceTurn: stream.forceTurn };
forceTurn: stream.forceTurn,
};
if (!isRemote) {
connectionOpts.simulcast = options.simulcast;
connectionOpts.startVideoBW = options.startVideoBW;
connectionOpts.hardMinVideoBW = options.hardMinVideoBW;
}
return connectionOpts;
};
Expand Down
10 changes: 10 additions & 0 deletions erizo_controller/erizoClient/src/utils/SdpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ SdpHelpers.enableOpusNacks = (sdpInput) => {
return sdp;
};

SdpHelpers.setParamForCodecs = (sdpInfo, mediaType, paramName, value) => {
sdpInfo.medias.forEach((mediaInfo) => {
if (mediaInfo.id === mediaType) {
mediaInfo.codecs.forEach((codec) => {
codec.setParam(paramName, value);
});
}
});
};

export default SdpHelpers;
17 changes: 15 additions & 2 deletions erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,15 @@ const BaseStack = (specInput) => {
return;
}
Logger.info('Set remote and local description');
Logger.debug('Remote Description', msg.sdp);
Logger.debug('Local Description', localDesc.sdp);
latestSessionVersion = sessionVersion;

SdpHelpers.setMaxBW(remoteSdp, specBase);
that.setStartVideoBW(remoteSdp);
that.setHardMinVideoBW(remoteSdp);

msg.sdp = remoteSdp.toString();
Logger.debug('Remote Description', msg.sdp);
Logger.debug('Local Description', localDesc.sdp);
that.remoteSdp = remoteSdp;

remoteDesc = msg;
Expand Down Expand Up @@ -206,6 +209,16 @@ const BaseStack = (specInput) => {
that.peerConnection.onicecandidate = onIceCandidate;
// public functions

that.setStartVideoBW = (sdpInput) => {
Logger.error('startVideoBW not implemented for this browser');
return sdpInput;
};

that.setHardMinVideoBW = (sdpInput) => {
Logger.error('hardMinVideoBw not implemented for this browser');
return sdpInput;
};

that.enableSimulcast = (sdpInput) => {
Logger.error('Simulcast not implemented');
return sdpInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ const ChromeStableStack = (specInput) => {
return sdp.replace(matchGroup[0], result);
};

that.setStartVideoBW = (sdpInfo) => {
if (spec.video && spec.startVideoBW) {
Logger.debug(`startVideoBW requested: ${spec.startVideoBW}`);
SdpHelpers.setParamForCodecs(sdpInfo, 'video', 'x-google-start-bitrate', spec.startVideoBW);
}
};

that.setHardMinVideoBW = (sdpInfo) => {
if (spec.video && spec.hardMinVideoBW) {
Logger.debug(`hardMinVideoBW requested: ${spec.hardMinVideoBW}`);
SdpHelpers.setParamForCodecs(sdpInfo, 'video', 'x-google-min-bitrate', spec.hardMinVideoBW);
}
};

return that;
};

Expand Down

0 comments on commit 02c24ce

Please sign in to comment.