@yang__yj/pixelstreaming-core 1.0.0 → 1.0.1
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/jest.config.js +18 -0
- package/package.json +46 -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 +2144 -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/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/{library/dist → dist}/lib-pixelstreamingfrontend.esm.js +0 -0
- /package/{library/dist → dist}/lib-pixelstreamingfrontend.js +0 -0
- /package/{library/types → types}/AFK/AFKController.d.ts +0 -0
- /package/{library/types → types}/Config/Config.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/HoveringMouseEvents.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/PeerConnectionController.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}/PixelStreaming/PixelStreaming.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/SendMessageController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/StreamMessageController.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/EventEmitter.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}/VideoPlayer/StreamController.d.ts +0 -0
- /package/{library/types → types}/VideoPlayer/VideoPlayer.d.ts +0 -0
- /package/{library/types → types}/WebRtcPlayer/WebRtcPlayerController.d.ts +0 -0
- /package/{library/types → types}/WebSockets/MessageReceive.d.ts +0 -0
- /package/{library/types → types}/WebSockets/MessageSend.d.ts +0 -0
- /package/{library/types → types}/WebSockets/SignallingProtocol.d.ts +0 -0
- /package/{library/types → types}/WebSockets/WebSocketController.d.ts +0 -0
- /package/{library/types → types}/WebXR/WebXRController.d.ts +0 -0
- /package/{library/types → types}/pixelstreamingfrontend.d.ts +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export class MockMediaStreamImpl implements MediaStream {
|
|
2
|
+
active: boolean;
|
|
3
|
+
id: string;
|
|
4
|
+
|
|
5
|
+
constructor(data?: MediaStream | MediaStreamTrack[]) {
|
|
6
|
+
//
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
onaddtrack: ((this: MediaStream, ev: MediaStreamTrackEvent) => any) | null;
|
|
10
|
+
onremovetrack: ((this: MediaStream, ev: MediaStreamTrackEvent) => any) | null;
|
|
11
|
+
addTrack(track: MediaStreamTrack): void {
|
|
12
|
+
throw new Error("Method not implemented.");
|
|
13
|
+
}
|
|
14
|
+
clone(): MediaStream {
|
|
15
|
+
throw new Error("Method not implemented.");
|
|
16
|
+
}
|
|
17
|
+
getAudioTracks(): MediaStreamTrack[] {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
getTrackById(trackId: string): MediaStreamTrack | null {
|
|
21
|
+
throw new Error("Method not implemented.");
|
|
22
|
+
}
|
|
23
|
+
getTracks(): MediaStreamTrack[] {
|
|
24
|
+
throw new Error("Method not implemented.");
|
|
25
|
+
}
|
|
26
|
+
getVideoTracks(): MediaStreamTrack[] {
|
|
27
|
+
throw new Error("Method not implemented.");
|
|
28
|
+
}
|
|
29
|
+
removeTrack(track: MediaStreamTrack): void {
|
|
30
|
+
throw new Error("Method not implemented.");
|
|
31
|
+
}
|
|
32
|
+
addEventListener<K extends keyof MediaStreamEventMap>(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
33
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
34
|
+
addEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
35
|
+
throw new Error("Method not implemented.");
|
|
36
|
+
}
|
|
37
|
+
removeEventListener<K extends keyof MediaStreamEventMap>(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
38
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
39
|
+
removeEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
40
|
+
throw new Error("Method not implemented.");
|
|
41
|
+
}
|
|
42
|
+
dispatchEvent(event: Event): boolean {
|
|
43
|
+
throw new Error("Method not implemented.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class MockMediaStreamTrackImpl implements MediaStreamTrack {
|
|
49
|
+
contentHint: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
id: string;
|
|
52
|
+
kind: string;
|
|
53
|
+
label: string;
|
|
54
|
+
muted: boolean;
|
|
55
|
+
readyState: MediaStreamTrackState;
|
|
56
|
+
|
|
57
|
+
constructor() {
|
|
58
|
+
this.kind = 'video';
|
|
59
|
+
this.readyState = 'live';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onended: ((this: MediaStreamTrack, ev: Event) => any) | null;
|
|
63
|
+
onmute: ((this: MediaStreamTrack, ev: Event) => any) | null;
|
|
64
|
+
onunmute: ((this: MediaStreamTrack, ev: Event) => any) | null;
|
|
65
|
+
applyConstraints(constraints?: MediaTrackConstraints | undefined): Promise<void> {
|
|
66
|
+
throw new Error("Method not implemented.");
|
|
67
|
+
}
|
|
68
|
+
clone(): MediaStreamTrack {
|
|
69
|
+
throw new Error("Method not implemented.");
|
|
70
|
+
}
|
|
71
|
+
getCapabilities(): MediaTrackCapabilities {
|
|
72
|
+
throw new Error("Method not implemented.");
|
|
73
|
+
}
|
|
74
|
+
getConstraints(): MediaTrackConstraints {
|
|
75
|
+
throw new Error("Method not implemented.");
|
|
76
|
+
}
|
|
77
|
+
getSettings(): MediaTrackSettings {
|
|
78
|
+
throw new Error("Method not implemented.");
|
|
79
|
+
}
|
|
80
|
+
stop(): void {
|
|
81
|
+
throw new Error("Method not implemented.");
|
|
82
|
+
}
|
|
83
|
+
addEventListener<K extends keyof MediaStreamTrackEventMap>(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
84
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
85
|
+
addEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
86
|
+
throw new Error("Method not implemented.");
|
|
87
|
+
}
|
|
88
|
+
removeEventListener<K extends keyof MediaStreamTrackEventMap>(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
89
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
90
|
+
removeEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
91
|
+
throw new Error("Method not implemented.");
|
|
92
|
+
}
|
|
93
|
+
dispatchEvent(event: Event): boolean {
|
|
94
|
+
throw new Error("Method not implemented.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const mockHTMLMediaElementPlay = (ableToPlay: boolean) => {
|
|
99
|
+
if (ableToPlay) {
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
}
|
|
102
|
+
return Promise.reject("mock cancel");
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const originalMediaStream = global.MediaStream;
|
|
106
|
+
const originalMediaStreamTrack = global.MediaStreamTrack;
|
|
107
|
+
export const mockMediaStream = () => {
|
|
108
|
+
global.MediaStream = MockMediaStreamImpl;
|
|
109
|
+
global.MediaStreamTrack = MockMediaStreamTrackImpl;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const unmockMediaStream = () => {
|
|
113
|
+
global.MediaStream = originalMediaStream;
|
|
114
|
+
global.MediaStreamTrack = originalMediaStreamTrack;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const mockHTMLMediaElement = (options: { ableToPlay: boolean, readyState?: number }) => {
|
|
118
|
+
const { ableToPlay, readyState } = options;
|
|
119
|
+
jest.spyOn(HTMLMediaElement.prototype, 'play').mockReturnValue(mockHTMLMediaElementPlay(ableToPlay));
|
|
120
|
+
if (readyState !== undefined) {
|
|
121
|
+
jest.spyOn(HTMLMediaElement.prototype, 'readyState', 'get').mockReturnValue(readyState);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
export interface MockRTCPeerConnectionSpyFunctions {
|
|
2
|
+
constructorSpy: null | ((config: RTCConfiguration) => void);
|
|
3
|
+
closeSpy: null | (() => void);
|
|
4
|
+
setRemoteDescriptionSpy: null | ((description: RTCSessionDescriptionInit) => void);
|
|
5
|
+
setLocalDescriptionSpy: null | ((description: RTCLocalSessionDescriptionInit) => void);
|
|
6
|
+
createAnswerSpy: null | (() => void);
|
|
7
|
+
addTransceiverSpy: null | ((trackOrKind: string | MediaStreamTrack, init?: RTCRtpTransceiverInit | undefined) => void);
|
|
8
|
+
addIceCandidateSpy: null | ((candidate: RTCIceCandidateInit) => void);
|
|
9
|
+
sendDataSpy: null | ((data: ArrayBuffer) => void);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MockRTCPeerConnectionTriggerFunctions {
|
|
13
|
+
triggerIceConnectionStateChange: null | ((state: RTCIceConnectionState) => void);
|
|
14
|
+
triggerOnTrack: null | ((data: RTCTrackEventInit) => void);
|
|
15
|
+
triggerOnIceCandidate: null | ((data: RTCPeerConnectionIceEventInit) => void);
|
|
16
|
+
triggerOnDataChannel: null | ((data: RTCDataChannelEventInit) => void);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const spyFunctions: MockRTCPeerConnectionSpyFunctions = {
|
|
20
|
+
constructorSpy: null,
|
|
21
|
+
closeSpy: null,
|
|
22
|
+
setRemoteDescriptionSpy: null,
|
|
23
|
+
setLocalDescriptionSpy: null,
|
|
24
|
+
createAnswerSpy: null,
|
|
25
|
+
addTransceiverSpy: null,
|
|
26
|
+
addIceCandidateSpy: null,
|
|
27
|
+
sendDataSpy: null,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const triggerFunctions: MockRTCPeerConnectionTriggerFunctions = {
|
|
31
|
+
triggerIceConnectionStateChange: null,
|
|
32
|
+
triggerOnTrack: null,
|
|
33
|
+
triggerOnIceCandidate: null,
|
|
34
|
+
triggerOnDataChannel: null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class MockRTCPeerConnectionImpl implements RTCPeerConnection {
|
|
38
|
+
|
|
39
|
+
canTrickleIceCandidates: boolean | null;
|
|
40
|
+
connectionState: RTCPeerConnectionState;
|
|
41
|
+
currentLocalDescription: RTCSessionDescription | null;
|
|
42
|
+
currentRemoteDescription: RTCSessionDescription | null;
|
|
43
|
+
iceConnectionState: RTCIceConnectionState;
|
|
44
|
+
iceGatheringState: RTCIceGatheringState;
|
|
45
|
+
localDescription: RTCSessionDescription | null;
|
|
46
|
+
pendingLocalDescription: RTCSessionDescription | null;
|
|
47
|
+
pendingRemoteDescription: RTCSessionDescription | null;
|
|
48
|
+
remoteDescription: RTCSessionDescription | null;
|
|
49
|
+
sctp: RTCSctpTransport | null;
|
|
50
|
+
signalingState: RTCSignalingState;
|
|
51
|
+
_dataChannels: RTCDataChannel[] = [];
|
|
52
|
+
|
|
53
|
+
constructor(config: RTCConfiguration) {
|
|
54
|
+
this.connectionState = "new";
|
|
55
|
+
this.iceConnectionState = "new";
|
|
56
|
+
spyFunctions.constructorSpy?.(config);
|
|
57
|
+
triggerFunctions.triggerIceConnectionStateChange = this.triggerIceConnectionStateChange.bind(this);
|
|
58
|
+
triggerFunctions.triggerOnTrack = this.triggerOnTrack.bind(this);
|
|
59
|
+
triggerFunctions.triggerOnIceCandidate = this.triggerOnIceCandidate.bind(this);
|
|
60
|
+
triggerFunctions.triggerOnDataChannel =
|
|
61
|
+
this.triggerOnDataChannel.bind(this);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
65
|
+
ondatachannel: ((this: RTCPeerConnection, ev: RTCDataChannelEvent) => any) | null;
|
|
66
|
+
onicecandidate: ((this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any) | null;
|
|
67
|
+
onicecandidateerror: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
68
|
+
oniceconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
69
|
+
onicegatheringstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
70
|
+
onnegotiationneeded: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
71
|
+
onsignalingstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
|
|
72
|
+
ontrack: ((this: RTCPeerConnection, ev: RTCTrackEvent) => any) | null;
|
|
73
|
+
addIceCandidate(candidate?: RTCIceCandidateInit | undefined): Promise<void>;
|
|
74
|
+
addIceCandidate(candidate: RTCIceCandidateInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
|
|
75
|
+
addIceCandidate(candidate?: unknown, successCallback?: unknown, failureCallback?: unknown): Promise<void> {
|
|
76
|
+
if (this.iceConnectionState !== "connected" && this.iceConnectionState !== "completed") {
|
|
77
|
+
this.iceConnectionState = "checking";
|
|
78
|
+
}
|
|
79
|
+
this.oniceconnectionstatechange?.(new Event("iceconnectionstatechange"));
|
|
80
|
+
spyFunctions.addIceCandidateSpy?.(candidate as RTCIceCandidateInit);
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender {
|
|
84
|
+
throw new Error("Method not implemented.");
|
|
85
|
+
}
|
|
86
|
+
addTransceiver(trackOrKind: string | MediaStreamTrack, init?: RTCRtpTransceiverInit | undefined): RTCRtpTransceiver {
|
|
87
|
+
spyFunctions.addTransceiverSpy?.(trackOrKind, init);
|
|
88
|
+
return {} as RTCRtpTransceiver;
|
|
89
|
+
}
|
|
90
|
+
createAnswer(options?: RTCAnswerOptions | undefined): Promise<RTCSessionDescriptionInit>;
|
|
91
|
+
createAnswer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
|
|
92
|
+
createAnswer(successCallback?: unknown, failureCallback?: unknown): Promise<void> | Promise<RTCSessionDescriptionInit> {
|
|
93
|
+
spyFunctions.createAnswerSpy?.();
|
|
94
|
+
const res: RTCSessionDescriptionInit = {
|
|
95
|
+
type: "answer",
|
|
96
|
+
sdp: "v=0\r\no=- 5791786663981007547 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 98\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:z0li\r\na=ice-pwd:DkbG5Q3dFSIygDc47cms4TGA\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F9:5B:3C:AB:89:88:0E:1B:2E:63:B3:D2:B8:92:59:E2:3A:46:B6:85:09:F4:50:0E:72:4F:9F:70:6D:5F:BD:1A\r\na=setup:active\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 urn:3gpp:video-orientation\r\na=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 H264/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=fmtp:96 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:98 H264/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 63 110\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:z0li\r\na=ice-pwd:DkbG5Q3dFSIygDc47cms4TGA\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F9:5B:3C:AB:89:88:0E:1B:2E:63:B3:D2:B8:92:59:E2:3A:46:B6:85:09:F4:50:0E:72:4F:9F:70:6D:5F:BD:1A\r\na=setup:active\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:110 telephone-event/48000\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:z0li\r\na=ice-pwd:DkbG5Q3dFSIygDc47cms4TGA\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F9:5B:3C:AB:89:88:0E:1B:2E:63:B3:D2:B8:92:59:E2:3A:46:B6:85:09:F4:50:0E:72:4F:9F:70:6D:5F:BD:1A\r\na=setup:active\r\na=mid:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"
|
|
97
|
+
};
|
|
98
|
+
return Promise.resolve(res);
|
|
99
|
+
}
|
|
100
|
+
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit | undefined): RTCDataChannel {
|
|
101
|
+
const dataChannel = new RTCDataChannel();
|
|
102
|
+
this._dataChannels.push(dataChannel);
|
|
103
|
+
return dataChannel;
|
|
104
|
+
}
|
|
105
|
+
createOffer(options?: RTCOfferOptions | undefined): Promise<RTCSessionDescriptionInit>;
|
|
106
|
+
createOffer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions | undefined): Promise<void>;
|
|
107
|
+
createOffer(successCallback?: unknown, failureCallback?: unknown, options?: unknown): Promise<void> | Promise<RTCSessionDescriptionInit> {
|
|
108
|
+
throw new Error("Method not implemented.");
|
|
109
|
+
}
|
|
110
|
+
getConfiguration(): RTCConfiguration {
|
|
111
|
+
throw new Error("Method not implemented.");
|
|
112
|
+
}
|
|
113
|
+
getReceivers(): RTCRtpReceiver[] {
|
|
114
|
+
throw new Error("Method not implemented.");
|
|
115
|
+
}
|
|
116
|
+
getSenders(): RTCRtpSender[] {
|
|
117
|
+
throw new Error("Method not implemented.");
|
|
118
|
+
}
|
|
119
|
+
getStats(selector?: MediaStreamTrack | null | undefined): Promise<RTCStatsReport> {
|
|
120
|
+
const stats = {
|
|
121
|
+
forEach: function (callbackfn: (value: any) => void): void {
|
|
122
|
+
callbackfn({
|
|
123
|
+
type: 'candidate-pair',
|
|
124
|
+
bytesReceived: 123,
|
|
125
|
+
});
|
|
126
|
+
callbackfn({
|
|
127
|
+
type: 'local-candidate',
|
|
128
|
+
address: 'mock-address',
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
return Promise.resolve(stats as RTCStatsReport);
|
|
133
|
+
}
|
|
134
|
+
getTransceivers(): RTCRtpTransceiver[] {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
removeTrack(sender: RTCRtpSender): void {
|
|
138
|
+
throw new Error("Method not implemented.");
|
|
139
|
+
}
|
|
140
|
+
restartIce(): void {
|
|
141
|
+
throw new Error("Method not implemented.");
|
|
142
|
+
}
|
|
143
|
+
setConfiguration(configuration?: RTCConfiguration | undefined): void {
|
|
144
|
+
throw new Error("Method not implemented.");
|
|
145
|
+
}
|
|
146
|
+
setLocalDescription(description?: RTCLocalSessionDescriptionInit | undefined): Promise<void>;
|
|
147
|
+
setLocalDescription(description: RTCLocalSessionDescriptionInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
|
|
148
|
+
setLocalDescription(description?: unknown, successCallback?: unknown, failureCallback?: unknown): Promise<void> {
|
|
149
|
+
spyFunctions.setLocalDescriptionSpy?.(description as RTCLocalSessionDescriptionInit);
|
|
150
|
+
return Promise.resolve();
|
|
151
|
+
}
|
|
152
|
+
setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
|
|
153
|
+
setRemoteDescription(description: RTCSessionDescriptionInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
|
|
154
|
+
setRemoteDescription(description: unknown, successCallback?: unknown, failureCallback?: unknown): Promise<void> {
|
|
155
|
+
spyFunctions.setRemoteDescriptionSpy?.(description as RTCSessionDescriptionInit);
|
|
156
|
+
return Promise.resolve();
|
|
157
|
+
}
|
|
158
|
+
addEventListener<K extends keyof RTCPeerConnectionEventMap>(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
159
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
160
|
+
addEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
161
|
+
throw new Error("Method not implemented.");
|
|
162
|
+
}
|
|
163
|
+
removeEventListener<K extends keyof RTCPeerConnectionEventMap>(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
164
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
165
|
+
removeEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
166
|
+
throw new Error("Method not implemented.");
|
|
167
|
+
}
|
|
168
|
+
dispatchEvent(event: Event): boolean {
|
|
169
|
+
throw new Error("Method not implemented.");
|
|
170
|
+
}
|
|
171
|
+
static generateCertificate(keygenAlgorithm: AlgorithmIdentifier): Promise<RTCCertificate> {
|
|
172
|
+
throw new Error("Method not implemented.");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
close(): void {
|
|
176
|
+
this.connectionState = "closed";
|
|
177
|
+
this.iceConnectionState = "closed";
|
|
178
|
+
this.onconnectionstatechange?.(new Event(this.connectionState));
|
|
179
|
+
this.oniceconnectionstatechange?.(new Event(this.iceConnectionState));
|
|
180
|
+
this._dataChannels.forEach((channel) => channel.close());
|
|
181
|
+
spyFunctions.closeSpy?.();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
triggerIceConnectionStateChange(state: RTCIceConnectionState) {
|
|
185
|
+
this.iceConnectionState = state;
|
|
186
|
+
const event = new Event(state);
|
|
187
|
+
this.oniceconnectionstatechange?.(event);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
triggerOnTrack(data: RTCTrackEventInit) {
|
|
191
|
+
const event = new RTCTrackEvent('track', data);
|
|
192
|
+
this.ontrack?.(event);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
triggerOnIceCandidate(data: RTCPeerConnectionIceEventInit) {
|
|
196
|
+
const event = new RTCPeerConnectionIceEvent('icecandidate', data);
|
|
197
|
+
this.onicecandidate?.(event);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
triggerOnDataChannel(data: RTCDataChannelEventInit) {
|
|
201
|
+
this._dataChannels.push(data.channel);
|
|
202
|
+
const event = new RTCDataChannelEvent('datachannel', data);
|
|
203
|
+
this.ondatachannel?.(event);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export class MockRTCIceCandidateImpl implements RTCIceCandidate {
|
|
208
|
+
address: string | null;
|
|
209
|
+
candidate: string;
|
|
210
|
+
component: RTCIceComponent | null;
|
|
211
|
+
foundation: string | null;
|
|
212
|
+
port: number | null;
|
|
213
|
+
priority: number | null;
|
|
214
|
+
protocol: RTCIceProtocol | null;
|
|
215
|
+
relatedAddress: string | null;
|
|
216
|
+
relatedPort: number | null;
|
|
217
|
+
sdpMLineIndex: number | null;
|
|
218
|
+
sdpMid: string | null;
|
|
219
|
+
tcpType: RTCIceTcpCandidateType | null;
|
|
220
|
+
type: RTCIceCandidateType | null;
|
|
221
|
+
usernameFragment: string | null;
|
|
222
|
+
|
|
223
|
+
constructor(options?: RTCIceCandidateInit) {
|
|
224
|
+
this.candidate = options?.candidate || "";
|
|
225
|
+
this.sdpMid = options?.sdpMid || null;
|
|
226
|
+
this.sdpMLineIndex = options?.sdpMLineIndex || null;
|
|
227
|
+
this.usernameFragment = options?.usernameFragment || null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
toJSON(): RTCIceCandidateInit {
|
|
231
|
+
throw new Error("Method not implemented.");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export class MockRTCDataChannelImpl implements RTCDataChannel {
|
|
236
|
+
binaryType: BinaryType;
|
|
237
|
+
bufferedAmount: number;
|
|
238
|
+
bufferedAmountLowThreshold: number;
|
|
239
|
+
id: number | null;
|
|
240
|
+
label: string;
|
|
241
|
+
maxPacketLifeTime: number | null;
|
|
242
|
+
maxRetransmits: number | null;
|
|
243
|
+
negotiated: boolean;
|
|
244
|
+
ordered: boolean;
|
|
245
|
+
protocol: string;
|
|
246
|
+
readyState: RTCDataChannelState;
|
|
247
|
+
|
|
248
|
+
constructor() {
|
|
249
|
+
this.readyState = "open";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
onbufferedamountlow: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
253
|
+
onclose: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
254
|
+
onclosing: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
255
|
+
onerror: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
256
|
+
onmessage: ((this: RTCDataChannel, ev: MessageEvent<any>) => any) | null;
|
|
257
|
+
onopen: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
258
|
+
close(): void {
|
|
259
|
+
this.onclose?.(new Event('close'));
|
|
260
|
+
}
|
|
261
|
+
send(data: string): void;
|
|
262
|
+
send(data: Blob): void;
|
|
263
|
+
send(data: ArrayBuffer): void;
|
|
264
|
+
send(data: ArrayBufferView): void;
|
|
265
|
+
send(data: unknown): void {
|
|
266
|
+
spyFunctions.sendDataSpy?.(data as ArrayBuffer);
|
|
267
|
+
}
|
|
268
|
+
addEventListener<K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
269
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
270
|
+
addEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
271
|
+
throw new Error("Method not implemented.");
|
|
272
|
+
}
|
|
273
|
+
removeEventListener<K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
274
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
275
|
+
removeEventListener(type: unknown, listener: unknown, options?: unknown): void {
|
|
276
|
+
throw new Error("Method not implemented.");
|
|
277
|
+
}
|
|
278
|
+
dispatchEvent(event: Event): boolean {
|
|
279
|
+
if (event.type === 'message') {
|
|
280
|
+
this.onmessage?.(event as MessageEvent);
|
|
281
|
+
}
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export class MockRTCDataChannelEventImpl extends Event implements RTCDataChannelEvent {
|
|
287
|
+
channel: RTCDataChannel;
|
|
288
|
+
constructor(name: string, data: RTCDataChannelEventInit) {
|
|
289
|
+
super(name, data);
|
|
290
|
+
this.channel = data.channel;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export class MockRTCTrackEventImpl extends Event implements RTCTrackEvent {
|
|
295
|
+
receiver: RTCRtpReceiver;
|
|
296
|
+
streams: readonly MediaStream[];
|
|
297
|
+
track: MediaStreamTrack;
|
|
298
|
+
transceiver: RTCRtpTransceiver;
|
|
299
|
+
constructor(name: string, data: RTCTrackEventInit) {
|
|
300
|
+
super(name, data);
|
|
301
|
+
this.receiver = data.receiver;
|
|
302
|
+
this.streams = data.streams || [];
|
|
303
|
+
this.track = data.track;
|
|
304
|
+
this.transceiver = data.transceiver;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const originalRTCPeerConnection = global.RTCPeerConnection;
|
|
309
|
+
const originalRTCIceCandidate = global.RTCIceCandidate;
|
|
310
|
+
const originalRTCDataChannel = global.RTCDataChannel;
|
|
311
|
+
const originalRTCDataChannelEvent = global.RTCDataChannelEvent;
|
|
312
|
+
const originalRTCTrackEvent = global.RTCTrackEvent;
|
|
313
|
+
export const mockRTCPeerConnection = (): [
|
|
314
|
+
MockRTCPeerConnectionSpyFunctions,
|
|
315
|
+
MockRTCPeerConnectionTriggerFunctions
|
|
316
|
+
] => {
|
|
317
|
+
spyFunctions.constructorSpy = jest.fn();
|
|
318
|
+
spyFunctions.closeSpy = jest.fn();
|
|
319
|
+
spyFunctions.setRemoteDescriptionSpy = jest.fn();
|
|
320
|
+
spyFunctions.setLocalDescriptionSpy = jest.fn();
|
|
321
|
+
spyFunctions.createAnswerSpy = jest.fn();
|
|
322
|
+
spyFunctions.addTransceiverSpy = jest.fn();
|
|
323
|
+
spyFunctions.addIceCandidateSpy = jest.fn();
|
|
324
|
+
spyFunctions.sendDataSpy = jest.fn();
|
|
325
|
+
global.RTCPeerConnection = MockRTCPeerConnectionImpl;
|
|
326
|
+
global.RTCIceCandidate = MockRTCIceCandidateImpl;
|
|
327
|
+
global.RTCDataChannel = MockRTCDataChannelImpl;
|
|
328
|
+
global.RTCDataChannelEvent = MockRTCDataChannelEventImpl;
|
|
329
|
+
global.RTCTrackEvent = MockRTCTrackEventImpl;
|
|
330
|
+
return [spyFunctions, triggerFunctions];
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export const unmockRTCPeerConnection = () => {
|
|
334
|
+
global.RTCPeerConnection = originalRTCPeerConnection;
|
|
335
|
+
global.RTCIceCandidate = originalRTCIceCandidate;
|
|
336
|
+
global.RTCDataChannel = originalRTCDataChannel;
|
|
337
|
+
global.RTCDataChannelEvent = originalRTCDataChannelEvent;
|
|
338
|
+
global.RTCTrackEvent = originalRTCTrackEvent;
|
|
339
|
+
spyFunctions.constructorSpy = null;
|
|
340
|
+
spyFunctions.closeSpy = null;
|
|
341
|
+
spyFunctions.setRemoteDescriptionSpy = null;
|
|
342
|
+
spyFunctions.setLocalDescriptionSpy = null;
|
|
343
|
+
spyFunctions.createAnswerSpy = null;
|
|
344
|
+
spyFunctions.addTransceiverSpy = null;
|
|
345
|
+
spyFunctions.addIceCandidateSpy = null;
|
|
346
|
+
spyFunctions.sendDataSpy = null;
|
|
347
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const mockRTCRtpReceiverImpl = {
|
|
2
|
+
prototype: jest.fn(),
|
|
3
|
+
getCapabilities: () => ({
|
|
4
|
+
codecs: [
|
|
5
|
+
{
|
|
6
|
+
clockRate: 60,
|
|
7
|
+
mimeType: "testMimeType",
|
|
8
|
+
sdpFmtpLine: "AV1"
|
|
9
|
+
}
|
|
10
|
+
] as RTCRtpCodecCapability[],
|
|
11
|
+
headerExtensions: [] as RTCRtpHeaderExtensionCapability[]
|
|
12
|
+
})
|
|
13
|
+
} as any as typeof global.RTCRtpReceiver;
|
|
14
|
+
|
|
15
|
+
const originalRTCRtpReceiver = global.RTCRtpReceiver;
|
|
16
|
+
export const mockRTCRtpReceiver = () => {
|
|
17
|
+
global.RTCRtpReceiver = mockRTCRtpReceiverImpl;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const unmockRTCRtpReceiver = () => {
|
|
21
|
+
global.RTCRtpReceiver = originalRTCRtpReceiver;
|
|
22
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export interface MockWebSocketSpyFunctions {
|
|
2
|
+
constructorSpy: null | ((url: string) => void);
|
|
3
|
+
openSpy: null | ((event: Event) => void);
|
|
4
|
+
errorSpy: null | ((event: Event) => void);
|
|
5
|
+
closeSpy: null | ((event: CloseEvent) => void);
|
|
6
|
+
messageSpy: null | ((event: MessageEvent) => void);
|
|
7
|
+
messageBinarySpy: null | ((event: MessageEvent) => void);
|
|
8
|
+
sendSpy: null | ((data: string | Blob | ArrayBufferView | ArrayBufferLike) => void);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MockWebSocketTriggerFunctions {
|
|
12
|
+
triggerOnOpen: null | (() => void);
|
|
13
|
+
triggerOnError: null | (() => void);
|
|
14
|
+
triggerOnClose: null | ((closeReason?: CloseEventInit) => void);
|
|
15
|
+
triggerOnMessage: null | ((message?: object) => void);
|
|
16
|
+
triggerOnMessageBinary: null | ((message?: Blob) => void);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const spyFunctions: MockWebSocketSpyFunctions = {
|
|
20
|
+
constructorSpy: null,
|
|
21
|
+
openSpy: null,
|
|
22
|
+
errorSpy: null,
|
|
23
|
+
closeSpy: null,
|
|
24
|
+
messageSpy: null,
|
|
25
|
+
messageBinarySpy: null,
|
|
26
|
+
sendSpy: null
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const triggerFunctions: MockWebSocketTriggerFunctions = {
|
|
30
|
+
triggerOnOpen: null,
|
|
31
|
+
triggerOnError: null,
|
|
32
|
+
triggerOnClose: null,
|
|
33
|
+
triggerOnMessage: null,
|
|
34
|
+
triggerOnMessageBinary: null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class MockWebSocketImpl extends WebSocket {
|
|
38
|
+
_readyState: number;
|
|
39
|
+
|
|
40
|
+
constructor(url: string | URL, protocols?: string | string[]) {
|
|
41
|
+
super(url, protocols);
|
|
42
|
+
this._readyState = this.OPEN;
|
|
43
|
+
spyFunctions.constructorSpy?.(this.url);
|
|
44
|
+
triggerFunctions.triggerOnOpen = this.triggerOnOpen.bind(this);
|
|
45
|
+
triggerFunctions.triggerOnError = this.triggerOnError.bind(this);
|
|
46
|
+
triggerFunctions.triggerOnClose = this.triggerOnClose.bind(this);
|
|
47
|
+
triggerFunctions.triggerOnMessage = this.triggerOnMessage.bind(this);
|
|
48
|
+
triggerFunctions.triggerOnMessageBinary =
|
|
49
|
+
this.triggerOnMessageBinary.bind(this);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get readyState() {
|
|
53
|
+
return this._readyState;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
close(code?: number | undefined, reason?: string | undefined): void {
|
|
57
|
+
super.close(code, reason);
|
|
58
|
+
this._readyState = this.CLOSED;
|
|
59
|
+
this.triggerOnClose({ code, reason });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
send(data: string | Blob | ArrayBufferView | ArrayBufferLike): void {
|
|
63
|
+
spyFunctions.sendSpy?.(data);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
triggerOnOpen() {
|
|
67
|
+
const event = new Event('open');
|
|
68
|
+
this.onopen?.(event);
|
|
69
|
+
spyFunctions.openSpy?.(event);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
triggerOnError() {
|
|
73
|
+
const event = new Event('error');
|
|
74
|
+
this.onerror?.(event);
|
|
75
|
+
spyFunctions.errorSpy?.(event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
triggerOnClose(closeReason?: CloseEventInit) {
|
|
79
|
+
const reason = closeReason ?? { code: 1, reason: 'mock reason' };
|
|
80
|
+
const event = new CloseEvent('close', reason);
|
|
81
|
+
this.onclose?.(event);
|
|
82
|
+
spyFunctions.closeSpy?.(event);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
triggerOnMessage(message?: object) {
|
|
86
|
+
const data = message
|
|
87
|
+
? JSON.stringify(message)
|
|
88
|
+
: JSON.stringify({ type: 'test' });
|
|
89
|
+
const event = new MessageEvent('message', { data });
|
|
90
|
+
this.onmessage?.(event);
|
|
91
|
+
spyFunctions.messageSpy?.(event);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
triggerOnMessageBinary(message?: Blob) {
|
|
95
|
+
const data =
|
|
96
|
+
message ??
|
|
97
|
+
new Blob([JSON.stringify({ type: 'test' })], {
|
|
98
|
+
type: 'application/json'
|
|
99
|
+
});
|
|
100
|
+
const event = new MessageEvent('messagebinary', { data });
|
|
101
|
+
this.onmessagebinary?.(event);
|
|
102
|
+
spyFunctions.messageBinarySpy?.(event);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const originalWebSocket = WebSocket;
|
|
107
|
+
export const mockWebSocket = (): [
|
|
108
|
+
MockWebSocketSpyFunctions,
|
|
109
|
+
MockWebSocketTriggerFunctions
|
|
110
|
+
] => {
|
|
111
|
+
spyFunctions.constructorSpy = jest.fn();
|
|
112
|
+
spyFunctions.openSpy = jest.fn();
|
|
113
|
+
spyFunctions.errorSpy = jest.fn();
|
|
114
|
+
spyFunctions.closeSpy = jest.fn();
|
|
115
|
+
spyFunctions.messageSpy = jest.fn();
|
|
116
|
+
spyFunctions.messageBinarySpy = jest.fn();
|
|
117
|
+
spyFunctions.sendSpy = jest.fn();
|
|
118
|
+
global.WebSocket = MockWebSocketImpl;
|
|
119
|
+
return [spyFunctions, triggerFunctions];
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const unmockWebSocket = () => {
|
|
123
|
+
global.WebSocket = originalWebSocket;
|
|
124
|
+
spyFunctions.constructorSpy = null;
|
|
125
|
+
spyFunctions.openSpy = null;
|
|
126
|
+
spyFunctions.errorSpy = null;
|
|
127
|
+
spyFunctions.closeSpy = null;
|
|
128
|
+
spyFunctions.messageSpy = null;
|
|
129
|
+
spyFunctions.messageBinarySpy = null;
|
|
130
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
export { WebRtcPlayerController } from './WebRtcPlayer/WebRtcPlayerController';
|
|
4
|
+
export { WebXRController } from './WebXR/WebXRController';
|
|
5
|
+
export {
|
|
6
|
+
Config,
|
|
7
|
+
ControlSchemeType,
|
|
8
|
+
Flags,
|
|
9
|
+
NumericParameters,
|
|
10
|
+
TextParameters,
|
|
11
|
+
OptionParameters,
|
|
12
|
+
// FlagsIds,
|
|
13
|
+
// NumericParametersIds,
|
|
14
|
+
// TextParametersIds,
|
|
15
|
+
// OptionParametersIds,
|
|
16
|
+
// AllSettings
|
|
17
|
+
} from './Config/Config';
|
|
18
|
+
export { SettingBase } from './Config/SettingBase';
|
|
19
|
+
export { SettingFlag } from './Config/SettingFlag';
|
|
20
|
+
export { SettingNumber } from './Config/SettingNumber';
|
|
21
|
+
export { SettingOption } from './Config/SettingOption';
|
|
22
|
+
export { SettingText } from './Config/SettingText';
|
|
23
|
+
export { PixelStreaming } from './PixelStreaming/PixelStreaming';
|
|
24
|
+
|
|
25
|
+
export { AFKController as AfkLogic } from './AFK/AFKController';
|
|
26
|
+
|
|
27
|
+
export { LatencyTestResults } from './DataChannel/LatencyTestResults';
|
|
28
|
+
export {
|
|
29
|
+
EncoderSettings,
|
|
30
|
+
InitialSettings,
|
|
31
|
+
WebRTCSettings
|
|
32
|
+
} from './DataChannel/InitialSettings';
|
|
33
|
+
export { AggregatedStats } from './PeerConnectionController/AggregatedStats';
|
|
34
|
+
export { Logger } from './Logger/Logger';
|
|
35
|
+
export { UnquantizedDenormalizedUnsignedCoord as UnquantizedAndDenormalizeUnsigned } from './Util/CoordinateConverter';
|
|
36
|
+
export { MessageDirection } from './UeInstanceMessage/StreamMessageController';
|
|
37
|
+
export { MessageSend } from './WebSockets/MessageSend';
|
|
38
|
+
export { MessageRecv, MessageStreamerList } from './WebSockets/MessageReceive';
|
|
39
|
+
export { WebSocketController } from './WebSockets/WebSocketController';
|
|
40
|
+
export { SignallingProtocol } from './WebSockets/SignallingProtocol';
|
|
41
|
+
|
|
42
|
+
export { CandidatePairStats } from './PeerConnectionController/CandidatePairStats';
|
|
43
|
+
export { CandidateStat } from './PeerConnectionController/CandidateStat';
|
|
44
|
+
export { DataChannelStats } from './PeerConnectionController/DataChannelStats';
|
|
45
|
+
export {
|
|
46
|
+
InboundAudioStats,
|
|
47
|
+
InboundVideoStats
|
|
48
|
+
} from './PeerConnectionController/InboundRTPStats';
|
|
49
|
+
export { OutBoundVideoStats } from './PeerConnectionController/OutBoundRTPStats';
|
|
50
|
+
export * from './Util/EventEmitter';
|