@yume-chan/scrcpy 0.0.18 → 0.0.20
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/CHANGELOG.json +33 -0
- package/CHANGELOG.md +18 -1
- package/README.md +157 -183
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +1 -1
- package/bin/version.js +1 -1
- package/esm/codec/av1.d.ts +33 -0
- package/esm/codec/av1.d.ts.map +1 -0
- package/esm/codec/av1.js +35 -0
- package/esm/codec/av1.js.map +1 -0
- package/esm/codec/h264.d.ts +78 -0
- package/esm/codec/h264.d.ts.map +1 -0
- package/esm/codec/h264.js +256 -0
- package/esm/codec/h264.js.map +1 -0
- package/esm/codec/h265.d.ts +490 -0
- package/esm/codec/h265.d.ts.map +1 -0
- package/esm/codec/h265.js +1098 -0
- package/esm/codec/h265.js.map +1 -0
- package/esm/codec/index.d.ts +5 -0
- package/esm/codec/index.d.ts.map +1 -0
- package/esm/codec/index.js +5 -0
- package/esm/codec/index.js.map +1 -0
- package/esm/codec/nalu.d.ts +44 -0
- package/esm/codec/nalu.d.ts.map +1 -0
- package/esm/codec/nalu.js +310 -0
- package/esm/codec/nalu.js.map +1 -0
- package/esm/control/back-or-screen-on.d.ts +2 -2
- package/esm/control/back-or-screen-on.d.ts.map +1 -1
- package/esm/control/back-or-screen-on.js +1 -1
- package/esm/control/basic.d.ts +5 -0
- package/esm/control/basic.d.ts.map +1 -0
- package/esm/control/basic.js +3 -0
- package/esm/control/basic.js.map +1 -0
- package/esm/control/hover-helper.d.ts +17 -17
- package/esm/control/hover-helper.d.ts.map +1 -1
- package/esm/control/hover-helper.js +43 -43
- package/esm/control/hover-helper.js.map +1 -1
- package/esm/control/index.d.ts +13 -11
- package/esm/control/index.d.ts.map +1 -1
- package/esm/control/index.js +13 -11
- package/esm/control/index.js.map +1 -1
- package/esm/control/inject-keycode.d.ts +193 -60
- package/esm/control/inject-keycode.d.ts.map +1 -1
- package/esm/control/inject-keycode.js +198 -61
- package/esm/control/inject-keycode.js.map +1 -1
- package/esm/control/inject-scroll.d.ts +2 -2
- package/esm/control/inject-scroll.d.ts.map +1 -1
- package/esm/control/inject-scroll.js +1 -1
- package/esm/control/inject-text.d.ts +7 -8
- package/esm/control/inject-text.d.ts.map +1 -1
- package/esm/control/inject-text.js +5 -6
- package/esm/control/inject-text.js.map +1 -1
- package/esm/control/inject-touch.d.ts +32 -37
- package/esm/control/inject-touch.d.ts.map +1 -1
- package/esm/control/inject-touch.js +35 -62
- package/esm/control/inject-touch.js.map +1 -1
- package/esm/control/rotate-device.d.ts +4 -6
- package/esm/control/rotate-device.d.ts.map +1 -1
- package/esm/control/rotate-device.js +2 -4
- package/esm/control/rotate-device.js.map +1 -1
- package/esm/control/serializer.d.ts +25 -33
- package/esm/control/serializer.d.ts.map +1 -1
- package/esm/control/serializer.js +53 -78
- package/esm/control/serializer.js.map +1 -1
- package/esm/control/set-clipboard.d.ts +2 -2
- package/esm/control/set-clipboard.d.ts.map +1 -1
- package/esm/control/set-clipboard.js +1 -1
- package/esm/control/set-screen-power-mode.d.ts +10 -11
- package/esm/control/set-screen-power-mode.d.ts.map +1 -1
- package/esm/control/set-screen-power-mode.js +10 -11
- package/esm/control/set-screen-power-mode.js.map +1 -1
- package/esm/control/type.d.ts +28 -14
- package/esm/control/type.d.ts.map +1 -1
- package/esm/control/type.js +40 -18
- package/esm/control/type.js.map +1 -1
- package/esm/control/writer.d.ts +28 -0
- package/esm/control/writer.d.ts.map +1 -0
- package/esm/control/writer.js +53 -0
- package/esm/control/writer.js.map +1 -0
- package/esm/device-message/ack-clipboard.d.ts +8 -8
- package/esm/device-message/ack-clipboard.d.ts.map +1 -1
- package/esm/device-message/ack-clipboard.js +5 -5
- package/esm/device-message/clipboard.d.ts +9 -9
- package/esm/device-message/clipboard.d.ts.map +1 -1
- package/esm/device-message/clipboard.js +6 -6
- package/esm/device-message/index.d.ts +4 -4
- package/esm/device-message/index.js +4 -4
- package/esm/device-message/stream.d.ts +7 -7
- package/esm/device-message/stream.d.ts.map +1 -1
- package/esm/device-message/stream.js +34 -19
- package/esm/device-message/stream.js.map +1 -1
- package/esm/device-message/type.d.ts +4 -4
- package/esm/device-message/type.js +6 -6
- package/esm/index.d.ts +4 -5
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -5
- package/esm/index.js.map +1 -1
- package/esm/options/1_16/codec-options.d.ts +19 -19
- package/esm/options/1_16/codec-options.d.ts.map +1 -1
- package/esm/options/1_16/codec-options.js +25 -25
- package/esm/options/1_16/codec-options.js.map +1 -1
- package/esm/options/1_16/float-to-uint16.d.ts +5 -0
- package/esm/options/1_16/float-to-uint16.d.ts.map +1 -0
- package/esm/options/1_16/float-to-uint16.js +27 -0
- package/esm/options/1_16/float-to-uint16.js.map +1 -0
- package/esm/options/1_16/index.d.ts +6 -4
- package/esm/options/1_16/index.d.ts.map +1 -1
- package/esm/options/1_16/index.js +6 -4
- package/esm/options/1_16/index.js.map +1 -1
- package/esm/options/1_16/init.d.ts +66 -0
- package/esm/options/1_16/init.d.ts.map +1 -0
- package/esm/options/1_16/init.js +16 -0
- package/esm/options/1_16/init.js.map +1 -0
- package/esm/options/1_16/message.d.ts +32 -0
- package/esm/options/1_16/message.d.ts.map +1 -0
- package/esm/options/1_16/message.js +37 -0
- package/esm/options/1_16/message.js.map +1 -0
- package/esm/options/1_16/options.d.ts +48 -93
- package/esm/options/1_16/options.d.ts.map +1 -1
- package/esm/options/1_16/options.js +152 -189
- package/esm/options/1_16/options.js.map +1 -1
- package/esm/options/1_16/scroll.d.ts +26 -26
- package/esm/options/1_16/scroll.d.ts.map +1 -1
- package/esm/options/1_16/scroll.js +54 -55
- package/esm/options/1_16/scroll.js.map +1 -1
- package/esm/options/1_17.d.ts +33 -0
- package/esm/options/1_17.d.ts.map +1 -0
- package/esm/options/1_17.js +42 -0
- package/esm/options/1_17.js.map +1 -0
- package/esm/options/1_18.d.ts +59 -19
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +78 -45
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.d.ts +41 -20
- package/esm/options/1_21.d.ts.map +1 -1
- package/esm/options/1_21.js +51 -36
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22/index.d.ts +3 -2
- package/esm/options/1_22/index.d.ts.map +1 -1
- package/esm/options/1_22/index.js +3 -2
- package/esm/options/1_22/index.js.map +1 -1
- package/esm/options/1_22/init.d.ts +17 -0
- package/esm/options/1_22/init.d.ts.map +1 -0
- package/esm/options/1_22/init.js +2 -0
- package/esm/options/1_22/init.js.map +1 -0
- package/esm/options/1_22/options.d.ts +35 -28
- package/esm/options/1_22/options.d.ts.map +1 -1
- package/esm/options/1_22/options.js +36 -25
- package/esm/options/1_22/options.js.map +1 -1
- package/esm/options/1_22/scroll.d.ts +16 -16
- package/esm/options/1_22/scroll.d.ts.map +1 -1
- package/esm/options/1_22/scroll.js +14 -14
- package/esm/options/1_23.d.ts +36 -11
- package/esm/options/1_23.d.ts.map +1 -1
- package/esm/options/1_23.js +44 -34
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts +34 -8
- package/esm/options/1_24.d.ts.map +1 -1
- package/esm/options/1_24.js +22 -12
- package/esm/options/1_24.js.map +1 -1
- package/esm/options/1_25/index.d.ts +2 -2
- package/esm/options/1_25/index.js +2 -2
- package/esm/options/1_25/options.d.ts +10 -5
- package/esm/options/1_25/options.d.ts.map +1 -1
- package/esm/options/1_25/options.js +21 -7
- package/esm/options/1_25/options.js.map +1 -1
- package/esm/options/1_25/scroll.d.ts +19 -18
- package/esm/options/1_25/scroll.d.ts.map +1 -1
- package/esm/options/1_25/scroll.js +33 -32
- package/esm/options/1_25/scroll.js.map +1 -1
- package/esm/options/2_0.d.ts +91 -0
- package/esm/options/2_0.d.ts.map +1 -0
- package/esm/options/2_0.js +244 -0
- package/esm/options/2_0.js.map +1 -0
- package/esm/options/codec.d.ts +52 -0
- package/esm/options/codec.d.ts.map +1 -0
- package/esm/options/codec.js +26 -0
- package/esm/options/codec.js.map +1 -0
- package/esm/options/index.d.ts +12 -8
- package/esm/options/index.d.ts.map +1 -1
- package/esm/options/index.js +12 -8
- package/esm/options/index.js.map +1 -1
- package/esm/options/latest.d.ts +12 -0
- package/esm/options/latest.d.ts.map +1 -0
- package/esm/options/latest.js +8 -0
- package/esm/options/latest.js.map +1 -0
- package/esm/options/types.d.ts +86 -46
- package/esm/options/types.d.ts.map +1 -1
- package/esm/options/types.js +69 -17
- package/esm/options/types.js.map +1 -1
- package/package.json +10 -16
- package/src/codec/av1.ts +33 -0
- package/src/codec/h264.ts +317 -0
- package/src/codec/h265.ts +1375 -0
- package/src/codec/index.ts +4 -0
- package/src/codec/nalu.ts +373 -0
- package/src/control/back-or-screen-on.ts +1 -1
- package/src/control/basic.ts +3 -0
- package/src/control/hover-helper.ts +2 -4
- package/src/control/index.ts +2 -0
- package/src/control/inject-keycode.ts +194 -51
- package/src/control/inject-scroll.ts +1 -1
- package/src/control/inject-text.ts +6 -9
- package/src/control/inject-touch.ts +16 -55
- package/src/control/rotate-device.ts +3 -7
- package/src/control/serializer.ts +49 -105
- package/src/control/set-clipboard.ts +1 -1
- package/src/control/set-screen-power-mode.ts +6 -9
- package/src/control/type.ts +32 -0
- package/src/control/writer.ts +87 -0
- package/src/device-message/ack-clipboard.ts +1 -1
- package/src/device-message/clipboard.ts +1 -1
- package/src/device-message/stream.ts +32 -12
- package/src/index.ts +4 -5
- package/src/options/1_16/codec-options.ts +5 -8
- package/src/options/1_16/float-to-uint16.ts +33 -0
- package/src/options/1_16/index.ts +3 -1
- package/src/options/1_16/init.ts +80 -0
- package/src/options/1_16/message.ts +55 -0
- package/src/options/1_16/options.ts +152 -256
- package/src/options/1_16/scroll.ts +2 -5
- package/src/options/1_17.ts +66 -0
- package/src/options/1_18.ts +106 -42
- package/src/options/1_21.ts +51 -30
- package/src/options/1_22/index.ts +1 -0
- package/src/options/1_22/init.ts +19 -0
- package/src/options/1_22/options.ts +40 -46
- package/src/options/1_22/scroll.ts +2 -2
- package/src/options/1_23.ts +33 -23
- package/src/options/1_24.ts +25 -11
- package/src/options/1_25/options.ts +25 -6
- package/src/options/1_25/scroll.ts +5 -7
- package/src/options/2_0.ts +342 -0
- package/src/options/codec.ts +98 -0
- package/src/options/index.ts +7 -3
- package/src/options/latest.ts +14 -0
- package/src/options/types.ts +158 -48
- package/tsconfig.build.json +9 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/adb/client.d.ts +0 -41
- package/esm/adb/client.d.ts.map +0 -1
- package/esm/adb/client.js +0 -243
- package/esm/adb/client.js.map +0 -1
- package/esm/adb/connection.d.ts +0 -47
- package/esm/adb/connection.d.ts.map +0 -1
- package/esm/adb/connection.js +0 -110
- package/esm/adb/connection.js.map +0 -1
- package/esm/adb/index.d.ts +0 -4
- package/esm/adb/index.d.ts.map +0 -1
- package/esm/adb/index.js +0 -4
- package/esm/adb/index.js.map +0 -1
- package/esm/adb/options/1_16.d.ts +0 -8
- package/esm/adb/options/1_16.d.ts.map +0 -1
- package/esm/adb/options/1_16.js +0 -20
- package/esm/adb/options/1_16.js.map +0 -1
- package/esm/adb/options/1_22.d.ts +0 -8
- package/esm/adb/options/1_22.d.ts.map +0 -1
- package/esm/adb/options/1_22.js +0 -17
- package/esm/adb/options/1_22.js.map +0 -1
- package/esm/adb/options/index.d.ts +0 -4
- package/esm/adb/options/index.d.ts.map +0 -1
- package/esm/adb/options/index.js +0 -4
- package/esm/adb/options/index.js.map +0 -1
- package/esm/adb/options/types.d.ts +0 -24
- package/esm/adb/options/types.d.ts.map +0 -1
- package/esm/adb/options/types.js +0 -37
- package/esm/adb/options/types.js.map +0 -1
- package/esm/codec.d.ts +0 -34
- package/esm/codec.d.ts.map +0 -1
- package/esm/codec.js +0 -37
- package/esm/codec.js.map +0 -1
- package/esm/options/1_16/h264-configuration.d.ts +0 -49
- package/esm/options/1_16/h264-configuration.d.ts.map +0 -1
- package/esm/options/1_16/h264-configuration.js +0 -414
- package/esm/options/1_16/h264-configuration.js.map +0 -1
- package/esm/options/1_16/sps.d.ts +0 -22
- package/esm/options/1_16/sps.d.ts.map +0 -1
- package/esm/options/1_16/sps.js +0 -263
- package/esm/options/1_16/sps.js.map +0 -1
- package/src/adb/client.ts +0 -345
- package/src/adb/connection.ts +0 -192
- package/src/adb/index.ts +0 -3
- package/src/adb/options/1_16.ts +0 -30
- package/src/adb/options/1_22.ts +0 -26
- package/src/adb/options/index.ts +0 -3
- package/src/adb/options/types.ts +0 -75
- package/src/codec.ts +0 -35
- package/src/options/1_16/h264-configuration.ts +0 -485
package/esm/options/1_16/sps.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
// cspell: ignore golomb
|
|
2
|
-
// cspell: ignore qpprime
|
|
3
|
-
class BitReader {
|
|
4
|
-
buffer;
|
|
5
|
-
bytePosition = 0;
|
|
6
|
-
bitPosition = 0;
|
|
7
|
-
constructor(buffer) {
|
|
8
|
-
this.buffer = buffer;
|
|
9
|
-
}
|
|
10
|
-
read(length) {
|
|
11
|
-
let result = 0;
|
|
12
|
-
for (let i = 0; i < length; i += 1) {
|
|
13
|
-
result = (result << 1) | this.next();
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
next() {
|
|
18
|
-
const value = (this.buffer[this.bytePosition] >> (7 - this.bitPosition)) & 1;
|
|
19
|
-
this.bitPosition += 1;
|
|
20
|
-
if (this.bitPosition === 8) {
|
|
21
|
-
this.bytePosition += 1;
|
|
22
|
-
this.bitPosition = 0;
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
decodeExponentialGolombNumber() {
|
|
27
|
-
let length = 0;
|
|
28
|
-
while (this.next() === 0) {
|
|
29
|
-
length += 1;
|
|
30
|
-
}
|
|
31
|
-
if (length === 0) {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
return ((1 << length) | this.read(length)) - 1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function* iterateNalu(buffer) {
|
|
38
|
-
// -1 means we haven't found the first start code
|
|
39
|
-
let start = -1;
|
|
40
|
-
let writeIndex = 0;
|
|
41
|
-
// How many `0x00`s in a row we have counted
|
|
42
|
-
let zeroCount = 0;
|
|
43
|
-
let inEmulation = false;
|
|
44
|
-
for (const byte of buffer) {
|
|
45
|
-
buffer[writeIndex] = byte;
|
|
46
|
-
writeIndex += 1;
|
|
47
|
-
if (inEmulation) {
|
|
48
|
-
if (byte > 0x03) {
|
|
49
|
-
// `0x00000304` or larger are invalid
|
|
50
|
-
throw new Error("Invalid data");
|
|
51
|
-
}
|
|
52
|
-
inEmulation = false;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (byte == 0x00) {
|
|
56
|
-
zeroCount += 1;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const lastZeroCount = zeroCount;
|
|
60
|
-
zeroCount = 0;
|
|
61
|
-
if (start === -1) {
|
|
62
|
-
// 0x000001 is the start code
|
|
63
|
-
// But it can be preceded by any number of zeros
|
|
64
|
-
// So 2 is the minimal
|
|
65
|
-
if (lastZeroCount >= 2 && byte === 0x01) {
|
|
66
|
-
// Found start of first NAL unit
|
|
67
|
-
writeIndex = 0;
|
|
68
|
-
start = 0;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
// Not begin with start code
|
|
72
|
-
throw new Error("Invalid data");
|
|
73
|
-
}
|
|
74
|
-
if (lastZeroCount < 2) {
|
|
75
|
-
// zero or one `0x00`s are acceptable
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (byte === 0x01) {
|
|
79
|
-
// Remove all leading `0x00`s and this `0x01`
|
|
80
|
-
writeIndex -= lastZeroCount + 1;
|
|
81
|
-
// Found another NAL unit
|
|
82
|
-
yield buffer.subarray(start, writeIndex);
|
|
83
|
-
start = writeIndex;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (lastZeroCount > 2) {
|
|
87
|
-
// Too much `0x00`s
|
|
88
|
-
throw new Error("Invalid data");
|
|
89
|
-
}
|
|
90
|
-
switch (byte) {
|
|
91
|
-
case 0x02:
|
|
92
|
-
// Didn't find why, but 7.4.1 NAL unit semantics forbids `0x000002` appearing in NAL units
|
|
93
|
-
throw new Error("Invalid data");
|
|
94
|
-
case 0x03:
|
|
95
|
-
// `0x000003` is the "emulation_prevention_three_byte"
|
|
96
|
-
// `0x00000300`, `0x00000301`, `0x00000302` and `0x00000303` represent
|
|
97
|
-
// `0x000000`, `0x000001`, `0x000002` and `0x000003` respectively
|
|
98
|
-
// Remove current byte
|
|
99
|
-
writeIndex -= 1;
|
|
100
|
-
inEmulation = true;
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
// `0x000004` or larger are ok
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (inEmulation || zeroCount !== 0) {
|
|
108
|
-
throw new Error("Invalid data");
|
|
109
|
-
}
|
|
110
|
-
yield buffer.subarray(start, writeIndex);
|
|
111
|
-
}
|
|
112
|
-
// 7.3.2.1.1 Sequence parameter set data syntax
|
|
113
|
-
export function parse_sequence_parameter_set(buffer) {
|
|
114
|
-
for (const nalu of iterateNalu(new Uint8Array(buffer))) {
|
|
115
|
-
const reader = new BitReader(nalu);
|
|
116
|
-
if (reader.next() !== 0) {
|
|
117
|
-
throw new Error("Invalid data");
|
|
118
|
-
}
|
|
119
|
-
const nal_ref_idc = reader.read(2);
|
|
120
|
-
const nal_unit_type = reader.read(5);
|
|
121
|
-
if (nal_unit_type !== 7) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (nal_ref_idc === 0) {
|
|
125
|
-
throw new Error("Invalid data");
|
|
126
|
-
}
|
|
127
|
-
const profile_idc = reader.read(8);
|
|
128
|
-
const constraint_set = reader.read(8);
|
|
129
|
-
const constraint_set_reader = new BitReader(new Uint8Array([constraint_set]));
|
|
130
|
-
const constraint_set0_flag = !!constraint_set_reader.next();
|
|
131
|
-
const constraint_set1_flag = !!constraint_set_reader.next();
|
|
132
|
-
const constraint_set2_flag = !!constraint_set_reader.next();
|
|
133
|
-
const constraint_set3_flag = !!constraint_set_reader.next();
|
|
134
|
-
const constraint_set4_flag = !!constraint_set_reader.next();
|
|
135
|
-
const constraint_set5_flag = !!constraint_set_reader.next();
|
|
136
|
-
// reserved_zero_2bits
|
|
137
|
-
if (constraint_set_reader.read(2) !== 0) {
|
|
138
|
-
throw new Error("Invalid data");
|
|
139
|
-
}
|
|
140
|
-
const level_idc = reader.read(8);
|
|
141
|
-
const seq_parameter_set_id = reader.decodeExponentialGolombNumber();
|
|
142
|
-
if (profile_idc === 100 ||
|
|
143
|
-
profile_idc === 110 ||
|
|
144
|
-
profile_idc === 122 ||
|
|
145
|
-
profile_idc === 244 ||
|
|
146
|
-
profile_idc === 44 ||
|
|
147
|
-
profile_idc === 83 ||
|
|
148
|
-
profile_idc === 86 ||
|
|
149
|
-
profile_idc === 118 ||
|
|
150
|
-
profile_idc === 128 ||
|
|
151
|
-
profile_idc === 138 ||
|
|
152
|
-
profile_idc === 139 ||
|
|
153
|
-
profile_idc === 134) {
|
|
154
|
-
const chroma_format_idc = reader.decodeExponentialGolombNumber();
|
|
155
|
-
if (chroma_format_idc === 3) {
|
|
156
|
-
// separate_colour_plane_flag
|
|
157
|
-
reader.next();
|
|
158
|
-
}
|
|
159
|
-
// bit_depth_luma_minus8
|
|
160
|
-
reader.decodeExponentialGolombNumber();
|
|
161
|
-
// bit_depth_chroma_minus8
|
|
162
|
-
reader.decodeExponentialGolombNumber();
|
|
163
|
-
// qpprime_y_zero_transform_bypass_flag
|
|
164
|
-
reader.next();
|
|
165
|
-
const seq_scaling_matrix_present_flag = !!reader.next();
|
|
166
|
-
if (seq_scaling_matrix_present_flag) {
|
|
167
|
-
const seq_scaling_list_present_flag = [];
|
|
168
|
-
for (let i = 0; i < (chroma_format_idc !== 3 ? 8 : 12); i += 1) {
|
|
169
|
-
seq_scaling_list_present_flag[i] = !!reader.next();
|
|
170
|
-
if (seq_scaling_list_present_flag[i])
|
|
171
|
-
if (i < 6) {
|
|
172
|
-
// TODO
|
|
173
|
-
// scaling_list( ScalingList4x4[ i ], 16,
|
|
174
|
-
// UseDefaultScalingMatrix4x4Flag[ i ])
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
// TODO
|
|
178
|
-
// scaling_list( ScalingList8x8[ i − 6 ], 64,
|
|
179
|
-
// UseDefaultScalingMatrix8x8Flag[ i − 6 ] )
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// log2_max_frame_num_minus4
|
|
185
|
-
reader.decodeExponentialGolombNumber();
|
|
186
|
-
const pic_order_cnt_type = reader.decodeExponentialGolombNumber();
|
|
187
|
-
if (pic_order_cnt_type === 0) {
|
|
188
|
-
// log2_max_pic_order_cnt_lsb_minus4
|
|
189
|
-
reader.decodeExponentialGolombNumber();
|
|
190
|
-
}
|
|
191
|
-
else if (pic_order_cnt_type === 1) {
|
|
192
|
-
// delta_pic_order_always_zero_flag
|
|
193
|
-
reader.next();
|
|
194
|
-
// offset_for_non_ref_pic
|
|
195
|
-
reader.decodeExponentialGolombNumber();
|
|
196
|
-
// offset_for_top_to_bottom_field
|
|
197
|
-
reader.decodeExponentialGolombNumber();
|
|
198
|
-
const num_ref_frames_in_pic_order_cnt_cycle = reader.decodeExponentialGolombNumber();
|
|
199
|
-
const offset_for_ref_frame = [];
|
|
200
|
-
for (let i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i += 1) {
|
|
201
|
-
offset_for_ref_frame[i] =
|
|
202
|
-
reader.decodeExponentialGolombNumber();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// max_num_ref_frames
|
|
206
|
-
reader.decodeExponentialGolombNumber();
|
|
207
|
-
// gaps_in_frame_num_value_allowed_flag
|
|
208
|
-
reader.next();
|
|
209
|
-
const pic_width_in_mbs_minus1 = reader.decodeExponentialGolombNumber();
|
|
210
|
-
const pic_height_in_map_units_minus1 = reader.decodeExponentialGolombNumber();
|
|
211
|
-
const frame_mbs_only_flag = reader.next();
|
|
212
|
-
if (!frame_mbs_only_flag) {
|
|
213
|
-
// mb_adaptive_frame_field_flag
|
|
214
|
-
reader.next();
|
|
215
|
-
}
|
|
216
|
-
// direct_8x8_inference_flag
|
|
217
|
-
reader.next();
|
|
218
|
-
const frame_cropping_flag = !!reader.next();
|
|
219
|
-
let frame_crop_left_offset;
|
|
220
|
-
let frame_crop_right_offset;
|
|
221
|
-
let frame_crop_top_offset;
|
|
222
|
-
let frame_crop_bottom_offset;
|
|
223
|
-
if (frame_cropping_flag) {
|
|
224
|
-
frame_crop_left_offset = reader.decodeExponentialGolombNumber();
|
|
225
|
-
frame_crop_right_offset = reader.decodeExponentialGolombNumber();
|
|
226
|
-
frame_crop_top_offset = reader.decodeExponentialGolombNumber();
|
|
227
|
-
frame_crop_bottom_offset = reader.decodeExponentialGolombNumber();
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
frame_crop_left_offset = 0;
|
|
231
|
-
frame_crop_right_offset = 0;
|
|
232
|
-
frame_crop_top_offset = 0;
|
|
233
|
-
frame_crop_bottom_offset = 0;
|
|
234
|
-
}
|
|
235
|
-
const vui_parameters_present_flag = !!reader.next();
|
|
236
|
-
if (vui_parameters_present_flag) {
|
|
237
|
-
// TODO
|
|
238
|
-
// vui_parameters( )
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
profile_idc,
|
|
242
|
-
constraint_set,
|
|
243
|
-
constraint_set0_flag,
|
|
244
|
-
constraint_set1_flag,
|
|
245
|
-
constraint_set2_flag,
|
|
246
|
-
constraint_set3_flag,
|
|
247
|
-
constraint_set4_flag,
|
|
248
|
-
constraint_set5_flag,
|
|
249
|
-
level_idc,
|
|
250
|
-
seq_parameter_set_id,
|
|
251
|
-
pic_width_in_mbs_minus1,
|
|
252
|
-
pic_height_in_map_units_minus1,
|
|
253
|
-
frame_mbs_only_flag,
|
|
254
|
-
frame_cropping_flag,
|
|
255
|
-
frame_crop_left_offset,
|
|
256
|
-
frame_crop_right_offset,
|
|
257
|
-
frame_crop_top_offset,
|
|
258
|
-
frame_crop_bottom_offset,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
throw new Error("Invalid data");
|
|
262
|
-
}
|
|
263
|
-
//# sourceMappingURL=sps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sps.js","sourceRoot":"","sources":["../../../src/options/1_16/sps.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,yBAAyB;AAEzB,MAAM,SAAS;IACH,MAAM,CAAa;IAEnB,YAAY,GAAG,CAAC,CAAC;IAEjB,WAAW,GAAG,CAAC,CAAC;IAExB,YAAmB,MAAkB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,IAAI,CAAC,MAAc;QACtB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAChC,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,IAAI;QACP,MAAM,KAAK,GACP,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;SACxB;QACD,OAAO,KAAK,CA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AAC;QAClC,IAAI,wBAAgC,CAAC;QACrC,IAAI,mBAAmB,EAAE;YACrB,sBAAsB,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAC;YAChE,uBAAuB,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAC;YACjE,qBAAqB,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAC;YAC/D,wBAAwB,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAC;SACrE;aAAM;YACH,sBAAsB,GAAG,CAAC,CAAC;YAC3B,uBAAuB,GAAG,CAAC,CAAC;YAC5B,qBAAqB,GAAG,CAAC,CAAC;YAC1B,wBAAwB,GAAG,CAAC,CAAC;SAChC;QAED,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACpD,IAAI,2BAA2B,EAAE;YAC7B,OAAO;YACP,oBAAoB;SACvB;QAED,OAAO;YACH,WAAW;YACX,cAAc;YACd,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,SAAS;YACT,oBAAoB;YACpB,uBAAuB;YACvB,8BAA8B;YAC9B,mBAAmB;YACnB,mBAAmB;YACnB,sBAAsB;YACtB,uBAAuB;YACvB,qBAAqB;YACrB,wBAAwB;SAC3B,CAAC;KACL;IAED,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC"}
|
package/src/adb/client.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdbSubprocessNoneProtocol,
|
|
3
|
-
type Adb,
|
|
4
|
-
type AdbSubprocessProtocol,
|
|
5
|
-
type AdbSync,
|
|
6
|
-
} from "@yume-chan/adb";
|
|
7
|
-
import {
|
|
8
|
-
AbortController,
|
|
9
|
-
DecodeUtf8Stream,
|
|
10
|
-
InspectStream,
|
|
11
|
-
ReadableStream,
|
|
12
|
-
SplitStringStream,
|
|
13
|
-
WrapWritableStream,
|
|
14
|
-
WritableStream,
|
|
15
|
-
type ReadableStreamDefaultController,
|
|
16
|
-
type ReadableStreamDefaultReader,
|
|
17
|
-
type ReadableWritablePair,
|
|
18
|
-
} from "@yume-chan/stream-extra";
|
|
19
|
-
|
|
20
|
-
import { ScrcpyControlMessageSerializer } from "../control/index.js";
|
|
21
|
-
import {
|
|
22
|
-
ScrcpyDeviceMessageDeserializeStream,
|
|
23
|
-
type ScrcpyDeviceMessage,
|
|
24
|
-
} from "../device-message/index.js";
|
|
25
|
-
import {
|
|
26
|
-
DEFAULT_SERVER_PATH,
|
|
27
|
-
type ScrcpyVideoStreamPacket,
|
|
28
|
-
} from "../options/index.js";
|
|
29
|
-
|
|
30
|
-
import { type AdbScrcpyOptions } from "./options/index.js";
|
|
31
|
-
|
|
32
|
-
class ArrayToStream<T> extends ReadableStream<T> {
|
|
33
|
-
private array!: T[];
|
|
34
|
-
private index = 0;
|
|
35
|
-
|
|
36
|
-
constructor(array: T[]) {
|
|
37
|
-
super({
|
|
38
|
-
start: async () => {
|
|
39
|
-
await Promise.resolve();
|
|
40
|
-
this.array = array;
|
|
41
|
-
},
|
|
42
|
-
pull: (controller) => {
|
|
43
|
-
if (this.index < this.array.length) {
|
|
44
|
-
controller.enqueue(this.array[this.index]!);
|
|
45
|
-
this.index += 1;
|
|
46
|
-
} else {
|
|
47
|
-
controller.close();
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class ConcatStream<T> extends ReadableStream<T> {
|
|
55
|
-
private streams!: ReadableStream<T>[];
|
|
56
|
-
private index = 0;
|
|
57
|
-
private reader!: ReadableStreamDefaultReader<T>;
|
|
58
|
-
|
|
59
|
-
constructor(...streams: ReadableStream<T>[]) {
|
|
60
|
-
super({
|
|
61
|
-
start: async (controller) => {
|
|
62
|
-
await Promise.resolve();
|
|
63
|
-
|
|
64
|
-
this.streams = streams;
|
|
65
|
-
this.advance(controller);
|
|
66
|
-
},
|
|
67
|
-
pull: async (controller) => {
|
|
68
|
-
const result = await this.reader.read();
|
|
69
|
-
if (!result.done) {
|
|
70
|
-
controller.enqueue(result.value);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.advance(controller);
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private advance(controller: ReadableStreamDefaultController<T>) {
|
|
79
|
-
if (this.index < this.streams.length) {
|
|
80
|
-
this.reader = this.streams[this.index]!.getReader();
|
|
81
|
-
this.index += 1;
|
|
82
|
-
} else {
|
|
83
|
-
controller.close();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export class ScrcpyExitedError extends Error {
|
|
89
|
-
public output: string[];
|
|
90
|
-
|
|
91
|
-
public constructor(output: string[]) {
|
|
92
|
-
super("scrcpy server exited prematurely");
|
|
93
|
-
this.output = output;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export class AdbScrcpyClient {
|
|
98
|
-
public static pushServer(adb: Adb, path = DEFAULT_SERVER_PATH) {
|
|
99
|
-
let sync!: AdbSync;
|
|
100
|
-
return new WrapWritableStream<Uint8Array>({
|
|
101
|
-
async start() {
|
|
102
|
-
sync = await adb.sync();
|
|
103
|
-
return sync.write(path);
|
|
104
|
-
},
|
|
105
|
-
async close() {
|
|
106
|
-
await sync.dispose();
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public static async start(
|
|
112
|
-
adb: Adb,
|
|
113
|
-
path: string,
|
|
114
|
-
version: string,
|
|
115
|
-
options: AdbScrcpyOptions<object>
|
|
116
|
-
) {
|
|
117
|
-
const connection = options.createConnection(adb);
|
|
118
|
-
let process: AdbSubprocessProtocol | undefined;
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
await connection.initialize();
|
|
122
|
-
|
|
123
|
-
process = await adb.subprocess.spawn(
|
|
124
|
-
[
|
|
125
|
-
// cspell: disable-next-line
|
|
126
|
-
`CLASSPATH=${path}`,
|
|
127
|
-
"app_process",
|
|
128
|
-
/* unused */ "/",
|
|
129
|
-
"com.genymobile.scrcpy.Server",
|
|
130
|
-
version,
|
|
131
|
-
...options.formatServerArguments(),
|
|
132
|
-
],
|
|
133
|
-
{
|
|
134
|
-
// Scrcpy server doesn't use stderr,
|
|
135
|
-
// so disable Shell Protocol to simplify processing
|
|
136
|
-
protocols: [AdbSubprocessNoneProtocol],
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const stdout = process.stdout
|
|
141
|
-
.pipeThrough(new DecodeUtf8Stream())
|
|
142
|
-
.pipeThrough(new SplitStringStream("\n"));
|
|
143
|
-
|
|
144
|
-
// Read stdout, otherwise `process.exit` won't resolve.
|
|
145
|
-
const output: string[] = [];
|
|
146
|
-
const abortController = new AbortController();
|
|
147
|
-
const pipe = stdout
|
|
148
|
-
.pipeTo(
|
|
149
|
-
new WritableStream({
|
|
150
|
-
write(chunk) {
|
|
151
|
-
output.push(chunk);
|
|
152
|
-
},
|
|
153
|
-
}),
|
|
154
|
-
{
|
|
155
|
-
signal: abortController.signal,
|
|
156
|
-
preventCancel: true,
|
|
157
|
-
}
|
|
158
|
-
)
|
|
159
|
-
.catch((e) => {
|
|
160
|
-
void e;
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const result = await Promise.race([
|
|
164
|
-
process.exit,
|
|
165
|
-
connection.getStreams(),
|
|
166
|
-
]);
|
|
167
|
-
|
|
168
|
-
if (typeof result === "number") {
|
|
169
|
-
throw new ScrcpyExitedError(output);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
abortController.abort();
|
|
173
|
-
await pipe;
|
|
174
|
-
|
|
175
|
-
const [videoStream, controlStream] = result;
|
|
176
|
-
return new AdbScrcpyClient(
|
|
177
|
-
options,
|
|
178
|
-
process,
|
|
179
|
-
new ConcatStream(new ArrayToStream(output), stdout),
|
|
180
|
-
videoStream,
|
|
181
|
-
controlStream
|
|
182
|
-
);
|
|
183
|
-
} catch (e) {
|
|
184
|
-
await process?.kill();
|
|
185
|
-
throw e;
|
|
186
|
-
} finally {
|
|
187
|
-
connection.dispose();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* This method will modify the given `options`,
|
|
193
|
-
* so don't reuse it elsewhere.
|
|
194
|
-
*/
|
|
195
|
-
public static async getEncoders(
|
|
196
|
-
adb: Adb,
|
|
197
|
-
path: string,
|
|
198
|
-
version: string,
|
|
199
|
-
options: AdbScrcpyOptions<object>
|
|
200
|
-
): Promise<string[]> {
|
|
201
|
-
Object.assign(options.value, {
|
|
202
|
-
// Provide an invalid encoder name
|
|
203
|
-
// So the server will return all available encoders
|
|
204
|
-
encoderName: "_",
|
|
205
|
-
// Disable control for faster connection in 1.22+
|
|
206
|
-
control: false,
|
|
207
|
-
sendDeviceMeta: false,
|
|
208
|
-
sendDummyByte: false,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// Scrcpy server will open connections, before initializing encoder
|
|
212
|
-
// Thus although an invalid encoder name is given, the start process will success
|
|
213
|
-
const client = await AdbScrcpyClient.start(adb, path, version, options);
|
|
214
|
-
|
|
215
|
-
const encoderNameRegex = options.getOutputEncoderNameRegex();
|
|
216
|
-
const encoders: string[] = [];
|
|
217
|
-
await client.stdout.pipeTo(
|
|
218
|
-
new WritableStream({
|
|
219
|
-
write(line) {
|
|
220
|
-
const match = line.match(encoderNameRegex);
|
|
221
|
-
if (match) {
|
|
222
|
-
encoders.push(match[1]!);
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
return encoders;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* This method will modify the given `options`,
|
|
233
|
-
* so don't reuse it elsewhere.
|
|
234
|
-
*/
|
|
235
|
-
public static async getDisplays(
|
|
236
|
-
adb: Adb,
|
|
237
|
-
path: string,
|
|
238
|
-
version: string,
|
|
239
|
-
options: AdbScrcpyOptions<object>
|
|
240
|
-
): Promise<number[]> {
|
|
241
|
-
Object.assign(options.value, {
|
|
242
|
-
// Similar to `getEncoders`, pass an invalid option and parse the output
|
|
243
|
-
displayId: -1,
|
|
244
|
-
// Disable control for faster connection in 1.22+
|
|
245
|
-
control: false,
|
|
246
|
-
sendDeviceMeta: false,
|
|
247
|
-
sendDummyByte: false,
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
try {
|
|
251
|
-
// Server will exit before opening connections when an invalid display id was given.
|
|
252
|
-
await AdbScrcpyClient.start(adb, path, version, options);
|
|
253
|
-
} catch (e) {
|
|
254
|
-
if (e instanceof ScrcpyExitedError) {
|
|
255
|
-
const displayIdRegex = /\s+scrcpy --display (\d+)/;
|
|
256
|
-
const displays: number[] = [];
|
|
257
|
-
for (const line of e.output) {
|
|
258
|
-
const match = line.match(displayIdRegex);
|
|
259
|
-
if (match) {
|
|
260
|
-
displays.push(Number.parseInt(match[1]!, 10));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return displays;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
throw new Error("failed to get displays");
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
private process: AdbSubprocessProtocol;
|
|
271
|
-
|
|
272
|
-
private _stdout: ReadableStream<string>;
|
|
273
|
-
public get stdout() {
|
|
274
|
-
return this._stdout;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public get exit() {
|
|
278
|
-
return this.process.exit;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
private _screenWidth: number | undefined;
|
|
282
|
-
public get screenWidth() {
|
|
283
|
-
return this._screenWidth;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
private _screenHeight: number | undefined;
|
|
287
|
-
public get screenHeight() {
|
|
288
|
-
return this._screenHeight;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private _videoStream: ReadableStream<ScrcpyVideoStreamPacket>;
|
|
292
|
-
public get videoStream() {
|
|
293
|
-
return this._videoStream;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
private _controlMessageSerializer:
|
|
297
|
-
| ScrcpyControlMessageSerializer
|
|
298
|
-
| undefined;
|
|
299
|
-
public get controlMessageSerializer() {
|
|
300
|
-
return this._controlMessageSerializer;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
private _deviceMessageStream:
|
|
304
|
-
| ReadableStream<ScrcpyDeviceMessage>
|
|
305
|
-
| undefined;
|
|
306
|
-
public get deviceMessageStream() {
|
|
307
|
-
return this._deviceMessageStream;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
public constructor(
|
|
311
|
-
options: AdbScrcpyOptions<object>,
|
|
312
|
-
process: AdbSubprocessProtocol,
|
|
313
|
-
stdout: ReadableStream<string>,
|
|
314
|
-
videoStream: ReadableStream<Uint8Array>,
|
|
315
|
-
controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined
|
|
316
|
-
) {
|
|
317
|
-
this.process = process;
|
|
318
|
-
this._stdout = stdout;
|
|
319
|
-
|
|
320
|
-
this._videoStream = videoStream
|
|
321
|
-
.pipeThrough(options.createVideoStreamTransformer())
|
|
322
|
-
.pipeThrough(
|
|
323
|
-
new InspectStream((packet) => {
|
|
324
|
-
if (packet.type === "configuration") {
|
|
325
|
-
this._screenWidth = packet.data.croppedWidth;
|
|
326
|
-
this._screenHeight = packet.data.croppedHeight;
|
|
327
|
-
}
|
|
328
|
-
})
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
if (controlStream) {
|
|
332
|
-
this._controlMessageSerializer = new ScrcpyControlMessageSerializer(
|
|
333
|
-
controlStream.writable,
|
|
334
|
-
options
|
|
335
|
-
);
|
|
336
|
-
this._deviceMessageStream = controlStream.readable.pipeThrough(
|
|
337
|
-
new ScrcpyDeviceMessageDeserializeStream()
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
public async close() {
|
|
343
|
-
await this.process.kill();
|
|
344
|
-
}
|
|
345
|
-
}
|