@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,6 +50,10 @@ export class NumericParameters {
50
50
  static AFKCountdownSecs = 'AFKCountdown' as const;
51
51
  static MinQP = 'MinQP' as const;
52
52
  static MaxQP = 'MaxQP' as const;
53
+ static MinQuality = 'MinQuality' as const;
54
+ static MaxQuality = 'MaxQuality' as const;
55
+ static CompatQualityMin = 'CompatQualityMin' as const;
56
+ static CompatQualityMax = 'CompatQualityMax' as const;
53
57
  static WebRTCFPS = 'WebRTCFPS' as const;
54
58
  static WebRTCMinBitrate = 'WebRTCMinBitrate' as const;
55
59
  static WebRTCMaxBitrate = 'WebRTCMaxBitrate' as const;
@@ -622,6 +626,66 @@ export class Config {
622
626
  )
623
627
  );
624
628
 
629
+ this.numericParameters.set(
630
+ NumericParameters.MinQuality,
631
+ new SettingNumber(
632
+ NumericParameters.MinQuality,
633
+ 'Min Quality',
634
+ 'The lower bound for the quality factor of the encoder. 0 = Worst quality, 100 = Best quality.',
635
+ 0 /*min*/,
636
+ 100 /*max*/,
637
+ settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MinQuality)
638
+ ? settings[NumericParameters.MinQuality]
639
+ : 0 /*value*/,
640
+ useUrlParams
641
+ )
642
+ );
643
+
644
+ this.numericParameters.set(
645
+ NumericParameters.MaxQuality,
646
+ new SettingNumber(
647
+ NumericParameters.MaxQuality,
648
+ 'Max Quality',
649
+ 'The upper bound for the quality factor of the encoder. 0 = Worst quality, 100 = Best quality.',
650
+ 0 /*min*/,
651
+ 100 /*max*/,
652
+ settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.MaxQuality)
653
+ ? settings[NumericParameters.MaxQuality]
654
+ : 100 /*value*/,
655
+ useUrlParams
656
+ )
657
+ );
658
+
659
+ this.numericParameters.set(
660
+ NumericParameters.CompatQualityMin,
661
+ new SettingNumber(
662
+ NumericParameters.CompatQualityMin,
663
+ 'Min Quality',
664
+ 'The lower bound for encoding quality. 0 = Worst, 100 = Best.',
665
+ 0 /*min*/,
666
+ 100 /*max*/,
667
+ settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.CompatQualityMin)
668
+ ? settings[NumericParameters.CompatQualityMin]
669
+ : 0 /*value*/,
670
+ useUrlParams
671
+ )
672
+ );
673
+
674
+ this.numericParameters.set(
675
+ NumericParameters.CompatQualityMax,
676
+ new SettingNumber(
677
+ NumericParameters.CompatQualityMax,
678
+ 'Max Quality',
679
+ 'The upper bound for encoding quality. 0 = Worst, 100 = Best.',
680
+ 0 /*min*/,
681
+ 100 /*max*/,
682
+ settings && Object.prototype.hasOwnProperty.call(settings, NumericParameters.CompatQualityMax)
683
+ ? settings[NumericParameters.CompatQualityMax]
684
+ : 100 /*value*/,
685
+ useUrlParams
686
+ )
687
+ );
688
+
625
689
  this.numericParameters.set(
626
690
  NumericParameters.WebRTCFPS,
627
691
  new SettingNumber(
@@ -40,6 +40,8 @@ export class EncoderSettings {
40
40
  MaxBitrate?: number;
41
41
  MinQP?: number;
42
42
  MaxQP?: number;
43
+ MinQuality?: number;
44
+ MaxQuality?: number;
43
45
  RateControl?: 'CBR' | 'VBR' | 'ConstQP';
44
46
  FillerData?: boolean;
45
47
  MultiPass?: 'DISABLED' | 'QUARTER' | 'FULL';
@@ -183,19 +183,58 @@ export class PixelStreaming {
183
183
  this._webRtcController.setGamePadInputEnabled(isEnabled);
184
184
  });
185
185
 
186
- // encoder settings
186
+ // direct qp settings
187
187
  this.config._addOnNumericSettingChangedListener(NumericParameters.MinQP, (newValue: number) => {
188
188
  Logger.Info('-------- Sending MinQP --------');
189
189
  this._webRtcController.sendEncoderMinQP(newValue);
190
190
  Logger.Info('-------------------------------------------');
191
+ const quality = Math.trunc(100 * (1 - newValue / 51));
192
+ this.config.setNumericSetting(NumericParameters.CompatQualityMax, quality);
191
193
  });
192
194
 
193
195
  this.config._addOnNumericSettingChangedListener(NumericParameters.MaxQP, (newValue: number) => {
194
- Logger.Info('-------- Sending encoder settings --------');
196
+ Logger.Info('-------- Sending MaxQP --------');
195
197
  this._webRtcController.sendEncoderMaxQP(newValue);
196
198
  Logger.Info('-------------------------------------------');
199
+ const quality = Math.trunc(100 * (1 - newValue / 51));
200
+ this.config.setNumericSetting(NumericParameters.CompatQualityMin, quality);
197
201
  });
198
202
 
203
+ // direct quality factor settings
204
+ this.config._addOnNumericSettingChangedListener(NumericParameters.MinQuality, (newValue: number) => {
205
+ Logger.Info('-------- Sending MinQuality --------');
206
+ this._webRtcController.sendEncoderMinQuality(newValue);
207
+ Logger.Info('-------------------------------------------');
208
+ this.config.setNumericSetting(NumericParameters.CompatQualityMin, newValue);
209
+ });
210
+
211
+ this.config._addOnNumericSettingChangedListener(NumericParameters.MaxQuality, (newValue: number) => {
212
+ Logger.Info('-------- Sending MaxQuality --------');
213
+ this._webRtcController.sendEncoderMaxQuality(newValue);
214
+ Logger.Info('-------------------------------------------');
215
+ this.config.setNumericSetting(NumericParameters.CompatQualityMax, newValue);
216
+ });
217
+
218
+ // new quality value that gets scaled to qp for legacy reasons
219
+ this.config._addOnNumericSettingChangedListener(
220
+ NumericParameters.CompatQualityMin,
221
+ (newValue: number) => {
222
+ newValue = 51 - (newValue / 100) * 51;
223
+ Logger.Info('-------- Sending MinQP from quality value --------');
224
+ this._webRtcController.sendEncoderMaxQP(newValue);
225
+ Logger.Info('-------------------------------------------');
226
+ }
227
+ );
228
+
229
+ this.config._addOnNumericSettingChangedListener(
230
+ NumericParameters.CompatQualityMax,
231
+ (newValue: number) => {
232
+ newValue = 51 - (newValue / 100) * 51;
233
+ Logger.Info('-------- Sending MaxQP from quality value --------');
234
+ this._webRtcController.sendEncoderMinQP(newValue);
235
+ Logger.Info('-------------------------------------------');
236
+ }
237
+ );
199
238
  // WebRTC settings
200
239
  this.config._addOnNumericSettingChangedListener(
201
240
  NumericParameters.WebRTCMinBitrate,
@@ -531,20 +570,60 @@ export class PixelStreaming {
531
570
  const urlParams = new IURLSearchParams(window.location.search);
532
571
  Logger.Info(`using URL parameters ${useUrlParams}`);
533
572
  if (settings.EncoderSettings) {
534
- this.config.setNumericSetting(
535
- NumericParameters.MinQP,
536
- // If a setting is set in the URL, make sure we respect that value as opposed to what the application sends us
537
- useUrlParams && urlParams.has(NumericParameters.MinQP)
538
- ? Number.parseFloat(urlParams.get(NumericParameters.MinQP))
539
- : settings.EncoderSettings.MinQP
540
- );
573
+ // here we should either get Min/MaxQP from PS1
574
+ // or Min/MaxQuality from PS2
575
+ // we only want to set one set or the other as they converge in CompatQualityMin/Max and
576
+ // we dont want to have them conflict with default values.
577
+ if (settings.EncoderSettings.MinQP) {
578
+ this.config.setNumericSetting(
579
+ NumericParameters.MinQP,
580
+ // If a setting is set in the URL, make sure we respect that value as opposed to what the application sends us
581
+ useUrlParams && urlParams.has(NumericParameters.MinQP)
582
+ ? Number.parseFloat(urlParams.get(NumericParameters.MinQP))
583
+ : settings.EncoderSettings.MinQP || 0
584
+ );
541
585
 
542
- this.config.setNumericSetting(
543
- NumericParameters.MaxQP,
544
- useUrlParams && urlParams.has(NumericParameters.MaxQP)
545
- ? Number.parseFloat(urlParams.get(NumericParameters.MaxQP))
546
- : settings.EncoderSettings.MaxQP
547
- );
586
+ this.config.setNumericSetting(
587
+ NumericParameters.MaxQP,
588
+ useUrlParams && urlParams.has(NumericParameters.MaxQP)
589
+ ? Number.parseFloat(urlParams.get(NumericParameters.MaxQP))
590
+ : settings.EncoderSettings.MaxQP || 51
591
+ );
592
+ }
593
+
594
+ if (settings.EncoderSettings.MinQuality) {
595
+ this.config.setNumericSetting(
596
+ NumericParameters.MinQuality,
597
+ // If a setting is set in the URL, make sure we respect that value as opposed to what the application sends us
598
+ useUrlParams && urlParams.has(NumericParameters.MinQuality)
599
+ ? Number.parseFloat(urlParams.get(NumericParameters.MinQuality))
600
+ : settings.EncoderSettings.MinQuality || 0
601
+ );
602
+
603
+ this.config.setNumericSetting(
604
+ NumericParameters.MaxQuality,
605
+ useUrlParams && urlParams.has(NumericParameters.MaxQuality)
606
+ ? Number.parseFloat(urlParams.get(NumericParameters.MaxQuality))
607
+ : settings.EncoderSettings.MaxQuality || 100
608
+ );
609
+ }
610
+
611
+ // these two are just used to converge quality and qp and behave slightly differently since they
612
+ // shouldnt exist in EncoderSettings
613
+ if (useUrlParams) {
614
+ if (urlParams.has(NumericParameters.CompatQualityMin)) {
615
+ this.config.setNumericSetting(
616
+ NumericParameters.CompatQualityMin,
617
+ Number.parseFloat(urlParams.get(NumericParameters.CompatQualityMin))
618
+ );
619
+ }
620
+ if (urlParams.has(NumericParameters.CompatQualityMax)) {
621
+ this.config.setNumericSetting(
622
+ NumericParameters.CompatQualityMax,
623
+ Number.parseFloat(urlParams.get(NumericParameters.CompatQualityMax))
624
+ );
625
+ }
626
+ }
548
627
  }
549
628
  if (settings.WebRTCSettings) {
550
629
  this.config.setNumericSetting(
@@ -1487,6 +1487,44 @@ export class WebRtcPlayerController {
1487
1487
  }
1488
1488
  }
1489
1489
 
1490
+ /**
1491
+ * Send the MinQuality encoder setting to the UE Instance.
1492
+ * @param minQuality - The lower bound for quality when encoding
1493
+ * valid values are (0-100) where:
1494
+ * 0 = Worst quality.
1495
+ * 100 = Best quality.
1496
+ */
1497
+ sendEncoderMinQuality(minQuality: number) {
1498
+ Logger.Info(`MinQuality=${minQuality}\n`);
1499
+
1500
+ if (minQuality != null) {
1501
+ this.streamMessageController.toStreamerHandlers.get('Command')([
1502
+ JSON.stringify({
1503
+ 'Encoder.MinQuality': minQuality
1504
+ })
1505
+ ]);
1506
+ }
1507
+ }
1508
+
1509
+ /**
1510
+ * Send the MaxQuality encoder setting to the UE Instance.
1511
+ * @param maxQuality - The upper bound for quality when encoding
1512
+ * valid values are (0-100) where:
1513
+ * 0 = Worst quality.
1514
+ * 100 = Best quality.
1515
+ */
1516
+ sendEncoderMaxQuality(maxQuality: number) {
1517
+ Logger.Info(`MaxQuality=${maxQuality}\n`);
1518
+
1519
+ if (maxQuality != null) {
1520
+ this.streamMessageController.toStreamerHandlers.get('Command')([
1521
+ JSON.stringify({
1522
+ 'Encoder.MaxQuality': maxQuality
1523
+ })
1524
+ ]);
1525
+ }
1526
+ }
1527
+
1490
1528
  /**
1491
1529
  * Send the { WebRTC.MinBitrate: SomeNumber }} command to UE to set
1492
1530
  * the minimum bitrate that we allow WebRTC to use