This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 259
Bitrate negotiation on stream startup #425
Merged
mcottontensor
merged 4 commits into
EpicGames:master
from
mcottontensor:initial_bitrates
Nov 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
const maxBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate); | ||
|
||
this.webSocketController.sendWebRtcOffer(offer, minBitrate, maxBitrate); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/ |
||
} | ||
|
||
/** | ||
|
@@ -1564,7 +1568,11 @@ export class WebRtcPlayerController { | |
'Sending the answer to the Server', | ||
6 | ||
); | ||
this.webSocketController.sendWebRtcAnswer(answer); | ||
|
||
const minBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMinBitrate); | ||
const maxBitrate = 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate); | ||
|
||
this.webSocketController.sendWebRtcAnswer(answer, minBitrate, maxBitrate); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about an options param. |
||
|
||
if (this.isUsingSFU) { | ||
this.webSocketController.sendWebRtcDatachannelRequest(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,17 +24,26 @@ export class MessageSend implements Send { | |
type: string; | ||
peerConnectionOptions: object; | ||
|
||
/** | ||
* A filter for controlling what parameters to actually send. | ||
* Good for excluding default values or hidden internals. | ||
* Return undefined to exclude the property completely. | ||
*/ | ||
sendFilter(key: string, value: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
return value; | ||
} | ||
|
||
/** | ||
* Turns the wrapper into a JSON String | ||
* @returns - JSON String of the Message to send | ||
*/ | ||
payload() { | ||
Logger.Log( | ||
Logger.GetStackTrace(), | ||
'Sending => \n' + JSON.stringify(this, undefined, 4), | ||
'Sending => \n' + JSON.stringify(this, this.sendFilter, 4), | ||
6 | ||
); | ||
return JSON.stringify(this); | ||
return JSON.stringify(this, this.sendFilter); | ||
} | ||
} | ||
|
||
|
@@ -88,39 +97,61 @@ export class MessagePong extends MessageSend { | |
*/ | ||
export class MessageWebRTCOffer extends MessageSend { | ||
sdp: string; | ||
minBitrate: number; | ||
maxBitrate: number; | ||
|
||
/** | ||
* @param offer - Generated Web RTC Offer | ||
*/ | ||
constructor(offer?: RTCSessionDescriptionInit) { | ||
constructor(offer: RTCSessionDescriptionInit, minBitrate: number, maxBitrate: number) { | ||
super(); | ||
this.type = MessageSendTypes.OFFER; | ||
this.minBitrate = 0; | ||
this.maxBitrate = 0; | ||
|
||
if (offer) { | ||
this.type = offer.type as MessageSendTypes; | ||
this.sdp = offer.sdp; | ||
this.minBitrate = minBitrate; | ||
this.maxBitrate = maxBitrate; | ||
} | ||
} | ||
|
||
sendFilter(key: string, value: any) { | ||
if ((key == "minBitrate" || key == "maxBitrate") && value <= 0) return undefined; | ||
return value; | ||
} | ||
} | ||
|
||
/** | ||
* Web RTC Answer message wrapper | ||
*/ | ||
export class MessageWebRTCAnswer extends MessageSend { | ||
sdp: string; | ||
minBitrate: number; | ||
maxBitrate: number; | ||
|
||
/** | ||
* @param answer - Generated Web RTC Offer | ||
*/ | ||
constructor(answer?: RTCSessionDescriptionInit) { | ||
constructor(answer: RTCSessionDescriptionInit, minBitrate: number, maxBitrate: number) { | ||
super(); | ||
this.type = MessageSendTypes.ANSWER; | ||
this.minBitrate = 0; | ||
this.maxBitrate = 0; | ||
|
||
if (answer) { | ||
this.type = answer.type as MessageSendTypes; | ||
this.sdp = answer.sdp; | ||
this.minBitrate = minBitrate; | ||
this.maxBitrate = maxBitrate; | ||
} | ||
} | ||
|
||
sendFilter(key: string, value: any) { | ||
if ((key == "minBitrate" || key == "maxBitrate") && value <= 0) return undefined; | ||
return value; | ||
} | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.