From 6462905b76bb5ec2ac310f727a4fb8300d126be1 Mon Sep 17 00:00:00 2001 From: Matthew Cotton Date: Wed, 22 Nov 2023 11:55:24 +1100 Subject: [PATCH 1/2] Adding support to set the streamer id in the pixel streaming initial settings. Fixes #436 --- Frontend/library/src/Config/Config.ts | 8 +++++++- Frontend/library/src/PixelStreaming/PixelStreaming.ts | 4 ++++ .../library/src/WebRtcPlayer/WebRtcPlayerController.ts | 9 +++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Frontend/library/src/Config/Config.ts b/Frontend/library/src/Config/Config.ts index b4892b6a..9d572e72 100644 --- a/Frontend/library/src/Config/Config.ts +++ b/Frontend/library/src/Config/Config.ts @@ -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; } } diff --git a/Frontend/library/src/PixelStreaming/PixelStreaming.ts b/Frontend/library/src/PixelStreaming/PixelStreaming.ts index ed0d6b2f..a8aca186 100644 --- a/Frontend/library/src/PixelStreaming/PixelStreaming.ts +++ b/Frontend/library/src/PixelStreaming/PixelStreaming.ts @@ -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, diff --git a/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts b/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts index 3e15c2ac..328ff945 100644 --- a/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts +++ b/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts @@ -1322,6 +1322,10 @@ export class WebRtcPlayerController { 6 ); + // get the current selected streamer id option + var streamerIDOption = this.config.getSettingOption(OptionParameters.StreamerId); + const currentSelectedStreamerID = 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 @@ -1330,15 +1334,16 @@ export class WebRtcPlayerController { settingOptions ); - let wantedStreamerId: string = null; + let wantedStreamerId: string = currentSelectedStreamerID; // default to previously selected 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) { From 5e71c6ff9749f2d001d820278d4a039f3ca8907e Mon Sep 17 00:00:00 2001 From: Matthew Cotton Date: Wed, 22 Nov 2023 12:52:26 +1100 Subject: [PATCH 2/2] Fixing default behaviour when joining with one streamer. --- Frontend/library/src/Config/SettingOption.ts | 2 +- .../library/src/WebRtcPlayer/WebRtcPlayerController.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Frontend/library/src/Config/SettingOption.ts b/Frontend/library/src/Config/SettingOption.ts index cc5726e3..ba2aed77 100644 --- a/Frontend/library/src/Config/SettingOption.ts +++ b/Frontend/library/src/Config/SettingOption.ts @@ -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); diff --git a/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts b/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts index 328ff945..3d9eb2d9 100644 --- a/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts +++ b/Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts @@ -1322,9 +1322,15 @@ export class WebRtcPlayerController { 6 ); + let wantedStreamerId: string = null; + // get the current selected streamer id option var streamerIDOption = this.config.getSettingOption(OptionParameters.StreamerId); - const currentSelectedStreamerID = streamerIDOption.selected; + 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 @@ -1334,7 +1340,6 @@ export class WebRtcPlayerController { settingOptions ); - let wantedStreamerId: string = currentSelectedStreamerID; // default to previously selected let autoSelectedStreamerId: string = null; const waitForStreamer = this.config.isFlagEnabled(Flags.WaitForStreamer); const reconnectLimit = this.config.getNumericSettingValue(NumericParameters.MaxReconnectAttempts);