Skip to content

Commit

Permalink
Fix linting and formatting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Belchy06 committed Dec 11, 2024
1 parent 6f8b69b commit 4ccb96d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Frontend/library/src/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export class Config {
settings && Object.prototype.hasOwnProperty.call(settings, OptionParameters.PreferredQuality)
? settings[OptionParameters.PreferredQuality]!
: 'Default',
[ 'Default' ],
['Default'],
useUrlParams
)
);
Expand Down
76 changes: 36 additions & 40 deletions Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class WebRtcPlayerController {
gamePadController: GamepadController;
coordinateConverter: InputCoordTranslator;
isUsingSFU: boolean;
isUsingSVC: boolean
isUsingSVC: boolean;
isQualityController: boolean;
statsTimerHandle: number;
file: FileTemplate;
Expand Down Expand Up @@ -287,26 +287,34 @@ export class WebRtcPlayerController {
this.protocol.sendMessage(message);
});

this.config._addOnOptionSettingChangedListener(OptionParameters.PreferredQuality, (preferredQuality) => {
if (preferredQuality === undefined || preferredQuality === '') {
return;
}
this.config._addOnOptionSettingChangedListener(
OptionParameters.PreferredQuality,
(preferredQuality) => {
if (preferredQuality === undefined || preferredQuality === '') {
return;
}

let message;
if (this.isUsingSVC)
{
// User is using SVC so selected quality will be of the form SxTy(h). Just extract the x and y numbers
message = MessageHelpers.createMessage(Messages.layerPreference, { spatialLayer: +preferredQuality[1] - 1, temporalLayer: +preferredQuality[3] - 1 });
}
else
{
// User is not using SVC so the selected quality will be either Low, Medium or High so we extract the appropriate spatial layer index
let allQualities = this.config.getSettingOption(OptionParameters.PreferredQuality).options;
let qualityIndex = allQualities.indexOf(preferredQuality);
message = MessageHelpers.createMessage(Messages.layerPreference, { spatialLayer: qualityIndex, temporalLayer: 0 });
let message;
if (this.isUsingSVC) {
// User is using SVC so selected quality will be of the form SxTy(h). Just extract the x and y numbers
message = MessageHelpers.createMessage(Messages.layerPreference, {
spatialLayer: +preferredQuality[1] - 1,
temporalLayer: +preferredQuality[3] - 1
});
} else {
// User is not using SVC so the selected quality will be either Low, Medium or High so we extract the appropriate spatial layer index
const allQualities = this.config.getSettingOption(
OptionParameters.PreferredQuality
).options;
const qualityIndex = allQualities.indexOf(preferredQuality);
message = MessageHelpers.createMessage(Messages.layerPreference, {
spatialLayer: qualityIndex,
temporalLayer: 0
});
}
this.protocol.sendMessage(message);
}
this.protocol.sendMessage(message);
});
);

this.setVideoEncoderAvgQP(-1);

Expand Down Expand Up @@ -1284,41 +1292,29 @@ export class WebRtcPlayerController {
// can switch between a default and SFU stream and have the settings reconfigure appropriately

const scalabilityMode = Offer.scalabilityMode ? Offer.scalabilityMode : 'L1T1';
let availableQualities = [ "Default" ];
if (this.isUsingSFU)
{
if (!this.isUsingSVC)
{
let availableQualities = ['Default'];
if (this.isUsingSFU) {
if (!this.isUsingSVC) {
// User is using an SFU without any temporal scalability. Just offer easily readable names
availableQualities = [ "Low", "Medium", "High" ];
}
else
{
availableQualities = ['Low', 'Medium', 'High'];
} else {
// User is using SVC. Generate all available options.
availableQualities = [];
const maxSpatialLayers = +scalabilityMode[1];
const maxTemporalLayers = +scalabilityMode[3];
for (let s = 1; s <= maxSpatialLayers; s++)
{
for (let t = 1; t <= maxTemporalLayers; t++)
{
for (let s = 1; s <= maxSpatialLayers; s++) {
for (let t = 1; t <= maxTemporalLayers; t++) {
availableQualities.push(`S${s}T${t}`);
}
}
}
}

// Update the possible video quality options
this.config.setOptionSettingOptions(
OptionParameters.PreferredQuality,
availableQualities
);
this.config.setOptionSettingOptions(OptionParameters.PreferredQuality, availableQualities);

// Update the selected video quality with the highest possible resolution
this.config.setOptionSettingValue(
OptionParameters.PreferredQuality,
availableQualities.slice(-1)[0]
)
this.config.setOptionSettingValue(OptionParameters.PreferredQuality, availableQualities.slice(-1)[0]);

const sdpOffer: RTCSessionDescriptionInit = {
sdp: Offer.sdp,
Expand Down
6 changes: 3 additions & 3 deletions Frontend/library/src/pixelstreamingfrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export {
OptionParametersIds,
AllSettings,
OptionIds,
isFlagId,
isNumericId,
isOptionId,
isFlagId,
isNumericId,
isOptionId,
isTextId
} from './Config/Config';
export { SettingBase } from './Config/SettingBase';
Expand Down
19 changes: 10 additions & 9 deletions Frontend/ui-library/src/Application/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,17 +695,18 @@ export class Application {
// as well as the selected value
this.configUI.onSettingsChanged(event);

let { data: { id, target, type } } = event;
const {
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
data: { id, target, type }
} = event;
// Explicitly handle specific setting behaviour
if (id == OptionParameters.PreferredQuality)
{
const preferredQualityOption = this.stream.config.getSettingOption(OptionParameters.PreferredQuality);
if ([...preferredQualityOption.options].includes('Default'))
{
if (id == OptionParameters.PreferredQuality) {
const preferredQualityOption = this.stream.config.getSettingOption(
OptionParameters.PreferredQuality
);
if ([...preferredQualityOption.options].includes('Default')) {
this.configUI.disableSetting(OptionParameters.PreferredQuality);
}
else
{
} else {
this.configUI.enableSetting(OptionParameters.PreferredQuality);
}
}
Expand Down
34 changes: 10 additions & 24 deletions Frontend/ui-library/src/Config/ConfigUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,39 +381,25 @@ export class ConfigUI {
}

disableSetting(id: OptionIds | ExtraFlagsIds): void {
if (isFlagId(id))
{
if (isFlagId(id)) {
this.flagsUi.get(id)?.disable();
}
else if(isNumericId(id))
{
} else if (isNumericId(id)) {
this.numericParametersUi.get(id)?.disable();
}
else if(isTextId(id))
{
this.textParametersUi.get(id)?.disable();
}
else if(isOptionId(id))
{
} else if (isTextId(id)) {
this.textParametersUi.get(id)?.disable();
} else if (isOptionId(id)) {
this.optionParametersUi.get(id)?.disable();
}
}

enableSetting(id: OptionIds | ExtraFlagsIds): void {
if (isFlagId(id))
{
if (isFlagId(id)) {
this.flagsUi.get(id)?.enable();
}
else if(isNumericId(id))
{
} else if (isNumericId(id)) {
this.numericParametersUi.get(id)?.enable();
}
else if(isTextId(id))
{
this.textParametersUi.get(id)?.enable();
}
else if(isOptionId(id))
{
} else if (isTextId(id)) {
this.textParametersUi.get(id)?.enable();
} else if (isOptionId(id)) {
this.optionParametersUi.get(id)?.enable();
}
}
Expand Down

0 comments on commit 4ccb96d

Please sign in to comment.