Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Fix max bitrate not being set correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehb committed Feb 22, 2023
1 parent b2fb702 commit b912071
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Frontend/library/src/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export class Config {
'Min Bitrate (kbps)',
'The minimum bitrate that WebRTC should use.',
0 /*min*/,
100000 /*max*/,
500000 /*max*/,
0 /*value*/,
useUrlParams
)
Expand All @@ -474,7 +474,7 @@ export class Config {
'Max Bitrate (kbps)',
'The maximum bitrate that WebRTC should use.',
0 /*min*/,
100000 /*max*/,
500000 /*max*/,
0 /*value*/,
useUrlParams
)
Expand Down
43 changes: 6 additions & 37 deletions Frontend/library/src/PixelStreaming/PixelStreaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,7 @@ export class PixelStreaming {
'-------- Sending web rtc settings --------',
7
);
const webRtcSettings: WebRTCSettings = {
FPS: this.config.getNumericSettingValue(
NumericParameters.WebRTCFPS
),
MinBitrate: newValue * 1000,
MaxBitrate:
this.config.getNumericSettingValue(
NumericParameters.WebRTCMaxBitrate
) * 1000
};
this.webRtcController.sendWebRtcSettings(webRtcSettings);
this.webRtcController.sendWebRTCMinBitrate(newValue * 1000 /* kbps to bps */);
Logger.Log(
Logger.GetStackTrace(),
'-------------------------------------------',
Expand All @@ -243,17 +233,7 @@ export class PixelStreaming {
'-------- Sending web rtc settings --------',
7
);
const webRtcSettings: WebRTCSettings = {
FPS: this.config.getNumericSettingValue(
NumericParameters.WebRTCFPS
),
MinBitrate:
this.config.getNumericSettingValue(
NumericParameters.WebRTCMinBitrate
) * 1000,
MaxBitrate: newValue * 1000
};
this.webRtcController.sendWebRtcSettings(webRtcSettings);
this.webRtcController.sendWebRTCMaxBitrate(newValue * 1000 /* kbps to bps */);
Logger.Log(
Logger.GetStackTrace(),
'-------------------------------------------',
Expand All @@ -270,18 +250,7 @@ export class PixelStreaming {
'-------- Sending web rtc settings --------',
7
);
const webRtcSettings: WebRTCSettings = {
FPS: newValue,
MinBitrate:
this.config.getNumericSettingValue(
NumericParameters.WebRTCMinBitrate
) * 1000,
MaxBitrate:
this.config.getNumericSettingValue(
NumericParameters.WebRTCMaxBitrate
) * 1000
};
this.webRtcController.sendWebRtcSettings(webRtcSettings);
this.webRtcController.sendWebRTCFps(newValue);
Logger.Log(
Logger.GetStackTrace(),
'-------------------------------------------',
Expand Down Expand Up @@ -531,11 +500,11 @@ export class PixelStreaming {
if (settings.WebRTCSettings) {
this.config.setNumericSetting(
NumericParameters.WebRTCMinBitrate,
settings.WebRTCSettings.MinBitrate
settings.WebRTCSettings.MinBitrate / 1000 /* bps to kbps */
);
this.config.setNumericSetting(
NumericParameters.WebRTCMinBitrate,
settings.WebRTCSettings.MaxBitrate
NumericParameters.WebRTCMaxBitrate,
settings.WebRTCSettings.MaxBitrate / 1000 /* bps to kbps */
);
this.config.setNumericSetting(
NumericParameters.WebRTCFPS,
Expand Down
56 changes: 33 additions & 23 deletions Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,36 +1572,46 @@ export class WebRtcPlayerController {
}

/**
* Send the WebRTC Settings to the UE Instance as a UE UI Descriptor.
* @param webRTC - Web RTC Settings
* Send the { WebRTC.MinBitrate: SomeNumber }} command to UE to set
* the minimum bitrate that we allow WebRTC to use
* (note setting this too high in poor networks can be problematic).
* @param minBitrate - The minimum bitrate we would like WebRTC to not fall below.
*/
sendWebRtcSettings(webRTC: WebRTCSettings) {
Logger.Log(
Logger.GetStackTrace(),
'---- WebRTC Settings ----\n' +
JSON.stringify(webRTC, undefined, 4) +
'\n-------------------------------',
6
);

// 4.27 and 5 compatibility
if (webRTC.FPS != null) {
this.sendDescriptorController.emitCommand({
'WebRTC.Fps': webRTC.FPS
});
sendWebRTCMinBitrate(minBitrate: number) {
Logger.Log(Logger.GetStackTrace(), `WebRTC Min Bitrate=${minBitrate}`, 6);
if (minBitrate != null) {
this.sendDescriptorController.emitCommand({
'WebRTC.MaxFps': webRTC.FPS
'WebRTC.MinBitrate': minBitrate
});
}
if (webRTC.MinBitrate != null) {
}

/**
* Send the { WebRTC.MaxBitrate: SomeNumber }} command to UE to set
* the minimum bitrate that we allow WebRTC to use
* (note setting this too low could result in blocky video).
* @param minBitrate - The minimum bitrate we would like WebRTC to not fall below.
*/
sendWebRTCMaxBitrate(maxBitrate: number) {
Logger.Log(Logger.GetStackTrace(), `WebRTC Max Bitrate=${maxBitrate}`, 6);
if (maxBitrate != null) {
this.sendDescriptorController.emitCommand({
'PixelStreaming.WebRTC.MinBitrate': webRTC.MinBitrate
'WebRTC.MaxBitrate': maxBitrate
});
}
if (webRTC.MaxBitrate != null) {
this.sendDescriptorController.emitCommand({
'PixelStreaming.WebRTC.MaxBitrate ': webRTC.MaxBitrate
});
}

/**
* Send the { WebRTC.Fps: SomeNumber }} UE 5.0+
* and { WebRTC.MaxFps } UE 4.27 command to set
* the maximum fps we would like WebRTC to stream at.
* @param fps - The maximum stream fps.
*/
sendWebRTCFps(fps: number) {
Logger.Log(Logger.GetStackTrace(), `WebRTC FPS=${fps}`, 6);
if (fps != null) {
this.sendDescriptorController.emitCommand({'WebRTC.Fps': fps});
this.sendDescriptorController.emitCommand({'WebRTC.MaxFps': fps}); /* TODO: Remove when UE 4.27 unsupported. */
}
}

Expand Down

0 comments on commit b912071

Please sign in to comment.