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

Bitrate negotiation on stream startup #425

Merged
merged 4 commits into from
Nov 13, 2023
Merged

Bitrate negotiation on stream startup #425

merged 4 commits into from
Nov 13, 2023

Conversation

mcottontensor
Copy link
Contributor

  • Added min/max bitrate requests for offer/answer messages
  • Fixing bitrate values in the frontend units and parsing.

Relevant components:

  • Signalling server
  • Frontend library
  • Frontend UI library
  • Matchmaker
  • Platform scripts
  • SFU

Problem statement:

Setting the bitrate values before starting the stream did not work.

Solution

Added min/max bitrate values to the answer signalling message so the streamer can extract them and set them when needed.

Documentation

Test Plan and Compatibility

Will probably need a QA pass.

(offer/answer) from the player
- Fixing bitrate values units and parsing.
Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments about organising params into an struct/config object.

const minBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMinBitrate);
const maxBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate);

this.webSocketController.sendWebRtcOffer(offer, minBitrate, maxBitrate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than appending more parameters here (as I am certain we will want more in the future) can we instead pass an offerOptions, offerParams, offerConfig, or something like this as the additional parameter to this function/

const minBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMinBitrate);
const maxBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate);

this.webSocketController.sendWebRtcAnswer(answer, minBitrate, maxBitrate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above about an options param.

* Good for excluding default values or hidden internals.
* Return undefined to exclude the property completely.
*/
sendFilter(key: string, value: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Can comment have an example of how it should be used.

@@ -1551,7 +1551,11 @@ export class WebRtcPlayerController {
'Sending the offer to the Server',
6
);
this.webSocketController.sendWebRtcOffer(offer);

const minBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMinBitrate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming as minBitrateBps, although technicaly bitrate implies bps, the word bitrate is also used for kilobits and megabits quite often so I think the extra clarity here helps.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes to naming/structuring really.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment about using ExtraParams object even more.

sendWebRtcOffer(offer: RTCSessionDescriptionInit, minBitrate: number, maxBitrate: number) {
const payload = new MessageSend.MessageWebRTCOffer(offer, minBitrate, maxBitrate);
sendWebRtcOffer(offer: RTCSessionDescriptionInit, extraParams: ExtraOfferParameters) {
const payload = new MessageSend.MessageWebRTCOffer(offer, extraParams.minBitrateBps, extraParams.maxBitrateBps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the constructor of MessageSend.MessageWebRTCOffer and MessageSend.MessageWebRTCAnswer take the ExtraParameters object for the same reason (so constructor doesn't grow overlong as we add more).

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor correct to type used I think

@@ -134,7 +149,7 @@ export class MessageWebRTCAnswer extends MessageSend {
/**
* @param answer - Generated Web RTC Offer
*/
constructor(answer: RTCSessionDescriptionInit, minBitrate: number, maxBitrate: number) {
constructor(answer: RTCSessionDescriptionInit, extraParams: ExtraOfferParameters) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offer params passed to answer?

Copy link
Contributor

@lukehb lukehb Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also comment:

@ param answer - Generated Web RTC Offer

Seems wrong in the same way, talking about offer in answer constructor.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@mcottontensor mcottontensor merged commit a7afbc3 into EpicGames:master Nov 13, 2023
@mcottontensor mcottontensor deleted the initial_bitrates branch November 13, 2023 21:49
@DenisTensorWorks
Copy link
Collaborator

This PR closes this issue: #275

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants