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

Commit

Permalink
Merge pull request #438 from mcottontensor/player_config_streamerid
Browse files Browse the repository at this point in the history
Fixing handling of StreamerId in the initial config settings.
  • Loading branch information
mcottontensor committed Nov 22, 2023
2 parents 7eba788 + 5e71c6f commit a3b76a3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Frontend/library/src/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,13 @@ export class Config {
`Cannot set text setting called ${id} - it does not exist in the Config.enumParameters map.`
);
} else {
this.optionParameters.get(id).selected = settingValue;
const optionSetting = this.optionParameters.get(id);
const existingOptions = optionSetting.options;
if (!existingOptions.includes(settingValue)) {
existingOptions.push(settingValue);
optionSetting.options = existingOptions;
}
optionSetting.selected = settingValue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Frontend/library/src/Config/SettingOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class SettingOption<
// eslint-disable-next-line @typescript-eslint/no-empty-function
defaultOnChangeListener: (changedValue: unknown, setting: SettingBase) => void = () => { /* Do nothing, to be overridden. */ }
) {
super(id, label, description, [defaultTextValue, defaultTextValue], defaultOnChangeListener);
super(id, label, description, [defaultTextValue], defaultOnChangeListener);

this.options = options;
const urlParams = new URLSearchParams(window.location.search);
Expand Down
4 changes: 4 additions & 0 deletions Frontend/library/src/PixelStreaming/PixelStreaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ export class PixelStreaming {

const useUrlParams = this.config.useUrlParams;
const urlParams = new URLSearchParams(window.location.search);
Logger.Info(
Logger.GetStackTrace(),
`using URL parameters ${useUrlParams}`
);
if (settings.EncoderSettings) {
this.config.setNumericSetting(
NumericParameters.MinQP,
Expand Down
14 changes: 12 additions & 2 deletions Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,16 @@ export class WebRtcPlayerController {
6
);

let wantedStreamerId: string = null;

// get the current selected streamer id option
var streamerIDOption = this.config.getSettingOption(OptionParameters.StreamerId);
const existingSelection = streamerIDOption.selected.toString().trim();
if (!!existingSelection) {
// default to selected option if it exists
wantedStreamerId = streamerIDOption.selected;
}

// add the streamers to the UI
const settingOptions = [...messageStreamerList.ids]; // copy the original messageStreamerList.ids
settingOptions.unshift(''); // add an empty option at the top
Expand All @@ -1330,15 +1340,15 @@ export class WebRtcPlayerController {
settingOptions
);

let wantedStreamerId: string = null;
let autoSelectedStreamerId: string = null;
const waitForStreamer = this.config.isFlagEnabled(Flags.WaitForStreamer);
const reconnectLimit = this.config.getNumericSettingValue(NumericParameters.MaxReconnectAttempts);
const reconnectDelay = this.config.getNumericSettingValue(NumericParameters.StreamerAutoJoinInterval);

// first we figure out a wanted streamer id through various means
const useUrlParams = this.config.useUrlParams;
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has(OptionParameters.StreamerId)) {
if (useUrlParams && urlParams.has(OptionParameters.StreamerId)) {
// if we've set the streamer id on the url we only want that streamer id
wantedStreamerId = urlParams.get(OptionParameters.StreamerId);
} else if (this.subscribedStream) {
Expand Down

0 comments on commit a3b76a3

Please sign in to comment.