@yang__yj/pixelstreaming-core 1.0.1 → 1.0.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/lib-pixelstreamingfrontend.esm.js +1 -1
- package/dist/lib-pixelstreamingfrontend.js +1 -1
- package/package.json +2 -1
- package/src/Inputs/TouchController.ts +11 -11
- package/src/WebRtcPlayer/WebRtcPlayerController.ts +252 -175
- package/types/Config/Config.d.ts +5 -4
- package/types/DataChannel/DataChannelLatencyTestController.d.ts +26 -0
- package/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -0
- package/types/Inputs/HoveringMouseEvents.d.ts +1 -1
- package/types/PeerConnectionController/PeerConnectionController.d.ts +1 -1
- package/types/PixelStreaming/PixelStreaming.d.ts +31 -6
- package/types/UeInstanceMessage/SendMessageController.d.ts +1 -1
- package/types/UeInstanceMessage/StreamMessageController.d.ts +3 -5
- package/types/Util/EventEmitter.d.ts +40 -3
- package/types/Util/RTCUtils.d.ts +8 -0
- package/types/VideoPlayer/StreamController.d.ts +3 -3
- package/types/VideoPlayer/VideoPlayer.d.ts +2 -0
- package/types/WebRtcPlayer/WebRtcPlayerController.d.ts +30 -27
- package/types/WebSockets/MessageReceive.d.ts +9 -9
- package/types/WebSockets/MessageSend.d.ts +13 -9
- package/types/WebSockets/SignallingProtocol.d.ts +3 -3
- package/types/WebSockets/WebSocketController.d.ts +16 -12
- package/types/pixelstreamingfrontend.d.ts +2 -1
- package/yang__yj-pixelstreaming-core-1.0.1.tgz +0 -0
- package/yang__yj-pixelstreaming-core-1.0.2.tgz +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
2
|
|
|
3
|
-
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
4
|
-
import { useRoute, useRouter } from "vue-router";
|
|
3
|
+
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
5
4
|
import { WebSocketController } from '../WebSockets/WebSocketController';
|
|
6
5
|
import { StreamController } from '../VideoPlayer/StreamController';
|
|
7
6
|
import {
|
|
@@ -66,7 +65,7 @@ import {
|
|
|
66
65
|
import {
|
|
67
66
|
DataChannelLatencyTestRequest,
|
|
68
67
|
DataChannelLatencyTestResponse
|
|
69
|
-
} from
|
|
68
|
+
} from '../DataChannel/DataChannelLatencyTestResults';
|
|
70
69
|
/**
|
|
71
70
|
* Entry point for the WebRTC Player
|
|
72
71
|
*/
|
|
@@ -138,7 +137,9 @@ export class WebRtcPlayerController {
|
|
|
138
137
|
this.onAfkTriggered.bind(this)
|
|
139
138
|
);
|
|
140
139
|
this.afkController.onAFKTimedOutCallback = () => {
|
|
141
|
-
this.closeSignalingServer(
|
|
140
|
+
this.closeSignalingServer(
|
|
141
|
+
'You have been disconnected due to inactivity'
|
|
142
|
+
);
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
this.freezeFrameController = new FreezeFrameController(
|
|
@@ -162,9 +163,9 @@ export class WebRtcPlayerController {
|
|
|
162
163
|
'Resolution.Height': height
|
|
163
164
|
};
|
|
164
165
|
|
|
165
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
167
|
+
JSON.stringify(descriptor)
|
|
168
|
+
]);
|
|
168
169
|
};
|
|
169
170
|
|
|
170
171
|
// Every time video player is resized in browser we need to reinitialize the mouse coordinate conversion and freeze frame sizing logic.
|
|
@@ -201,7 +202,9 @@ export class WebRtcPlayerController {
|
|
|
201
202
|
messageList: MessageReceive.MessageStreamerList
|
|
202
203
|
) => this.handleStreamerListMessage(messageList);
|
|
203
204
|
|
|
204
|
-
this.webSocketController.onPlayerCount = (
|
|
205
|
+
this.webSocketController.onPlayerCount = (
|
|
206
|
+
playerCount: MessageReceive.MessagePlayerCount
|
|
207
|
+
) => {
|
|
205
208
|
this.pixelStreaming._onPlayerCount(playerCount.count);
|
|
206
209
|
};
|
|
207
210
|
|
|
@@ -215,7 +218,9 @@ export class WebRtcPlayerController {
|
|
|
215
218
|
// 发送当前连接 所有像素流 TODO:无法判断是固定的什么项目的像素流
|
|
216
219
|
// this.webSocketController.requestStreamerList();
|
|
217
220
|
// this.webSocketController.requestStreamerObject(window.streamerName());
|
|
218
|
-
this.webSocketController.requestStreamerObject(
|
|
221
|
+
this.webSocketController.requestStreamerObject(
|
|
222
|
+
sessionStorage.getItem('streamerName')
|
|
223
|
+
);
|
|
219
224
|
|
|
220
225
|
// this.webSocketController.onStreamerList = (
|
|
221
226
|
// messageList: MessageReceive.MessageStreamerList
|
|
@@ -224,45 +229,59 @@ export class WebRtcPlayerController {
|
|
|
224
229
|
}
|
|
225
230
|
});
|
|
226
231
|
|
|
227
|
-
this.webSocketController.onClose.addEventListener(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
232
|
+
this.webSocketController.onClose.addEventListener(
|
|
233
|
+
'close',
|
|
234
|
+
(event: CustomEvent) => {
|
|
235
|
+
// when we refresh the page during a stream we get the going away code.
|
|
236
|
+
// in that case we don't want to reconnect since we're navigating away.
|
|
237
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
|
|
238
|
+
// lists all the codes.
|
|
239
|
+
const CODE_GOING_AWAY = 1001;
|
|
240
|
+
|
|
241
|
+
const willTryReconnect =
|
|
242
|
+
this.shouldReconnect &&
|
|
243
|
+
event.detail.code != CODE_GOING_AWAY &&
|
|
244
|
+
this.config.getNumericSettingValue(
|
|
245
|
+
NumericParameters.MaxReconnectAttempts
|
|
246
|
+
) > 0;
|
|
247
|
+
|
|
248
|
+
const disconnectMessage = this.disconnectMessage
|
|
249
|
+
? this.disconnectMessage
|
|
250
|
+
: event.detail.reason;
|
|
251
|
+
this.pixelStreaming._onDisconnect(
|
|
252
|
+
disconnectMessage,
|
|
253
|
+
!willTryReconnect && !this.isReconnecting
|
|
254
|
+
);
|
|
240
255
|
|
|
241
|
-
|
|
256
|
+
this.afkController.stopAfkWarningTimer();
|
|
242
257
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
258
|
+
// stop sending stats on interval if we have closed our connection
|
|
259
|
+
if (
|
|
260
|
+
this.statsTimerHandle &&
|
|
261
|
+
this.statsTimerHandle !== undefined
|
|
262
|
+
) {
|
|
263
|
+
window.clearInterval(this.statsTimerHandle);
|
|
264
|
+
}
|
|
247
265
|
|
|
248
|
-
|
|
249
|
-
|
|
266
|
+
// reset the stream quality icon.
|
|
267
|
+
this.setVideoEncoderAvgQP(0);
|
|
250
268
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
269
|
+
// unregister all input device event handlers on disconnect
|
|
270
|
+
this.setTouchInputEnabled(false);
|
|
271
|
+
this.setMouseInputEnabled(false);
|
|
272
|
+
this.setKeyboardInputEnabled(false);
|
|
273
|
+
this.setGamePadInputEnabled(false);
|
|
256
274
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
275
|
+
if (willTryReconnect) {
|
|
276
|
+
// need a small delay here to prevent reconnect spamming
|
|
277
|
+
setTimeout(() => {
|
|
278
|
+
this.isReconnecting = true;
|
|
279
|
+
this.reconnectAttempt++;
|
|
280
|
+
this.tryReconnect(event.detail.reason);
|
|
281
|
+
}, 2000);
|
|
282
|
+
}
|
|
264
283
|
}
|
|
265
|
-
|
|
284
|
+
);
|
|
266
285
|
|
|
267
286
|
// 在应用中设置webRtc播放器控制器的最后几个方法,以便激活连接
|
|
268
287
|
this.sendMessageController = new SendMessageController(
|
|
@@ -291,7 +310,7 @@ export class WebRtcPlayerController {
|
|
|
291
310
|
this.config._addOnOptionSettingChangedListener(
|
|
292
311
|
OptionParameters.StreamerId,
|
|
293
312
|
(streamerid) => {
|
|
294
|
-
if (streamerid ===
|
|
313
|
+
if (streamerid === '') {
|
|
295
314
|
return;
|
|
296
315
|
}
|
|
297
316
|
|
|
@@ -324,7 +343,7 @@ export class WebRtcPlayerController {
|
|
|
324
343
|
// }
|
|
325
344
|
|
|
326
345
|
return signallingServerUrl;
|
|
327
|
-
}
|
|
346
|
+
};
|
|
328
347
|
}
|
|
329
348
|
|
|
330
349
|
/**
|
|
@@ -349,9 +368,7 @@ export class WebRtcPlayerController {
|
|
|
349
368
|
|
|
350
369
|
//try {
|
|
351
370
|
const messageType =
|
|
352
|
-
this.streamMessageController.fromStreamerMessages.get(
|
|
353
|
-
message[0]
|
|
354
|
-
);
|
|
371
|
+
this.streamMessageController.fromStreamerMessages.get(message[0]);
|
|
355
372
|
this.streamMessageController.fromStreamerHandlers.get(messageType)(
|
|
356
373
|
event.data
|
|
357
374
|
);
|
|
@@ -406,8 +423,9 @@ export class WebRtcPlayerController {
|
|
|
406
423
|
this.streamMessageController.registerMessageHandler(
|
|
407
424
|
MessageDirection.FromStreamer,
|
|
408
425
|
'DataChannelLatencyTest',
|
|
409
|
-
(data: ArrayBuffer) =>
|
|
410
|
-
|
|
426
|
+
(data: ArrayBuffer) =>
|
|
427
|
+
this.handleDataChannelLatencyTestResponse(data)
|
|
428
|
+
);
|
|
411
429
|
this.streamMessageController.registerMessageHandler(
|
|
412
430
|
MessageDirection.FromStreamer,
|
|
413
431
|
'InitialSettings',
|
|
@@ -502,7 +520,8 @@ export class WebRtcPlayerController {
|
|
|
502
520
|
'LatencyTest',
|
|
503
521
|
(data: Array<number | string>) =>
|
|
504
522
|
this.sendMessageController.sendMessageToStreamer(
|
|
505
|
-
'LatencyTest',
|
|
523
|
+
'LatencyTest',
|
|
524
|
+
data
|
|
506
525
|
)
|
|
507
526
|
);
|
|
508
527
|
this.streamMessageController.registerMessageHandler(
|
|
@@ -525,7 +544,8 @@ export class WebRtcPlayerController {
|
|
|
525
544
|
'UIInteraction',
|
|
526
545
|
(data: Array<number | string>) =>
|
|
527
546
|
this.sendMessageController.sendMessageToStreamer(
|
|
528
|
-
'UIInteraction',
|
|
547
|
+
'UIInteraction',
|
|
548
|
+
data
|
|
529
549
|
)
|
|
530
550
|
);
|
|
531
551
|
this.streamMessageController.registerMessageHandler(
|
|
@@ -533,7 +553,8 @@ export class WebRtcPlayerController {
|
|
|
533
553
|
'Command',
|
|
534
554
|
(data: Array<number | string>) =>
|
|
535
555
|
this.sendMessageController.sendMessageToStreamer(
|
|
536
|
-
'Command',
|
|
556
|
+
'Command',
|
|
557
|
+
data
|
|
537
558
|
)
|
|
538
559
|
);
|
|
539
560
|
this.streamMessageController.registerMessageHandler(
|
|
@@ -541,7 +562,8 @@ export class WebRtcPlayerController {
|
|
|
541
562
|
'TextboxEntry',
|
|
542
563
|
(data: Array<number | string>) =>
|
|
543
564
|
this.sendMessageController.sendMessageToStreamer(
|
|
544
|
-
'TextboxEntry',
|
|
565
|
+
'TextboxEntry',
|
|
566
|
+
data
|
|
545
567
|
)
|
|
546
568
|
);
|
|
547
569
|
this.streamMessageController.registerMessageHandler(
|
|
@@ -814,9 +836,10 @@ export class WebRtcPlayerController {
|
|
|
814
836
|
delete protocolJSON.Direction;
|
|
815
837
|
Logger.Log(
|
|
816
838
|
Logger.GetStackTrace(),
|
|
817
|
-
`Received new ${
|
|
818
|
-
|
|
819
|
-
|
|
839
|
+
`Received new ${
|
|
840
|
+
direction == MessageDirection.FromStreamer
|
|
841
|
+
? 'FromStreamer'
|
|
842
|
+
: 'ToStreamer'
|
|
820
843
|
} protocol. Updating existing protocol...(更新现有协议)`
|
|
821
844
|
);
|
|
822
845
|
Object.keys(protocolJSON).forEach((messageType) => {
|
|
@@ -825,26 +848,27 @@ export class WebRtcPlayerController {
|
|
|
825
848
|
case MessageDirection.ToStreamer:
|
|
826
849
|
// Check that the message contains all the relevant params
|
|
827
850
|
if (
|
|
828
|
-
!Object.prototype.hasOwnProperty.call(
|
|
829
|
-
message,
|
|
830
|
-
'id'
|
|
831
|
-
)
|
|
851
|
+
!Object.prototype.hasOwnProperty.call(message, 'id')
|
|
832
852
|
) {
|
|
833
853
|
Logger.Error(
|
|
834
854
|
Logger.GetStackTrace(),
|
|
835
855
|
`ToStreamer->${messageType} protocol definition was malformed as it didn't contain at least an id\n
|
|
836
856
|
Definition was: ${JSON.stringify(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
857
|
+
message,
|
|
858
|
+
null,
|
|
859
|
+
2
|
|
860
|
+
)}`
|
|
841
861
|
);
|
|
842
862
|
// return in a forEach is equivalent to a continue in a normal for loop
|
|
843
863
|
return;
|
|
844
864
|
}
|
|
845
865
|
|
|
846
866
|
// UE5.1 and UE5.2 don't send a structure for these message types, but they actually do have a structure so ignore updating them
|
|
847
|
-
if (
|
|
867
|
+
if (
|
|
868
|
+
messageType === 'UIInteraction' ||
|
|
869
|
+
messageType === 'Command' ||
|
|
870
|
+
messageType === 'LatencyTest'
|
|
871
|
+
) {
|
|
848
872
|
return;
|
|
849
873
|
}
|
|
850
874
|
|
|
@@ -931,13 +955,17 @@ export class WebRtcPlayerController {
|
|
|
931
955
|
}
|
|
932
956
|
|
|
933
957
|
/**
|
|
934
|
-
*
|
|
935
|
-
* @param message
|
|
958
|
+
*
|
|
959
|
+
* @param message
|
|
936
960
|
*/
|
|
937
961
|
onGamepadResponse(message: ArrayBuffer) {
|
|
938
|
-
const responseString = new TextDecoder('utf-16').decode(
|
|
962
|
+
const responseString = new TextDecoder('utf-16').decode(
|
|
963
|
+
message.slice(1)
|
|
964
|
+
);
|
|
939
965
|
const responseJSON = JSON.parse(responseString);
|
|
940
|
-
this.gamePadController.onGamepadResponseReceived(
|
|
966
|
+
this.gamePadController.onGamepadResponseReceived(
|
|
967
|
+
responseJSON.controllerId
|
|
968
|
+
);
|
|
941
969
|
}
|
|
942
970
|
|
|
943
971
|
onAfkTriggered(): void {
|
|
@@ -976,7 +1004,10 @@ export class WebRtcPlayerController {
|
|
|
976
1004
|
|
|
977
1005
|
// 如果连接是打开的,首先关闭它。等待一段时间再试一次
|
|
978
1006
|
this.isReconnecting = true;
|
|
979
|
-
if (
|
|
1007
|
+
if (
|
|
1008
|
+
this.webSocketController.webSocket &&
|
|
1009
|
+
this.webSocketController.webSocket.readyState != WebSocket.CLOSED
|
|
1010
|
+
) {
|
|
980
1011
|
this.closeSignalingServer(`${message} Restarting stream...`);
|
|
981
1012
|
setTimeout(() => {
|
|
982
1013
|
this.tryReconnect(message);
|
|
@@ -1036,9 +1067,7 @@ export class WebRtcPlayerController {
|
|
|
1036
1067
|
6
|
|
1037
1068
|
);
|
|
1038
1069
|
setTimeout(() => {
|
|
1039
|
-
this.pixelStreaming.dispatchEvent(
|
|
1040
|
-
new HideFreezeFrameEvent()
|
|
1041
|
-
);
|
|
1070
|
+
this.pixelStreaming.dispatchEvent(new HideFreezeFrameEvent());
|
|
1042
1071
|
this.freezeFrameController.hideFreezeFrame();
|
|
1043
1072
|
}, this.freezeFrameController.freezeFrameDelay);
|
|
1044
1073
|
if (this.videoPlayer.getVideoElement()) {
|
|
@@ -1102,7 +1131,7 @@ export class WebRtcPlayerController {
|
|
|
1102
1131
|
this.pixelStreaming.dispatchEvent(new PlayStreamEvent());
|
|
1103
1132
|
|
|
1104
1133
|
if (this.streamController.audioElement.srcObject) {
|
|
1105
|
-
const startMuted = this.config.isFlagEnabled(Flags.StartVideoMuted)
|
|
1134
|
+
const startMuted = this.config.isFlagEnabled(Flags.StartVideoMuted);
|
|
1106
1135
|
this.streamController.audioElement.muted = startMuted;
|
|
1107
1136
|
|
|
1108
1137
|
if (startMuted) {
|
|
@@ -1194,7 +1223,9 @@ export class WebRtcPlayerController {
|
|
|
1194
1223
|
Logger.GetStackTrace(),
|
|
1195
1224
|
'No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead'
|
|
1196
1225
|
);
|
|
1197
|
-
this.closeSignalingServer(
|
|
1226
|
+
this.closeSignalingServer(
|
|
1227
|
+
'TURN cannot be forced, closing connection. Please use STUN instead.'
|
|
1228
|
+
);
|
|
1198
1229
|
return;
|
|
1199
1230
|
}
|
|
1200
1231
|
}
|
|
@@ -1240,8 +1271,13 @@ export class WebRtcPlayerController {
|
|
|
1240
1271
|
// Browsers emit "connected" when getting first connection and "completed" when finishing
|
|
1241
1272
|
// candidate checking. However, sometimes browsers can skip "connected" and only emit "completed".
|
|
1242
1273
|
// Therefore need to check both cases and emit onWebRtcConnected only once on the first hit.
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1274
|
+
if (
|
|
1275
|
+
!webRtcConnectedSent &&
|
|
1276
|
+
['connected', 'completed'].includes(
|
|
1277
|
+
this.peerConnectionController.peerConnection
|
|
1278
|
+
.iceConnectionState
|
|
1279
|
+
)
|
|
1280
|
+
) {
|
|
1245
1281
|
this.pixelStreaming._onWebRtcConnected();
|
|
1246
1282
|
webRtcConnectedSent = true;
|
|
1247
1283
|
}
|
|
@@ -1340,32 +1376,29 @@ export class WebRtcPlayerController {
|
|
|
1340
1376
|
6
|
|
1341
1377
|
);
|
|
1342
1378
|
|
|
1343
|
-
const streamerBusyList =
|
|
1379
|
+
const streamerBusyList =
|
|
1380
|
+
(
|
|
1381
|
+
messageStreamerList as unknown as {
|
|
1382
|
+
streamerBusyList?: Array<{ streamerId: string }>;
|
|
1383
|
+
}
|
|
1384
|
+
).streamerBusyList ?? [];
|
|
1385
|
+
|
|
1344
1386
|
|
|
1345
1387
|
if (streamerBusyList.length > 0) {
|
|
1346
1388
|
console.log(window.location.href, '======');
|
|
1347
|
-
if (window.location.href.indexOf('home')
|
|
1348
|
-
return
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
}
|
|
1358
|
-
)
|
|
1359
|
-
.then(() => {
|
|
1360
|
-
this.webSocketController.sendSubscribe(streamerBusyList[0].streamerId);
|
|
1361
|
-
})
|
|
1362
|
-
.catch(() => {
|
|
1363
|
-
|
|
1364
|
-
})
|
|
1389
|
+
if (window.location.href.indexOf('home') !== -1) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
const confirmed = window.confirm(
|
|
1393
|
+
'监测到当前窗口有人在使用,是否强制进入?'
|
|
1394
|
+
);
|
|
1395
|
+
if (confirmed) {
|
|
1396
|
+
this.webSocketController.sendSubscribe(
|
|
1397
|
+
streamerBusyList[0].streamerId
|
|
1398
|
+
);
|
|
1365
1399
|
}
|
|
1366
1400
|
}
|
|
1367
1401
|
|
|
1368
|
-
|
|
1369
1402
|
// 将streamer添加到UI中
|
|
1370
1403
|
const settingOptions = [...messageStreamerList.ids]; // 复制原始的messageStreamerList.ids
|
|
1371
1404
|
// settingOptions.unshift(''); // 在顶部添加一个空选项
|
|
@@ -1379,9 +1412,15 @@ export class WebRtcPlayerController {
|
|
|
1379
1412
|
let wantedStreamerId: string = null;
|
|
1380
1413
|
let autoSelectedStreamerId: string = null;
|
|
1381
1414
|
|
|
1382
|
-
const waitForStreamer = this.config.isFlagEnabled(
|
|
1383
|
-
|
|
1384
|
-
|
|
1415
|
+
const waitForStreamer = this.config.isFlagEnabled(
|
|
1416
|
+
Flags.WaitForStreamer
|
|
1417
|
+
);
|
|
1418
|
+
const reconnectLimit = this.config.getNumericSettingValue(
|
|
1419
|
+
NumericParameters.MaxReconnectAttempts
|
|
1420
|
+
);
|
|
1421
|
+
const reconnectDelay = this.config.getNumericSettingValue(
|
|
1422
|
+
NumericParameters.StreamerAutoJoinInterval
|
|
1423
|
+
);
|
|
1385
1424
|
|
|
1386
1425
|
// 首先,我们通过各种方式找出一个通缉的主播id
|
|
1387
1426
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -1394,10 +1433,16 @@ export class WebRtcPlayerController {
|
|
|
1394
1433
|
}
|
|
1395
1434
|
|
|
1396
1435
|
// 现在我们看看能不能选出来。
|
|
1397
|
-
if (
|
|
1436
|
+
if (
|
|
1437
|
+
wantedStreamerId &&
|
|
1438
|
+
messageStreamerList.ids.includes(wantedStreamerId)
|
|
1439
|
+
) {
|
|
1398
1440
|
// 如果想要的流在列表中。我们选择它
|
|
1399
1441
|
autoSelectedStreamerId = wantedStreamerId;
|
|
1400
|
-
} else if (
|
|
1442
|
+
} else if (
|
|
1443
|
+
(!wantedStreamerId || !waitForStreamer) &&
|
|
1444
|
+
messageStreamerList.ids.length == 1
|
|
1445
|
+
) {
|
|
1401
1446
|
// 否则,如果我们没有等待想要的streamer,而且只有一个streamer,请连接到它
|
|
1402
1447
|
autoSelectedStreamerId = messageStreamerList.ids[0];
|
|
1403
1448
|
}
|
|
@@ -1541,8 +1586,12 @@ export class WebRtcPlayerController {
|
|
|
1541
1586
|
|
|
1542
1587
|
/* */
|
|
1543
1588
|
this.setMouseInputEnabled(this.config.isFlagEnabled(Flags.MouseInput));
|
|
1544
|
-
this.setKeyboardInputEnabled(
|
|
1545
|
-
|
|
1589
|
+
this.setKeyboardInputEnabled(
|
|
1590
|
+
this.config.isFlagEnabled(Flags.KeyboardInput)
|
|
1591
|
+
);
|
|
1592
|
+
this.setGamePadInputEnabled(
|
|
1593
|
+
this.config.isFlagEnabled(Flags.GamepadInput)
|
|
1594
|
+
);
|
|
1546
1595
|
}
|
|
1547
1596
|
|
|
1548
1597
|
/**
|
|
@@ -1671,11 +1720,11 @@ export class WebRtcPlayerController {
|
|
|
1671
1720
|
sendLatencyTest() {
|
|
1672
1721
|
this.latencyStartTime = Date.now();
|
|
1673
1722
|
|
|
1674
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1723
|
+
this.streamMessageController.toStreamerHandlers.get('LatencyTest')([
|
|
1724
|
+
JSON.stringify({
|
|
1725
|
+
StartTime: this.latencyStartTime
|
|
1726
|
+
})
|
|
1727
|
+
]);
|
|
1679
1728
|
}
|
|
1680
1729
|
|
|
1681
1730
|
/**
|
|
@@ -1700,11 +1749,11 @@ export class WebRtcPlayerController {
|
|
|
1700
1749
|
Logger.Log(Logger.GetStackTrace(), `MinQP=${minQP}\n`, 6);
|
|
1701
1750
|
|
|
1702
1751
|
if (minQP != null) {
|
|
1703
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1752
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1753
|
+
JSON.stringify({
|
|
1754
|
+
'Encoder.MinQP': minQP
|
|
1755
|
+
})
|
|
1756
|
+
]);
|
|
1708
1757
|
}
|
|
1709
1758
|
}
|
|
1710
1759
|
|
|
@@ -1721,65 +1770,73 @@ export class WebRtcPlayerController {
|
|
|
1721
1770
|
Logger.Log(Logger.GetStackTrace(), `MaxQP=${maxQP}\n`, 6);
|
|
1722
1771
|
|
|
1723
1772
|
if (maxQP != null) {
|
|
1724
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1773
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1774
|
+
JSON.stringify({
|
|
1775
|
+
'Encoder.MaxQP': maxQP
|
|
1776
|
+
})
|
|
1777
|
+
]);
|
|
1729
1778
|
}
|
|
1730
1779
|
}
|
|
1731
1780
|
|
|
1732
1781
|
/**
|
|
1733
|
-
* Send the { WebRTC.MinBitrate: SomeNumber }} command to UE to set
|
|
1734
|
-
* the minimum bitrate that we allow WebRTC to use
|
|
1782
|
+
* Send the { WebRTC.MinBitrate: SomeNumber }} command to UE to set
|
|
1783
|
+
* the minimum bitrate that we allow WebRTC to use
|
|
1735
1784
|
* (note setting this too high in poor networks can be problematic).
|
|
1736
1785
|
* @param minBitrate - The minimum bitrate we would like WebRTC to not fall below.
|
|
1737
1786
|
*/
|
|
1738
1787
|
sendWebRTCMinBitrate(minBitrate: number) {
|
|
1739
|
-
Logger.Log(
|
|
1788
|
+
Logger.Log(
|
|
1789
|
+
Logger.GetStackTrace(),
|
|
1790
|
+
`WebRTC Min Bitrate=${minBitrate}`,
|
|
1791
|
+
6
|
|
1792
|
+
);
|
|
1740
1793
|
if (minBitrate != null) {
|
|
1741
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1794
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1795
|
+
JSON.stringify({
|
|
1796
|
+
'WebRTC.MinBitrate': minBitrate
|
|
1797
|
+
})
|
|
1798
|
+
]);
|
|
1746
1799
|
}
|
|
1747
1800
|
}
|
|
1748
1801
|
|
|
1749
1802
|
/**
|
|
1750
|
-
* Send the { WebRTC.MaxBitrate: SomeNumber }} command to UE to set
|
|
1751
|
-
* the minimum bitrate that we allow WebRTC to use
|
|
1803
|
+
* Send the { WebRTC.MaxBitrate: SomeNumber }} command to UE to set
|
|
1804
|
+
* the minimum bitrate that we allow WebRTC to use
|
|
1752
1805
|
* (note setting this too low could result in blocky video).
|
|
1753
1806
|
* @param minBitrate - The minimum bitrate we would like WebRTC to not fall below.
|
|
1754
1807
|
*/
|
|
1755
1808
|
sendWebRTCMaxBitrate(maxBitrate: number) {
|
|
1756
|
-
Logger.Log(
|
|
1809
|
+
Logger.Log(
|
|
1810
|
+
Logger.GetStackTrace(),
|
|
1811
|
+
`WebRTC Max Bitrate=${maxBitrate}`,
|
|
1812
|
+
6
|
|
1813
|
+
);
|
|
1757
1814
|
if (maxBitrate != null) {
|
|
1758
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1815
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1816
|
+
JSON.stringify({
|
|
1817
|
+
'WebRTC.MaxBitrate': maxBitrate
|
|
1818
|
+
})
|
|
1819
|
+
]);
|
|
1763
1820
|
}
|
|
1764
1821
|
}
|
|
1765
1822
|
|
|
1766
1823
|
/**
|
|
1767
1824
|
* Send the { WebRTC.Fps: SomeNumber }} UE 5.0+
|
|
1768
|
-
* and { WebRTC.MaxFps } UE 4.27 command to set
|
|
1769
|
-
* the maximum fps we would like WebRTC to stream at.
|
|
1825
|
+
* and { WebRTC.MaxFps } UE 4.27 command to set
|
|
1826
|
+
* the maximum fps we would like WebRTC to stream at.
|
|
1770
1827
|
* @param fps - The maximum stream fps.
|
|
1771
1828
|
*/
|
|
1772
1829
|
sendWebRTCFps(fps: number) {
|
|
1773
1830
|
Logger.Log(Logger.GetStackTrace(), `WebRTC FPS=${fps}`, 6);
|
|
1774
1831
|
if (fps != null) {
|
|
1775
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1776
|
-
'
|
|
1777
|
-
|
|
1832
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1833
|
+
JSON.stringify({ 'WebRTC.Fps': fps })
|
|
1834
|
+
]);
|
|
1778
1835
|
|
|
1779
1836
|
/* TODO: Remove when UE 4.27 unsupported. */
|
|
1780
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1781
|
-
'
|
|
1782
|
-
|
|
1837
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1838
|
+
JSON.stringify({ 'WebRTC.MaxFps': fps })
|
|
1839
|
+
]);
|
|
1783
1840
|
}
|
|
1784
1841
|
}
|
|
1785
1842
|
|
|
@@ -1793,9 +1850,9 @@ export class WebRtcPlayerController {
|
|
|
1793
1850
|
6
|
|
1794
1851
|
);
|
|
1795
1852
|
|
|
1796
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1797
|
-
'
|
|
1798
|
-
|
|
1853
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1854
|
+
JSON.stringify({ 'stat.fps': '' })
|
|
1855
|
+
]);
|
|
1799
1856
|
}
|
|
1800
1857
|
|
|
1801
1858
|
/**
|
|
@@ -1820,9 +1877,9 @@ export class WebRtcPlayerController {
|
|
|
1820
1877
|
6
|
|
1821
1878
|
);
|
|
1822
1879
|
|
|
1823
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1824
|
-
|
|
1825
|
-
|
|
1880
|
+
this.streamMessageController.toStreamerHandlers.get('UIInteraction')([
|
|
1881
|
+
JSON.stringify(descriptor)
|
|
1882
|
+
]);
|
|
1826
1883
|
}
|
|
1827
1884
|
|
|
1828
1885
|
/**
|
|
@@ -1835,9 +1892,9 @@ export class WebRtcPlayerController {
|
|
|
1835
1892
|
6
|
|
1836
1893
|
);
|
|
1837
1894
|
|
|
1838
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1839
|
-
|
|
1840
|
-
|
|
1895
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1896
|
+
JSON.stringify(descriptor)
|
|
1897
|
+
]);
|
|
1841
1898
|
}
|
|
1842
1899
|
|
|
1843
1900
|
/**
|
|
@@ -1850,11 +1907,11 @@ export class WebRtcPlayerController {
|
|
|
1850
1907
|
6
|
|
1851
1908
|
);
|
|
1852
1909
|
|
|
1853
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1910
|
+
this.streamMessageController.toStreamerHandlers.get('Command')([
|
|
1911
|
+
JSON.stringify({
|
|
1912
|
+
ConsoleCommand: command
|
|
1913
|
+
})
|
|
1914
|
+
]);
|
|
1858
1915
|
}
|
|
1859
1916
|
|
|
1860
1917
|
/**
|
|
@@ -1909,7 +1966,7 @@ export class WebRtcPlayerController {
|
|
|
1909
1966
|
latencyTestResults.endToEndLatency =
|
|
1910
1967
|
~~(latencyTestResults.frameDisplayDeltaTimeMs +
|
|
1911
1968
|
latencyTestResults.networkLatency,
|
|
1912
|
-
|
|
1969
|
+
+latencyTestResults.CaptureToSendMs);
|
|
1913
1970
|
}
|
|
1914
1971
|
this.pixelStreaming._onLatencyTestResult(latencyTestResults);
|
|
1915
1972
|
}
|
|
@@ -1927,8 +1984,11 @@ export class WebRtcPlayerController {
|
|
|
1927
1984
|
const responseAsString = new TextDecoder('utf-16').decode(
|
|
1928
1985
|
message.slice(1)
|
|
1929
1986
|
);
|
|
1930
|
-
const latencyTestResponse: DataChannelLatencyTestResponse =
|
|
1931
|
-
|
|
1987
|
+
const latencyTestResponse: DataChannelLatencyTestResponse =
|
|
1988
|
+
JSON.parse(responseAsString);
|
|
1989
|
+
this.pixelStreaming._onDataChannelLatencyTestResponse(
|
|
1990
|
+
latencyTestResponse
|
|
1991
|
+
);
|
|
1932
1992
|
}
|
|
1933
1993
|
|
|
1934
1994
|
/**
|
|
@@ -1961,7 +2021,10 @@ export class WebRtcPlayerController {
|
|
|
1961
2021
|
parsedInitialSettings.PixelStreaming;
|
|
1962
2022
|
}
|
|
1963
2023
|
|
|
1964
|
-
if (
|
|
2024
|
+
if (
|
|
2025
|
+
parsedInitialSettings.ConfigOptions &&
|
|
2026
|
+
parsedInitialSettings.ConfigOptions.DefaultToHover !== undefined
|
|
2027
|
+
) {
|
|
1965
2028
|
this.config.setFlagEnabled(
|
|
1966
2029
|
Flags.HoveringMouseMode,
|
|
1967
2030
|
!!parsedInitialSettings.ConfigOptions.DefaultToHover
|
|
@@ -2098,11 +2161,17 @@ export class WebRtcPlayerController {
|
|
|
2098
2161
|
if (isEnabled) {
|
|
2099
2162
|
this.gamePadController = this.inputClassesFactory.registerGamePad();
|
|
2100
2163
|
this.gamePadController.onGamepadConnected = () => {
|
|
2101
|
-
this.streamMessageController.toStreamerHandlers.get(
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2164
|
+
this.streamMessageController.toStreamerHandlers.get(
|
|
2165
|
+
'GamepadConnected'
|
|
2166
|
+
)();
|
|
2167
|
+
};
|
|
2168
|
+
this.gamePadController.onGamepadDisconnected = (
|
|
2169
|
+
controllerIdx: number
|
|
2170
|
+
) => {
|
|
2171
|
+
this.streamMessageController.toStreamerHandlers.get(
|
|
2172
|
+
'GamepadDisconnected'
|
|
2173
|
+
)([controllerIdx]);
|
|
2174
|
+
};
|
|
2106
2175
|
}
|
|
2107
2176
|
}
|
|
2108
2177
|
|
|
@@ -2121,24 +2190,32 @@ export class WebRtcPlayerController {
|
|
|
2121
2190
|
);
|
|
2122
2191
|
}
|
|
2123
2192
|
|
|
2124
|
-
public registerMessageHandler(
|
|
2125
|
-
|
|
2193
|
+
public registerMessageHandler(
|
|
2194
|
+
name: string,
|
|
2195
|
+
direction: MessageDirection,
|
|
2196
|
+
handler?: (data: ArrayBuffer | Array<number | string>) => void
|
|
2197
|
+
) {
|
|
2198
|
+
if (
|
|
2199
|
+
direction === MessageDirection.FromStreamer &&
|
|
2200
|
+
typeof handler === 'undefined'
|
|
2201
|
+
) {
|
|
2126
2202
|
Logger.Warning(
|
|
2127
2203
|
Logger.GetStackTrace(),
|
|
2128
2204
|
`Unable to register handler for ${name} as no handler was passed`
|
|
2129
2205
|
);
|
|
2130
2206
|
}
|
|
2131
2207
|
|
|
2132
|
-
|
|
2133
2208
|
this.streamMessageController.registerMessageHandler(
|
|
2134
2209
|
direction,
|
|
2135
2210
|
name,
|
|
2136
|
-
(data: Array<number | string>) =>
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2211
|
+
(data: Array<number | string>) =>
|
|
2212
|
+
typeof handler === 'undefined' &&
|
|
2213
|
+
direction === MessageDirection.ToStreamer
|
|
2214
|
+
? this.sendMessageController.sendMessageToStreamer(
|
|
2215
|
+
name,
|
|
2216
|
+
data
|
|
2217
|
+
)
|
|
2218
|
+
: handler(data)
|
|
2142
2219
|
);
|
|
2143
2220
|
}
|
|
2144
2221
|
}
|