@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.4.0 → 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.
- package/dist/commonjs/Config/Config.js +16 -0
- package/dist/commonjs/Config/Config.js.map +1 -1
- package/dist/commonjs/DataChannel/InitialSettings.js.map +1 -1
- package/dist/commonjs/PixelStreaming/PixelStreaming.js +66 -10
- package/dist/commonjs/PixelStreaming/PixelStreaming.js.map +1 -1
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +34 -0
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js.map +1 -1
- package/dist/esm/Config/Config.js +16 -0
- package/dist/esm/Config/Config.js.map +1 -1
- package/dist/esm/DataChannel/InitialSettings.js.map +1 -1
- package/dist/esm/PixelStreaming/PixelStreaming.js +66 -10
- package/dist/esm/PixelStreaming/PixelStreaming.js.map +1 -1
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +34 -0
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js.map +1 -1
- package/dist/types/Config/Config.d.ts +4 -0
- package/dist/types/DataChannel/InitialSettings.d.ts +2 -0
- package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +16 -0
- package/package.json +2 -2
- package/readme.md +4 -3
- package/src/Config/Config.ts +64 -0
- package/src/DataChannel/InitialSettings.ts +2 -0
- package/src/PixelStreaming/PixelStreaming.ts +94 -15
- package/src/WebRtcPlayer/WebRtcPlayerController.ts +38 -0
package/readme.md
CHANGED
|
@@ -6,12 +6,13 @@ See [lib-pixelstreamingfrontend-ui](/Frontend/implementations/typescript) for an
|
|
|
6
6
|
|
|
7
7
|
### Key features
|
|
8
8
|
- Create a websocket connection to communicate with the signalling server.
|
|
9
|
-
- Create a WebRTC
|
|
9
|
+
- Create a WebRTC peer connection that displays the Unreal Engine video and audio.
|
|
10
10
|
- Handling of input from the user and transmitting it back to Unreal Engine.
|
|
11
11
|
- Opens a data channel connection sending and receiving custom data (in addition to input).
|
|
12
|
+
- Programmable and url specified settings.
|
|
12
13
|
|
|
13
14
|
### Adding it to your project
|
|
14
|
-
`npm
|
|
15
|
+
`npm install @epicgames-ps/lib-pixelstreamingfrontend-ue5.5`
|
|
15
16
|
|
|
16
17
|
### How this library is built
|
|
17
18
|
The NPM packages supports:
|
|
@@ -20,4 +21,4 @@ The NPM packages supports:
|
|
|
20
21
|
- Type definitions
|
|
21
22
|
- Source maps
|
|
22
23
|
|
|
23
|
-
**Note:** The NPM package does not contain a minified/bundled output, this is up to the user to do this in their application.
|
|
24
|
+
**Note:** The NPM package does not contain a minified/bundled output, this is up to the user to do this in their application.
|
package/src/Config/Config.ts
CHANGED
|
@@ -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(
|
|
@@ -183,19 +183,58 @@ export class PixelStreaming {
|
|
|
183
183
|
this._webRtcController.setGamePadInputEnabled(isEnabled);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
//
|
|
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
|
|
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
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|