@yang__yj/pixelstreaming-core 1.0.0 → 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/.cspell.json +48 -0
- package/.eslintignore +8 -0
- package/.eslintrc.js +8 -0
- package/.prettierignore +0 -0
- package/.prettierrc.json +6 -0
- package/coverage/clover.xml +3480 -0
- package/coverage/coverage-final.json +62 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +356 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/AFK/AFKController.ts.html +559 -0
- package/coverage/lcov-report/src/AFK/index.html +116 -0
- package/coverage/lcov-report/src/Config/Config.ts.html +2764 -0
- package/coverage/lcov-report/src/Config/SettingBase.ts.html +280 -0
- package/coverage/lcov-report/src/Config/SettingFlag.ts.html +382 -0
- package/coverage/lcov-report/src/Config/SettingNumber.ts.html +418 -0
- package/coverage/lcov-report/src/Config/SettingOption.ts.html +424 -0
- package/coverage/lcov-report/src/Config/SettingText.ts.html +331 -0
- package/coverage/lcov-report/src/Config/index.html +191 -0
- package/coverage/lcov-report/src/DataChannel/DataChannelController.ts.html +499 -0
- package/coverage/lcov-report/src/DataChannel/DataChannelSender.ts.html +262 -0
- package/coverage/lcov-report/src/DataChannel/InitialSettings.ts.html +268 -0
- package/coverage/lcov-report/src/DataChannel/LatencyTestResults.ts.html +313 -0
- package/coverage/lcov-report/src/DataChannel/index.html +161 -0
- package/coverage/lcov-report/src/FreezeFrame/FreezeFrame.ts.html +427 -0
- package/coverage/lcov-report/src/FreezeFrame/FreezeFrameController.ts.html +427 -0
- package/coverage/lcov-report/src/FreezeFrame/index.html +131 -0
- package/coverage/lcov-report/src/Inputs/FakeTouchController.ts.html +682 -0
- package/coverage/lcov-report/src/Inputs/GamepadController.ts.html +985 -0
- package/coverage/lcov-report/src/Inputs/HoveringMouseEvents.ts.html +688 -0
- package/coverage/lcov-report/src/Inputs/InputClassesFactory.ts.html +505 -0
- package/coverage/lcov-report/src/Inputs/KeyboardController.ts.html +1048 -0
- package/coverage/lcov-report/src/Inputs/LockedMouseEvents.ts.html +946 -0
- package/coverage/lcov-report/src/Inputs/MouseButtons.ts.html +160 -0
- package/coverage/lcov-report/src/Inputs/MouseController.ts.html +1171 -0
- package/coverage/lcov-report/src/Inputs/SpecialKeyCodes.ts.html +133 -0
- package/coverage/lcov-report/src/Inputs/TouchController.ts.html +712 -0
- package/coverage/lcov-report/src/Inputs/XRGamepadController.ts.html +463 -0
- package/coverage/lcov-report/src/Inputs/index.html +266 -0
- package/coverage/lcov-report/src/Logger/Logger.ts.html +325 -0
- package/coverage/lcov-report/src/Logger/index.html +116 -0
- package/coverage/lcov-report/src/PeerConnectionController/AggregatedStats.ts.html +1018 -0
- package/coverage/lcov-report/src/PeerConnectionController/CandidatePairStats.ts.html +136 -0
- package/coverage/lcov-report/src/PeerConnectionController/CandidateStat.ts.html +124 -0
- package/coverage/lcov-report/src/PeerConnectionController/DataChannelStats.ts.html +136 -0
- package/coverage/lcov-report/src/PeerConnectionController/InboundRTPStats.ts.html +547 -0
- package/coverage/lcov-report/src/PeerConnectionController/OutBoundRTPStats.ts.html +163 -0
- package/coverage/lcov-report/src/PeerConnectionController/PeerConnectionController.ts.html +1795 -0
- package/coverage/lcov-report/src/PeerConnectionController/SessionStats.ts.html +115 -0
- package/coverage/lcov-report/src/PeerConnectionController/StreamStats.ts.html +118 -0
- package/coverage/lcov-report/src/PeerConnectionController/index.html +236 -0
- package/coverage/lcov-report/src/PixelStreaming/PixelStreaming.ts.html +2269 -0
- package/coverage/lcov-report/src/PixelStreaming/index.html +116 -0
- package/coverage/lcov-report/src/UI/OnScreenKeyboard.ts.html +376 -0
- package/coverage/lcov-report/src/UI/index.html +116 -0
- package/coverage/lcov-report/src/UeInstanceMessage/ResponseController.ts.html +226 -0
- package/coverage/lcov-report/src/UeInstanceMessage/SendDescriptorController.ts.html +346 -0
- package/coverage/lcov-report/src/UeInstanceMessage/SendMessageController.ts.html +364 -0
- package/coverage/lcov-report/src/UeInstanceMessage/StreamMessageController.ts.html +862 -0
- package/coverage/lcov-report/src/UeInstanceMessage/ToStreamerMessagesController.ts.html +271 -0
- package/coverage/lcov-report/src/UeInstanceMessage/TwoWayMap.ts.html +241 -0
- package/coverage/lcov-report/src/UeInstanceMessage/index.html +191 -0
- package/coverage/lcov-report/src/Util/CoordinateConverter.ts.html +952 -0
- package/coverage/lcov-report/src/Util/EventEmitter.ts.html +1705 -0
- package/coverage/lcov-report/src/Util/EventListenerTracker.ts.html +172 -0
- package/coverage/lcov-report/src/Util/FileUtil.ts.html +505 -0
- package/coverage/lcov-report/src/Util/WebGLUtils.ts.html +232 -0
- package/coverage/lcov-report/src/Util/WebXRUtils.ts.html +160 -0
- package/coverage/lcov-report/src/Util/index.html +191 -0
- package/coverage/lcov-report/src/VideoPlayer/StreamController.ts.html +349 -0
- package/coverage/lcov-report/src/VideoPlayer/VideoPlayer.ts.html +799 -0
- package/coverage/lcov-report/src/VideoPlayer/index.html +131 -0
- package/coverage/lcov-report/src/WebRtcPlayer/WebRtcPlayerController.ts.html +6199 -0
- package/coverage/lcov-report/src/WebRtcPlayer/index.html +116 -0
- package/coverage/lcov-report/src/WebSockets/MessageReceive.ts.html +352 -0
- package/coverage/lcov-report/src/WebSockets/MessageSend.ts.html +604 -0
- package/coverage/lcov-report/src/WebSockets/SignallingProtocol.ts.html +622 -0
- package/coverage/lcov-report/src/WebSockets/WebSocketController.ts.html +844 -0
- package/coverage/lcov-report/src/WebSockets/index.html +161 -0
- package/coverage/lcov-report/src/WebXR/WebXRController.ts.html +1042 -0
- package/coverage/lcov-report/src/WebXR/index.html +116 -0
- package/coverage/lcov-report/src/__test__/index.html +161 -0
- package/coverage/lcov-report/src/__test__/mockMediaStream.ts.html +457 -0
- package/coverage/lcov-report/src/__test__/mockRTCPeerConnection.ts.html +1126 -0
- package/coverage/lcov-report/src/__test__/mockRTCRtpReceiver.ts.html +151 -0
- package/coverage/lcov-report/src/__test__/mockWebSocket.ts.html +475 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/pixelstreamingfrontend.ts.html +232 -0
- package/coverage/lcov.info +6458 -0
- package/dist/lib-pixelstreamingfrontend.esm.js +1 -0
- package/dist/lib-pixelstreamingfrontend.js +1 -0
- package/jest.config.js +18 -0
- package/package.json +47 -18
- package/readme.md +15 -0
- package/src/AFK/AFKController.test.ts +162 -0
- package/src/AFK/AFKController.ts +158 -0
- package/src/Config/Config.test.ts +222 -0
- package/src/Config/Config.ts +909 -0
- package/src/Config/SettingBase.ts +65 -0
- package/src/Config/SettingFlag.ts +99 -0
- package/src/Config/SettingNumber.ts +111 -0
- package/src/Config/SettingOption.ts +124 -0
- package/src/Config/SettingText.ts +82 -0
- package/src/DataChannel/DataChannelController.ts +138 -0
- package/src/DataChannel/DataChannelLatencyTestController.ts +129 -0
- package/src/DataChannel/DataChannelLatencyTestResults.ts +67 -0
- package/src/DataChannel/DataChannelSender.ts +59 -0
- package/src/DataChannel/InitialSettings.ts +61 -0
- package/src/DataChannel/LatencyTestResults.ts +76 -0
- package/src/FreezeFrame/FreezeFrame.ts +114 -0
- package/src/FreezeFrame/FreezeFrameController.ts +114 -0
- package/src/Inputs/FakeTouchController.ts +199 -0
- package/src/Inputs/GamepadController.ts +300 -0
- package/src/Inputs/GamepadTypes.ts +10 -0
- package/src/Inputs/HoveringMouseEvents.ts +192 -0
- package/src/Inputs/IMouseEvents.ts +64 -0
- package/src/Inputs/ITouchController.ts +29 -0
- package/src/Inputs/InputClassesFactory.ts +140 -0
- package/src/Inputs/KeyboardController.ts +318 -0
- package/src/Inputs/LockedMouseEvents.ts +287 -0
- package/src/Inputs/MouseButtons.ts +25 -0
- package/src/Inputs/MouseController.ts +362 -0
- package/src/Inputs/SpecialKeyCodes.ts +16 -0
- package/src/Inputs/TouchController.ts +253 -0
- package/src/Inputs/XRGamepadController.ts +126 -0
- package/src/Logger/Logger.ts +80 -0
- package/src/PeerConnectionController/AggregatedStats.ts +311 -0
- package/src/PeerConnectionController/CandidatePairStats.ts +17 -0
- package/src/PeerConnectionController/CandidateStat.ts +13 -0
- package/src/PeerConnectionController/CodecStats.ts +19 -0
- package/src/PeerConnectionController/DataChannelStats.ts +17 -0
- package/src/PeerConnectionController/InboundRTPStats.ts +154 -0
- package/src/PeerConnectionController/InboundTrackStats.ts +34 -0
- package/src/PeerConnectionController/OutBoundRTPStats.ts +26 -0
- package/src/PeerConnectionController/PeerConnectionController.ts +563 -0
- package/src/PeerConnectionController/SessionStats.ts +10 -0
- package/src/PeerConnectionController/StreamStats.ts +11 -0
- package/src/PixelStreaming/PixelStreaming.test.ts +624 -0
- package/src/PixelStreaming/PixelStreaming.ts +847 -0
- package/src/UI/OnScreenKeyboard.ts +97 -0
- package/src/UeInstanceMessage/ResponseController.ts +47 -0
- package/src/UeInstanceMessage/SendMessageController.ts +154 -0
- package/src/UeInstanceMessage/StreamMessageController.ts +233 -0
- package/src/UeInstanceMessage/ToStreamerMessagesController.ts +62 -0
- package/src/Util/CoordinateConverter.ts +289 -0
- package/src/Util/EventEmitter.ts +595 -0
- package/src/Util/EventListenerTracker.ts +29 -0
- package/src/Util/FileUtil.ts +140 -0
- package/src/Util/RTCUtils.ts +41 -0
- package/src/Util/WebGLUtils.ts +49 -0
- package/src/Util/WebXRUtils.ts +25 -0
- package/src/VideoPlayer/StreamController.ts +89 -0
- package/src/VideoPlayer/VideoPlayer.ts +246 -0
- package/src/WebRtcPlayer/WebRtcPlayerController.ts +2221 -0
- package/src/WebSockets/MessageReceive.ts +89 -0
- package/src/WebSockets/MessageSend.ts +185 -0
- package/src/WebSockets/SignallingProtocol.ts +180 -0
- package/src/WebSockets/WebSocketController.ts +267 -0
- package/src/WebXR/WebXRController.ts +319 -0
- package/src/__test__/mockMediaStream.ts +124 -0
- package/src/__test__/mockRTCPeerConnection.ts +347 -0
- package/src/__test__/mockRTCRtpReceiver.ts +22 -0
- package/src/__test__/mockWebSocket.ts +130 -0
- package/src/pixelstreamingfrontend.ts +50 -0
- package/tsconfig.jest.json +8 -0
- package/tsconfig.json +24 -0
- package/{library/types → types}/Config/Config.d.ts +5 -4
- package/types/DataChannel/DataChannelLatencyTestController.d.ts +26 -0
- package/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -0
- package/{library/types → types}/Inputs/HoveringMouseEvents.d.ts +1 -1
- package/{library/types → types}/PeerConnectionController/PeerConnectionController.d.ts +1 -1
- package/{library/types → types}/PixelStreaming/PixelStreaming.d.ts +31 -6
- package/{library/types → types}/UeInstanceMessage/SendMessageController.d.ts +1 -1
- package/{library/types → types}/UeInstanceMessage/StreamMessageController.d.ts +3 -5
- package/{library/types → types}/Util/EventEmitter.d.ts +40 -3
- package/types/Util/RTCUtils.d.ts +8 -0
- package/{library/types → types}/VideoPlayer/StreamController.d.ts +3 -3
- package/{library/types → types}/VideoPlayer/VideoPlayer.d.ts +2 -0
- package/{library/types → types}/WebRtcPlayer/WebRtcPlayerController.d.ts +30 -27
- package/{library/types → types}/WebSockets/MessageReceive.d.ts +9 -9
- package/{library/types → types}/WebSockets/MessageSend.d.ts +13 -9
- package/{library/types → types}/WebSockets/SignallingProtocol.d.ts +3 -3
- package/{library/types → types}/WebSockets/WebSocketController.d.ts +16 -12
- package/{library/types → types}/pixelstreamingfrontend.d.ts +2 -1
- package/webpack.common.js +35 -0
- package/webpack.dev.js +35 -0
- package/webpack.prod.js +36 -0
- package/yang__yj-pixelstreaming-core-1.0.1.tgz +0 -0
- package/yang__yj-pixelstreaming-core-1.0.2.tgz +0 -0
- package/library/dist/lib-pixelstreamingfrontend.esm.js +0 -1
- package/library/dist/lib-pixelstreamingfrontend.js +0 -1
- /package/{library/types → types}/AFK/AFKController.d.ts +0 -0
- /package/{library/types → types}/Config/SettingBase.d.ts +0 -0
- /package/{library/types → types}/Config/SettingFlag.d.ts +0 -0
- /package/{library/types → types}/Config/SettingNumber.d.ts +0 -0
- /package/{library/types → types}/Config/SettingOption.d.ts +0 -0
- /package/{library/types → types}/Config/SettingText.d.ts +0 -0
- /package/{library/types → types}/DataChannel/DataChannelController.d.ts +0 -0
- /package/{library/types → types}/DataChannel/DataChannelSender.d.ts +0 -0
- /package/{library/types → types}/DataChannel/InitialSettings.d.ts +0 -0
- /package/{library/types → types}/DataChannel/LatencyTestResults.d.ts +0 -0
- /package/{library/types → types}/FreezeFrame/FreezeFrame.d.ts +0 -0
- /package/{library/types → types}/FreezeFrame/FreezeFrameController.d.ts +0 -0
- /package/{library/types → types}/Inputs/FakeTouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/GamepadController.d.ts +0 -0
- /package/{library/types → types}/Inputs/GamepadTypes.d.ts +0 -0
- /package/{library/types → types}/Inputs/IMouseEvents.d.ts +0 -0
- /package/{library/types → types}/Inputs/ITouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/InputClassesFactory.d.ts +0 -0
- /package/{library/types → types}/Inputs/KeyboardController.d.ts +0 -0
- /package/{library/types → types}/Inputs/LockedMouseEvents.d.ts +0 -0
- /package/{library/types → types}/Inputs/MouseButtons.d.ts +0 -0
- /package/{library/types → types}/Inputs/MouseController.d.ts +0 -0
- /package/{library/types → types}/Inputs/SpecialKeyCodes.d.ts +0 -0
- /package/{library/types → types}/Inputs/TouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/XRGamepadController.d.ts +0 -0
- /package/{library/types → types}/Logger/Logger.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/AggregatedStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CandidatePairStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CandidateStat.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CodecStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/DataChannelStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/InboundRTPStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/InboundTrackStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/OutBoundRTPStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/SessionStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/StreamStats.d.ts +0 -0
- /package/{library/types → types}/UI/OnScreenKeyboard.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/ResponseController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/SendDescriptorController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/ToStreamerMessagesController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/TwoWayMap.d.ts +0 -0
- /package/{library/types → types}/Util/CoordinateConverter.d.ts +0 -0
- /package/{library/types → types}/Util/EventListenerTracker.d.ts +0 -0
- /package/{library/types → types}/Util/FileUtil.d.ts +0 -0
- /package/{library/types → types}/Util/WebGLUtils.d.ts +0 -0
- /package/{library/types → types}/Util/WebXRUtils.d.ts +0 -0
- /package/{library/types → types}/WebXR/WebXRController.d.ts +0 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
import { Logger } from '../Logger/Logger';
|
|
4
|
+
import { VideoPlayer } from '../VideoPlayer/VideoPlayer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts coordinates from element relative coordinates to values normalized within the value range of a short (and back again)
|
|
8
|
+
*/
|
|
9
|
+
export class CoordinateConverter {
|
|
10
|
+
videoElementProvider: VideoPlayer;
|
|
11
|
+
videoElementParent: HTMLElement;
|
|
12
|
+
videoElement: HTMLVideoElement;
|
|
13
|
+
ratio: number;
|
|
14
|
+
|
|
15
|
+
normalizeAndQuantizeUnsignedFunc: (
|
|
16
|
+
x: number,
|
|
17
|
+
y: number
|
|
18
|
+
) => NormalizedQuantizedUnsignedCoord;
|
|
19
|
+
normalizeAndQuantizeSignedFunc: (
|
|
20
|
+
x: number,
|
|
21
|
+
y: number
|
|
22
|
+
) => NormalizedQuantizedSignedCoord;
|
|
23
|
+
denormalizeAndUnquantizeUnsignedFunc: (
|
|
24
|
+
x: number,
|
|
25
|
+
y: number
|
|
26
|
+
) => UnquantizedDenormalizedUnsignedCoord;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param videoElementProvider - the div element that the video player will be injected into
|
|
30
|
+
*/
|
|
31
|
+
constructor(videoElementProvider: VideoPlayer) {
|
|
32
|
+
this.videoElementProvider = videoElementProvider;
|
|
33
|
+
this.normalizeAndQuantizeUnsignedFunc = () => {
|
|
34
|
+
throw new Error(
|
|
35
|
+
'Normalize and quantize unsigned, method not implemented.'
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
this.normalizeAndQuantizeSignedFunc = () => {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'Normalize and unquantize signed, method not implemented.'
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
this.denormalizeAndUnquantizeUnsignedFunc = () => {
|
|
44
|
+
throw new Error(
|
|
45
|
+
'Denormalize and unquantize unsigned, method not implemented.'
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The surface method for setterNormalizeAndQuantizeUnsigned
|
|
52
|
+
* @param x - x axis point
|
|
53
|
+
* @param y - y axis point
|
|
54
|
+
*/
|
|
55
|
+
normalizeAndQuantizeUnsigned(
|
|
56
|
+
x: number,
|
|
57
|
+
y: number
|
|
58
|
+
): NormalizedQuantizedUnsignedCoord {
|
|
59
|
+
return this.normalizeAndQuantizeUnsignedFunc(x, y);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The surface method for setterUnquantizeAndDenormalizeUnsigned
|
|
64
|
+
* @param x - x axis point
|
|
65
|
+
* @param y - y axis point
|
|
66
|
+
*/
|
|
67
|
+
unquantizeAndDenormalizeUnsigned(
|
|
68
|
+
x: number,
|
|
69
|
+
y: number
|
|
70
|
+
): UnquantizedDenormalizedUnsignedCoord {
|
|
71
|
+
return this.denormalizeAndUnquantizeUnsignedFunc(x, y);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The surface method for setterNormalizeAndQuantizeSigned
|
|
76
|
+
* @param x - x axis point
|
|
77
|
+
* @param y - y axis point
|
|
78
|
+
*/
|
|
79
|
+
normalizeAndQuantizeSigned(
|
|
80
|
+
x: number,
|
|
81
|
+
y: number
|
|
82
|
+
): NormalizedQuantizedSignedCoord {
|
|
83
|
+
return this.normalizeAndQuantizeSignedFunc(x, y);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* set up the Normalize And Quantize methods based on the aspect ratio and the video player ratio
|
|
88
|
+
*/
|
|
89
|
+
setupNormalizeAndQuantize() {
|
|
90
|
+
this.videoElementParent =
|
|
91
|
+
this.videoElementProvider.getVideoParentElement();
|
|
92
|
+
this.videoElement = this.videoElementProvider.getVideoElement();
|
|
93
|
+
|
|
94
|
+
if (this.videoElementParent && this.videoElement) {
|
|
95
|
+
const playerAspectRatio =
|
|
96
|
+
this.videoElementParent.clientHeight /
|
|
97
|
+
this.videoElementParent.clientWidth;
|
|
98
|
+
const videoAspectRatio =
|
|
99
|
+
this.videoElement.videoHeight / this.videoElement.videoWidth;
|
|
100
|
+
if (playerAspectRatio > videoAspectRatio) {
|
|
101
|
+
Logger.Log(
|
|
102
|
+
Logger.GetStackTrace(),
|
|
103
|
+
'Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio',
|
|
104
|
+
6
|
|
105
|
+
);
|
|
106
|
+
this.ratio = playerAspectRatio / videoAspectRatio;
|
|
107
|
+
this.normalizeAndQuantizeUnsignedFunc = (
|
|
108
|
+
x: number,
|
|
109
|
+
y: number
|
|
110
|
+
) => this.normalizeAndQuantizeUnsignedPlayerBigger(x, y);
|
|
111
|
+
this.normalizeAndQuantizeSignedFunc = (x: number, y: number) =>
|
|
112
|
+
this.normalizeAndQuantizeSignedPlayerBigger(x, y);
|
|
113
|
+
this.denormalizeAndUnquantizeUnsignedFunc = (
|
|
114
|
+
x: number,
|
|
115
|
+
y: number
|
|
116
|
+
) => this.denormalizeAndUnquantizeUnsignedPlayerBigger(x, y);
|
|
117
|
+
} else {
|
|
118
|
+
Logger.Log(
|
|
119
|
+
Logger.GetStackTrace(),
|
|
120
|
+
'Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio',
|
|
121
|
+
6
|
|
122
|
+
);
|
|
123
|
+
this.ratio = videoAspectRatio / playerAspectRatio;
|
|
124
|
+
this.normalizeAndQuantizeUnsignedFunc = (
|
|
125
|
+
x: number,
|
|
126
|
+
y: number
|
|
127
|
+
) => this.normalizeAndQuantizeUnsignedPlayerSmaller(x, y);
|
|
128
|
+
this.normalizeAndQuantizeSignedFunc = (x: number, y: number) =>
|
|
129
|
+
this.normalizeAndQuantizeSignedPlayerSmaller(x, y);
|
|
130
|
+
this.denormalizeAndUnquantizeUnsignedFunc = (
|
|
131
|
+
x: number,
|
|
132
|
+
y: number
|
|
133
|
+
) => this.denormalizeAndUnquantizeUnsignedPlayerSmaller(x, y);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* normalizeAndQuantizeUnsigned for playerAspectRatio > videoAspectRatio
|
|
140
|
+
* @param x - x axis point
|
|
141
|
+
* @param y - y axis point
|
|
142
|
+
*/
|
|
143
|
+
normalizeAndQuantizeUnsignedPlayerBigger(
|
|
144
|
+
x: number,
|
|
145
|
+
y: number
|
|
146
|
+
): NormalizedQuantizedUnsignedCoord {
|
|
147
|
+
const normalizedX = x / this.videoElementParent.clientWidth;
|
|
148
|
+
const normalizedY =
|
|
149
|
+
this.ratio * (y / this.videoElementParent.clientHeight - 0.5) + 0.5;
|
|
150
|
+
if (
|
|
151
|
+
normalizedX < 0.0 ||
|
|
152
|
+
normalizedX > 1.0 ||
|
|
153
|
+
normalizedY < 0.0 ||
|
|
154
|
+
normalizedY > 1.0
|
|
155
|
+
) {
|
|
156
|
+
return new NormalizedQuantizedUnsignedCoord(false, 65535, 65535);
|
|
157
|
+
} else {
|
|
158
|
+
return new NormalizedQuantizedUnsignedCoord(
|
|
159
|
+
true,
|
|
160
|
+
normalizedX * 65536,
|
|
161
|
+
normalizedY * 65536
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* unquantizeAndDenormalizeUnsigned for playerAspectRatio > videoAspectRatio
|
|
168
|
+
* @param x - x axis point
|
|
169
|
+
* @param y - y axis point
|
|
170
|
+
*/
|
|
171
|
+
denormalizeAndUnquantizeUnsignedPlayerBigger(x: number, y: number) {
|
|
172
|
+
const normalizedX = x / 65536;
|
|
173
|
+
const normalizedY = (y / 65536 - 0.5) / this.ratio + 0.5;
|
|
174
|
+
return new UnquantizedDenormalizedUnsignedCoord(
|
|
175
|
+
normalizedX * this.videoElementParent.clientWidth,
|
|
176
|
+
normalizedY * this.videoElementParent.clientHeight
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* normalizeAndQuantizeSigned for playerAspectRatio > videoAspectRatio
|
|
182
|
+
* @param x - x axis point
|
|
183
|
+
* @param y - y axis point
|
|
184
|
+
*/
|
|
185
|
+
normalizeAndQuantizeSignedPlayerBigger(x: number, y: number) {
|
|
186
|
+
const normalizedX = x / (0.5 * this.videoElementParent.clientWidth);
|
|
187
|
+
const normalizedY =
|
|
188
|
+
(this.ratio * y) / (0.5 * this.videoElementParent.clientHeight);
|
|
189
|
+
return new NormalizedQuantizedSignedCoord(
|
|
190
|
+
normalizedX * 32767,
|
|
191
|
+
normalizedY * 32767
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* normalizeAndQuantizeUnsigned for playerAspectRatio <= videoAspectRatio
|
|
197
|
+
* @param x - x axis point
|
|
198
|
+
* @param y - y axis point
|
|
199
|
+
*/
|
|
200
|
+
normalizeAndQuantizeUnsignedPlayerSmaller(x: number, y: number) {
|
|
201
|
+
const normalizedX =
|
|
202
|
+
this.ratio * (x / this.videoElementParent.clientWidth - 0.5) + 0.5;
|
|
203
|
+
const normalizedY = y / this.videoElementParent.clientHeight;
|
|
204
|
+
if (
|
|
205
|
+
normalizedX < 0.0 ||
|
|
206
|
+
normalizedX > 1.0 ||
|
|
207
|
+
normalizedY < 0.0 ||
|
|
208
|
+
normalizedY > 1.0
|
|
209
|
+
) {
|
|
210
|
+
return new NormalizedQuantizedUnsignedCoord(false, 65535, 65535);
|
|
211
|
+
} else {
|
|
212
|
+
return new NormalizedQuantizedUnsignedCoord(
|
|
213
|
+
true,
|
|
214
|
+
normalizedX * 65536,
|
|
215
|
+
normalizedY * 65536
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* unquantizeAndDenormalizeUnsigned for playerAspectRatio <= videoAspectRatio
|
|
222
|
+
* @param x - x axis point
|
|
223
|
+
* @param y - y axis point
|
|
224
|
+
*/
|
|
225
|
+
denormalizeAndUnquantizeUnsignedPlayerSmaller(x: number, y: number) {
|
|
226
|
+
const normalizedX = (x / 65536 - 0.5) / this.ratio + 0.5;
|
|
227
|
+
const normalizedY = y / 65536;
|
|
228
|
+
return new UnquantizedDenormalizedUnsignedCoord(
|
|
229
|
+
normalizedX * this.videoElementParent.clientWidth,
|
|
230
|
+
normalizedY * this.videoElementParent.clientHeight
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* normalizeAndQuantizeSigned for playerAspectRatio <= videoAspectRatio
|
|
236
|
+
* @param x - x axis point
|
|
237
|
+
* @param y - y axis point
|
|
238
|
+
*/
|
|
239
|
+
normalizeAndQuantizeSignedPlayerSmaller(x: number, y: number) {
|
|
240
|
+
const normalizedX =
|
|
241
|
+
(this.ratio * x) / (0.5 * this.videoElementParent.clientWidth);
|
|
242
|
+
const normalizedY = y / (0.5 * this.videoElementParent.clientHeight);
|
|
243
|
+
return new NormalizedQuantizedSignedCoord(
|
|
244
|
+
normalizedX * 32767,
|
|
245
|
+
normalizedY * 32767
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* A class for NormalizeAndQuantizeUnsigned objects
|
|
252
|
+
*/
|
|
253
|
+
export class NormalizedQuantizedUnsignedCoord {
|
|
254
|
+
inRange: boolean;
|
|
255
|
+
x: number;
|
|
256
|
+
y: number;
|
|
257
|
+
|
|
258
|
+
constructor(inRange: boolean, x: number, y: number) {
|
|
259
|
+
this.inRange = inRange;
|
|
260
|
+
this.x = x;
|
|
261
|
+
this.y = y;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A class for UnquantizedAndDenormalizeUnsigned objects
|
|
267
|
+
*/
|
|
268
|
+
export class UnquantizedDenormalizedUnsignedCoord {
|
|
269
|
+
x: number;
|
|
270
|
+
y: number;
|
|
271
|
+
|
|
272
|
+
constructor(x: number, y: number) {
|
|
273
|
+
this.x = x;
|
|
274
|
+
this.y = y;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A class for NormalizedQuantizedSignedCoord objects
|
|
280
|
+
*/
|
|
281
|
+
export class NormalizedQuantizedSignedCoord {
|
|
282
|
+
x: number;
|
|
283
|
+
y: number;
|
|
284
|
+
|
|
285
|
+
constructor(x: number, y: number) {
|
|
286
|
+
this.x = x;
|
|
287
|
+
this.y = y;
|
|
288
|
+
}
|
|
289
|
+
}
|