@yume-chan/scrcpy 0.0.16 → 0.0.17
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 +15 -0
- package/CHANGELOG.md +9 -1
- package/README.md +275 -38
- package/esm/adb/client.d.ts +40 -0
- package/esm/adb/client.d.ts.map +1 -0
- package/esm/adb/client.js +218 -0
- package/esm/adb/client.js.map +1 -0
- package/esm/adb/connection.d.ts +38 -0
- package/esm/adb/connection.d.ts.map +1 -0
- package/esm/{connection.js → adb/connection.js} +20 -24
- package/esm/adb/connection.js.map +1 -0
- package/esm/adb/index.d.ts +4 -0
- package/esm/adb/index.d.ts.map +1 -0
- package/esm/adb/index.js +4 -0
- package/esm/adb/index.js.map +1 -0
- package/esm/adb/options/1_16.d.ts +8 -0
- package/esm/adb/options/1_16.d.ts.map +1 -0
- package/esm/adb/options/1_16.js +20 -0
- package/esm/adb/options/1_16.js.map +1 -0
- package/esm/adb/options/1_22.d.ts +8 -0
- package/esm/adb/options/1_22.d.ts.map +1 -0
- package/esm/adb/options/1_22.js +17 -0
- package/esm/adb/options/1_22.js.map +1 -0
- package/esm/adb/options/index.d.ts +4 -0
- package/esm/adb/options/index.d.ts.map +1 -0
- package/esm/adb/options/index.js +4 -0
- package/esm/adb/options/index.js.map +1 -0
- package/esm/adb/options/types.d.ts +23 -0
- package/esm/adb/options/types.d.ts.map +1 -0
- package/esm/adb/options/types.js +30 -0
- package/esm/adb/options/types.js.map +1 -0
- package/esm/codec.js +2 -2
- package/esm/codec.js.map +1 -1
- package/esm/control/index.d.ts +8 -0
- package/esm/control/index.d.ts.map +1 -0
- package/esm/control/index.js +8 -0
- package/esm/control/index.js.map +1 -0
- package/esm/control/inject-keycode.d.ts +53 -0
- package/esm/control/inject-keycode.d.ts.map +1 -0
- package/esm/control/inject-keycode.js +54 -0
- package/esm/control/inject-keycode.js.map +1 -0
- package/esm/control/inject-text.d.ts +9 -0
- package/esm/control/inject-text.d.ts.map +1 -0
- package/esm/control/inject-text.js +7 -0
- package/esm/control/inject-text.js.map +1 -0
- package/esm/control/inject-touch.d.ts +30 -0
- package/esm/control/inject-touch.d.ts.map +1 -0
- package/esm/control/inject-touch.js +30 -0
- package/esm/control/inject-touch.js.map +1 -0
- package/esm/control/rotate-device.d.ts +7 -0
- package/esm/control/rotate-device.d.ts.map +1 -0
- package/esm/control/rotate-device.js +5 -0
- package/esm/control/rotate-device.js.map +1 -0
- package/esm/control/serializer.d.ts +23 -0
- package/esm/control/serializer.d.ts.map +1 -0
- package/esm/control/serializer.js +73 -0
- package/esm/control/serializer.js.map +1 -0
- package/esm/control/set-screen-power-mode.d.ts +12 -0
- package/esm/control/set-screen-power-mode.d.ts.map +1 -0
- package/esm/control/set-screen-power-mode.js +12 -0
- package/esm/control/set-screen-power-mode.js.map +1 -0
- package/esm/control/type.d.ts +15 -0
- package/esm/control/type.d.ts.map +1 -0
- package/esm/control/type.js +19 -0
- package/esm/control/type.js.map +1 -0
- package/esm/decoder/index.d.ts +27 -3
- package/esm/decoder/index.d.ts.map +1 -1
- package/esm/decoder/index.js +1 -3
- package/esm/decoder/index.js.map +1 -1
- package/esm/decoder/tinyh264/index.d.ts +5 -5
- package/esm/decoder/tinyh264/index.d.ts.map +1 -1
- package/esm/decoder/tinyh264/index.js +4 -4
- package/esm/decoder/tinyh264/index.js.map +1 -1
- package/esm/decoder/tinyh264/worker.js.map +1 -1
- package/esm/decoder/tinyh264/wrapper.d.ts.map +1 -1
- package/esm/decoder/tinyh264/wrapper.js +14 -8
- package/esm/decoder/tinyh264/wrapper.js.map +1 -1
- package/esm/decoder/types.d.ts +1 -27
- package/esm/decoder/types.d.ts.map +1 -1
- package/esm/decoder/web-codecs/index.d.ts +4 -4
- package/esm/decoder/web-codecs/index.d.ts.map +1 -1
- package/esm/decoder/web-codecs/index.js +1 -1
- package/esm/decoder/web-codecs/index.js.map +1 -1
- package/esm/device-message/clipboard.d.ts +10 -0
- package/esm/device-message/clipboard.d.ts.map +1 -0
- package/esm/device-message/clipboard.js +7 -0
- package/esm/device-message/clipboard.js.map +1 -0
- package/esm/device-message/index.d.ts +4 -0
- package/esm/device-message/index.d.ts.map +1 -0
- package/esm/device-message/index.js +4 -0
- package/esm/device-message/index.js.map +1 -0
- package/esm/device-message/stream.d.ts +7 -0
- package/esm/device-message/stream.d.ts.map +1 -0
- package/esm/device-message/stream.js +16 -0
- package/esm/device-message/stream.js.map +1 -0
- package/esm/device-message/type.d.ts +5 -0
- package/esm/device-message/type.d.ts.map +1 -0
- package/esm/device-message/type.js +7 -0
- package/esm/device-message/type.js.map +1 -0
- package/esm/index.d.ts +3 -6
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -6
- package/esm/index.js.map +1 -1
- package/esm/options/1_16/codec-options.d.ts +19 -0
- package/esm/options/1_16/codec-options.d.ts.map +1 -0
- package/esm/options/1_16/codec-options.js +27 -0
- package/esm/options/1_16/codec-options.js.map +1 -0
- package/esm/options/1_16/index.d.ts +3 -110
- package/esm/options/1_16/index.d.ts.map +1 -1
- package/esm/options/1_16/index.js +3 -226
- package/esm/options/1_16/index.js.map +1 -1
- package/esm/options/1_16/options.d.ts +97 -0
- package/esm/options/1_16/options.d.ts.map +1 -0
- package/esm/options/1_16/options.js +188 -0
- package/esm/options/1_16/options.js.map +1 -0
- package/esm/options/1_18.d.ts +8 -8
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +6 -6
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.d.ts +1 -1
- package/esm/options/1_21.d.ts.map +1 -1
- package/esm/options/1_21.js +1 -1
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22.d.ts +5 -8
- package/esm/options/1_22.d.ts.map +1 -1
- package/esm/options/1_22.js +4 -17
- package/esm/options/1_22.js.map +1 -1
- package/esm/options/1_23.d.ts +4 -4
- package/esm/options/1_23.d.ts.map +1 -1
- package/esm/options/1_23.js +1 -1
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts +1 -1
- package/esm/options/1_24.d.ts.map +1 -1
- package/esm/options/1_24.js.map +1 -1
- package/esm/options/index.d.ts +1 -1
- package/esm/options/index.d.ts.map +1 -1
- package/esm/options/index.js +1 -1
- package/esm/options/index.js.map +1 -1
- package/esm/options/types.d.ts +45 -0
- package/esm/options/types.d.ts.map +1 -0
- package/esm/options/{common.js → types.js} +1 -1
- package/esm/options/types.js.map +1 -0
- package/package.json +24 -24
- package/src/adb/client.ts +292 -0
- package/src/{connection.ts → adb/connection.ts} +35 -38
- package/src/adb/index.ts +3 -0
- package/src/adb/options/1_16.ts +23 -0
- package/src/adb/options/1_22.ts +20 -0
- package/src/adb/options/index.ts +3 -0
- package/src/adb/options/types.ts +55 -0
- package/src/control/index.ts +7 -0
- package/src/control/inject-keycode.ts +59 -0
- package/src/control/inject-text.ts +12 -0
- package/src/control/inject-touch.ts +34 -0
- package/src/control/rotate-device.ts +10 -0
- package/src/control/serializer.ts +86 -0
- package/src/control/set-screen-power-mode.ts +17 -0
- package/src/control/type.ts +17 -0
- package/src/device-message/clipboard.ts +11 -0
- package/src/device-message/index.ts +3 -0
- package/src/device-message/stream.ts +19 -0
- package/src/device-message/type.ts +5 -0
- package/src/index.ts +3 -6
- package/src/options/1_16/codec-options.ts +48 -0
- package/src/options/1_16/index.ts +3 -345
- package/src/options/1_16/options.ts +294 -0
- package/src/options/1_18.ts +12 -10
- package/src/options/1_21.ts +16 -6
- package/src/options/1_22.ts +10 -21
- package/src/options/1_23.ts +7 -5
- package/src/options/1_24.ts +3 -2
- package/src/options/index.ts +1 -1
- package/src/options/{common.ts → types.ts} +32 -13
- package/tsconfig.build.json +3 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.test.tsbuildinfo +1 -0
- package/esm/client.d.ts +0 -48
- package/esm/client.d.ts.map +0 -1
- package/esm/client.js +0 -341
- package/esm/client.js.map +0 -1
- package/esm/connection.d.ts +0 -37
- package/esm/connection.d.ts.map +0 -1
- package/esm/connection.js.map +0 -1
- package/esm/message.d.ts +0 -98
- package/esm/message.d.ts.map +0 -1
- package/esm/message.js +0 -98
- package/esm/message.js.map +0 -1
- package/esm/options/common.d.ts +0 -34
- package/esm/options/common.d.ts.map +0 -1
- package/esm/options/common.js.map +0 -1
- package/esm/push-server.d.ts +0 -6
- package/esm/push-server.d.ts.map +0 -1
- package/esm/push-server.js +0 -16
- package/esm/push-server.js.map +0 -1
- package/esm/utils.d.ts +0 -2
- package/esm/utils.d.ts.map +0 -1
- package/esm/utils.js +0 -6
- package/esm/utils.js.map +0 -1
- package/src/client.ts +0 -435
- package/src/decoder/index.ts +0 -3
- package/src/decoder/tinyh264/index.ts +0 -112
- package/src/decoder/tinyh264/types.d.ts +0 -137
- package/src/decoder/tinyh264/worker.ts +0 -2
- package/src/decoder/tinyh264/wrapper.ts +0 -89
- package/src/decoder/types.ts +0 -35
- package/src/decoder/web-codecs/index.ts +0 -99
- package/src/message.ts +0 -113
- package/src/push-server.ts +0 -24
- package/src/utils.ts +0 -5
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { StructDeserializeStream, TransformStream } from '@yume-chan/stream-extra';
|
|
2
|
+
import Struct from '@yume-chan/struct';
|
|
3
|
+
|
|
4
|
+
import { AndroidKeyEventAction, ScrcpyControlMessageType } from '../../control/index.js';
|
|
5
|
+
import type { ScrcpyBackOrScreenOnControlMessage1_18 } from '../1_18.js';
|
|
6
|
+
import type { ScrcpyInjectScrollControlMessage1_22 } from '../1_22.js';
|
|
7
|
+
import { toScrcpyOptionValue, type ScrcpyOptions, type ScrcpyVideoStreamPacket } from '../types.js';
|
|
8
|
+
import { CodecOptions } from './codec-options.js';
|
|
9
|
+
import { parse_sequence_parameter_set } from './sps.js';
|
|
10
|
+
|
|
11
|
+
export enum ScrcpyLogLevel {
|
|
12
|
+
Verbose = 'verbose',
|
|
13
|
+
Debug = 'debug',
|
|
14
|
+
Info = 'info',
|
|
15
|
+
Warn = 'warn',
|
|
16
|
+
Error = 'error',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum ScrcpyVideoOrientation {
|
|
20
|
+
Initial = -2,
|
|
21
|
+
Unlocked = -1,
|
|
22
|
+
Portrait = 0,
|
|
23
|
+
Landscape = 1,
|
|
24
|
+
PortraitFlipped = 2,
|
|
25
|
+
LandscapeFlipped = 3,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ScrcpyOptionsInit1_16 {
|
|
29
|
+
logLevel: ScrcpyLogLevel;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The maximum value of both width and height.
|
|
33
|
+
*/
|
|
34
|
+
maxSize: number;
|
|
35
|
+
|
|
36
|
+
bitRate: number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 0 for unlimited.
|
|
40
|
+
*
|
|
41
|
+
* @default 0
|
|
42
|
+
*/
|
|
43
|
+
maxFps: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The orientation of the video stream.
|
|
47
|
+
*
|
|
48
|
+
* It will not keep the device screen in specific orientation,
|
|
49
|
+
* only the captured video will in this orientation.
|
|
50
|
+
*/
|
|
51
|
+
lockVideoOrientation: ScrcpyVideoOrientation;
|
|
52
|
+
|
|
53
|
+
tunnelForward: boolean;
|
|
54
|
+
|
|
55
|
+
crop: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Send PTS so that the client may record properly
|
|
59
|
+
*
|
|
60
|
+
* Note: When `sendFrameMeta: false` is specified,
|
|
61
|
+
* `onChangeEncoding` event won't fire and `onVideoData` event doesn't
|
|
62
|
+
* merge sps/pps frame and first video frame. Which means you can't use
|
|
63
|
+
* the shipped decoders to render the video
|
|
64
|
+
* (You can still record the stream into a file).
|
|
65
|
+
*
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
sendFrameMeta: boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
control: boolean;
|
|
74
|
+
|
|
75
|
+
displayId: number;
|
|
76
|
+
|
|
77
|
+
showTouches: boolean;
|
|
78
|
+
|
|
79
|
+
stayAwake: boolean;
|
|
80
|
+
|
|
81
|
+
codecOptions: CodecOptions;
|
|
82
|
+
|
|
83
|
+
encoderName: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const VideoPacket =
|
|
87
|
+
new Struct()
|
|
88
|
+
.uint64('pts')
|
|
89
|
+
.uint32('size')
|
|
90
|
+
.uint8Array('data', { lengthField: 'size' });
|
|
91
|
+
|
|
92
|
+
export const NO_PTS = BigInt(1) << BigInt(63);
|
|
93
|
+
|
|
94
|
+
export const ScrcpyBackOrScreenOnControlMessage1_16 =
|
|
95
|
+
new Struct()
|
|
96
|
+
.uint8('type', ScrcpyControlMessageType.BackOrScreenOn as const);
|
|
97
|
+
|
|
98
|
+
export const ScrcpyInjectScrollControlMessage1_16 =
|
|
99
|
+
new Struct()
|
|
100
|
+
.uint8('type', ScrcpyControlMessageType.InjectScroll as const)
|
|
101
|
+
.uint32('pointerX')
|
|
102
|
+
.uint32('pointerY')
|
|
103
|
+
.uint16('screenWidth')
|
|
104
|
+
.uint16('screenHeight')
|
|
105
|
+
.int32('scrollX')
|
|
106
|
+
.int32('scrollY');
|
|
107
|
+
|
|
108
|
+
export class ScrcpyOptions1_16<T extends ScrcpyOptionsInit1_16 = ScrcpyOptionsInit1_16>
|
|
109
|
+
implements ScrcpyOptions<T> {
|
|
110
|
+
public value: Partial<T>;
|
|
111
|
+
|
|
112
|
+
public constructor(value: Partial<ScrcpyOptionsInit1_16>) {
|
|
113
|
+
if (new.target === ScrcpyOptions1_16 &&
|
|
114
|
+
value.logLevel === ScrcpyLogLevel.Verbose) {
|
|
115
|
+
value.logLevel = ScrcpyLogLevel.Debug;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (new.target === ScrcpyOptions1_16 &&
|
|
119
|
+
value.lockVideoOrientation === ScrcpyVideoOrientation.Initial) {
|
|
120
|
+
value.lockVideoOrientation = ScrcpyVideoOrientation.Unlocked;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.value = value as Partial<T>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
protected getArgumentOrder(): (keyof T)[] {
|
|
127
|
+
return [
|
|
128
|
+
'logLevel',
|
|
129
|
+
'maxSize',
|
|
130
|
+
'bitRate',
|
|
131
|
+
'maxFps',
|
|
132
|
+
'lockVideoOrientation',
|
|
133
|
+
'tunnelForward',
|
|
134
|
+
'crop',
|
|
135
|
+
'sendFrameMeta',
|
|
136
|
+
'control',
|
|
137
|
+
'displayId',
|
|
138
|
+
'showTouches',
|
|
139
|
+
'stayAwake',
|
|
140
|
+
'codecOptions',
|
|
141
|
+
'encoderName',
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public getDefaultValue(): T {
|
|
146
|
+
return {
|
|
147
|
+
logLevel: ScrcpyLogLevel.Debug,
|
|
148
|
+
maxSize: 0,
|
|
149
|
+
bitRate: 8_000_000,
|
|
150
|
+
maxFps: 0,
|
|
151
|
+
lockVideoOrientation: ScrcpyVideoOrientation.Unlocked,
|
|
152
|
+
tunnelForward: false,
|
|
153
|
+
crop: '-',
|
|
154
|
+
sendFrameMeta: true,
|
|
155
|
+
control: true,
|
|
156
|
+
displayId: 0,
|
|
157
|
+
showTouches: false,
|
|
158
|
+
stayAwake: false,
|
|
159
|
+
codecOptions: new CodecOptions({}),
|
|
160
|
+
encoderName: '-',
|
|
161
|
+
} as T;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public formatServerArguments(): string[] {
|
|
165
|
+
const defaults = this.getDefaultValue();
|
|
166
|
+
return this.getArgumentOrder()
|
|
167
|
+
.map(
|
|
168
|
+
key =>
|
|
169
|
+
toScrcpyOptionValue(this.value[key] || defaults[key], '-')
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public getOutputEncoderNameRegex(): RegExp {
|
|
174
|
+
return /\s+scrcpy --encoder-name '(.*?)'/;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public createVideoStreamTransformer(): TransformStream<Uint8Array, ScrcpyVideoStreamPacket> {
|
|
178
|
+
// Optimized path for video frames only
|
|
179
|
+
if (this.value.sendFrameMeta === false) {
|
|
180
|
+
return new TransformStream({
|
|
181
|
+
transform(chunk, controller) {
|
|
182
|
+
controller.enqueue({
|
|
183
|
+
type: 'frame',
|
|
184
|
+
data: chunk,
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let header: Uint8Array | undefined;
|
|
191
|
+
|
|
192
|
+
let deserializeStream = new StructDeserializeStream(VideoPacket);
|
|
193
|
+
return {
|
|
194
|
+
writable: deserializeStream.writable,
|
|
195
|
+
readable: deserializeStream.readable.pipeThrough(new TransformStream({
|
|
196
|
+
transform(packet, controller) {
|
|
197
|
+
if (packet.pts === NO_PTS) {
|
|
198
|
+
const sequenceParameterSet = parse_sequence_parameter_set(packet.data.slice().buffer);
|
|
199
|
+
|
|
200
|
+
const {
|
|
201
|
+
profile_idc: profileIndex,
|
|
202
|
+
constraint_set: constraintSet,
|
|
203
|
+
level_idc: levelIndex,
|
|
204
|
+
pic_width_in_mbs_minus1,
|
|
205
|
+
pic_height_in_map_units_minus1,
|
|
206
|
+
frame_mbs_only_flag,
|
|
207
|
+
frame_crop_left_offset,
|
|
208
|
+
frame_crop_right_offset,
|
|
209
|
+
frame_crop_top_offset,
|
|
210
|
+
frame_crop_bottom_offset,
|
|
211
|
+
} = sequenceParameterSet;
|
|
212
|
+
|
|
213
|
+
const encodedWidth = (pic_width_in_mbs_minus1 + 1) * 16;
|
|
214
|
+
const encodedHeight = (pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag) * 16;
|
|
215
|
+
const cropLeft = frame_crop_left_offset * 2;
|
|
216
|
+
const cropRight = frame_crop_right_offset * 2;
|
|
217
|
+
const cropTop = frame_crop_top_offset * 2;
|
|
218
|
+
const cropBottom = frame_crop_bottom_offset * 2;
|
|
219
|
+
|
|
220
|
+
const croppedWidth = encodedWidth - cropLeft - cropRight;
|
|
221
|
+
const croppedHeight = encodedHeight - cropTop - cropBottom;
|
|
222
|
+
|
|
223
|
+
header = packet.data;
|
|
224
|
+
controller.enqueue({
|
|
225
|
+
type: 'configuration',
|
|
226
|
+
data: {
|
|
227
|
+
profileIndex,
|
|
228
|
+
constraintSet,
|
|
229
|
+
levelIndex,
|
|
230
|
+
encodedWidth,
|
|
231
|
+
encodedHeight,
|
|
232
|
+
cropLeft,
|
|
233
|
+
cropRight,
|
|
234
|
+
cropTop,
|
|
235
|
+
cropBottom,
|
|
236
|
+
croppedWidth,
|
|
237
|
+
croppedHeight,
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
let frameData: Uint8Array;
|
|
244
|
+
if (header) {
|
|
245
|
+
frameData = new Uint8Array(header.byteLength + packet.data.byteLength);
|
|
246
|
+
frameData.set(header);
|
|
247
|
+
frameData.set(packet.data, header.byteLength);
|
|
248
|
+
header = undefined;
|
|
249
|
+
} else {
|
|
250
|
+
frameData = packet.data;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
controller.enqueue({
|
|
254
|
+
type: 'frame',
|
|
255
|
+
pts: packet.pts,
|
|
256
|
+
data: frameData,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}))
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public getControlMessageTypes(): ScrcpyControlMessageType[] {
|
|
264
|
+
return [
|
|
265
|
+
/* 0 */ ScrcpyControlMessageType.InjectKeyCode,
|
|
266
|
+
/* 1 */ ScrcpyControlMessageType.InjectText,
|
|
267
|
+
/* 2 */ ScrcpyControlMessageType.InjectTouch,
|
|
268
|
+
/* 3 */ ScrcpyControlMessageType.InjectScroll,
|
|
269
|
+
/* 4 */ ScrcpyControlMessageType.BackOrScreenOn,
|
|
270
|
+
/* 5 */ ScrcpyControlMessageType.ExpandNotificationPanel,
|
|
271
|
+
/* 6 */ ScrcpyControlMessageType.CollapseNotificationPanel,
|
|
272
|
+
/* 7 */ ScrcpyControlMessageType.GetClipboard,
|
|
273
|
+
/* 8 */ ScrcpyControlMessageType.SetClipboard,
|
|
274
|
+
/* 9 */ ScrcpyControlMessageType.SetScreenPowerMode,
|
|
275
|
+
/* 10 */ ScrcpyControlMessageType.RotateDevice,
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public serializeBackOrScreenOnControlMessage(
|
|
280
|
+
message: ScrcpyBackOrScreenOnControlMessage1_18,
|
|
281
|
+
) {
|
|
282
|
+
if (message.action === AndroidKeyEventAction.Down) {
|
|
283
|
+
return ScrcpyBackOrScreenOnControlMessage1_16.serialize(message);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public serializeInjectScrollControlMessage(
|
|
290
|
+
message: ScrcpyInjectScrollControlMessage1_22,
|
|
291
|
+
): Uint8Array {
|
|
292
|
+
return ScrcpyInjectScrollControlMessage1_16.serialize(message);
|
|
293
|
+
}
|
|
294
|
+
}
|
package/src/options/1_18.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import Struct, { placeholder } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import Struct, { placeholder } from '@yume-chan/struct';
|
|
2
|
+
|
|
3
|
+
import { AndroidKeyEventAction, ScrcpyControlMessageType } from '../control/index.js';
|
|
4
|
+
import { ScrcpyBackOrScreenOnControlMessage1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from './1_16/options.js';
|
|
4
5
|
|
|
5
6
|
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
|
|
6
7
|
powerOffOnClose: boolean;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const
|
|
10
|
+
export const ScrcpyBackOrScreenOnControlMessage1_18 =
|
|
10
11
|
new Struct()
|
|
11
|
-
.fields(
|
|
12
|
+
.fields(ScrcpyBackOrScreenOnControlMessage1_16)
|
|
12
13
|
.uint8('action', placeholder<AndroidKeyEventAction>());
|
|
13
14
|
|
|
14
|
-
export type
|
|
15
|
+
export type ScrcpyBackOrScreenOnControlMessage1_18 = typeof ScrcpyBackOrScreenOnControlMessage1_18['TInit'];
|
|
15
16
|
|
|
16
|
-
export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18>
|
|
17
|
+
export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18>
|
|
18
|
+
extends ScrcpyOptions1_16<T> {
|
|
17
19
|
constructor(value: Partial<ScrcpyOptionsInit1_18>) {
|
|
18
20
|
super(value);
|
|
19
21
|
}
|
|
@@ -22,7 +24,7 @@ export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsIn
|
|
|
22
24
|
return super.getArgumentOrder().concat(['powerOffOnClose']);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
public override getDefaultValue(): T {
|
|
26
28
|
return {
|
|
27
29
|
...super.getDefaultValue(),
|
|
28
30
|
powerOffOnClose: false,
|
|
@@ -54,8 +56,8 @@ export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsIn
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
public override serializeBackOrScreenOnControlMessage(
|
|
57
|
-
message:
|
|
59
|
+
message: ScrcpyBackOrScreenOnControlMessage1_18,
|
|
58
60
|
) {
|
|
59
|
-
return
|
|
61
|
+
return ScrcpyBackOrScreenOnControlMessage1_18.serialize(message);
|
|
60
62
|
}
|
|
61
63
|
}
|
package/src/options/1_21.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// cspell: ignore autosync
|
|
2
2
|
|
|
3
3
|
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
|
|
4
|
-
import { toScrcpyOptionValue } from
|
|
4
|
+
import { toScrcpyOptionValue } from './types.js';
|
|
5
5
|
|
|
6
6
|
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
|
|
7
7
|
clipboardAutosync?: boolean;
|
|
@@ -11,12 +11,13 @@ function toSnakeCase(input: string): string {
|
|
|
11
11
|
return input.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21>
|
|
14
|
+
export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21>
|
|
15
|
+
extends ScrcpyOptions1_18<T> {
|
|
15
16
|
public constructor(init: Partial<ScrcpyOptionsInit1_21>) {
|
|
16
17
|
super(init);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
public override getDefaultValue(): T {
|
|
20
21
|
return {
|
|
21
22
|
...super.getDefaultValue(),
|
|
22
23
|
clipboardAutosync: true,
|
|
@@ -27,8 +28,17 @@ export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsIn
|
|
|
27
28
|
// 1.21 changed the format of arguments
|
|
28
29
|
// So `getArgumentOrder()` is no longer needed
|
|
29
30
|
return Object.entries(this.value)
|
|
30
|
-
.map(
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
.map(
|
|
32
|
+
([key, value]) =>
|
|
33
|
+
[key, toScrcpyOptionValue(value, undefined)] as const
|
|
34
|
+
)
|
|
35
|
+
.filter(
|
|
36
|
+
(pair): pair is [string, string] =>
|
|
37
|
+
pair[1] !== undefined
|
|
38
|
+
)
|
|
39
|
+
.map(
|
|
40
|
+
([key, value]) =>
|
|
41
|
+
`${toSnakeCase(key)}=${value}`
|
|
42
|
+
);
|
|
33
43
|
}
|
|
34
44
|
}
|
package/src/options/1_22.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js";
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
|
|
3
|
+
import { ScrcpyInjectScrollControlMessage1_16 } from './1_16/options.js';
|
|
4
|
+
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from './1_21.js';
|
|
6
5
|
|
|
7
6
|
export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
|
8
7
|
downsizeOnError: boolean;
|
|
@@ -32,11 +31,13 @@ export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
|
|
32
31
|
export const ScrcpyInjectScrollControlMessage1_22 =
|
|
33
32
|
new Struct()
|
|
34
33
|
.fields(ScrcpyInjectScrollControlMessage1_16)
|
|
35
|
-
.int32(
|
|
34
|
+
.int32('buttons');
|
|
36
35
|
|
|
37
|
-
export type ScrcpyInjectScrollControlMessage1_22 =
|
|
36
|
+
export type ScrcpyInjectScrollControlMessage1_22 =
|
|
37
|
+
typeof ScrcpyInjectScrollControlMessage1_22['TInit'];
|
|
38
38
|
|
|
39
|
-
export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22>
|
|
39
|
+
export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22>
|
|
40
|
+
extends ScrcpyOptions1_21<T> {
|
|
40
41
|
public constructor(init: Partial<ScrcpyOptionsInit1_22>) {
|
|
41
42
|
if (init.rawVideoStream) {
|
|
42
43
|
// Set implied options for client-side processing
|
|
@@ -48,7 +49,7 @@ export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsIn
|
|
|
48
49
|
super(init);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
public override getDefaultValue(): T {
|
|
52
53
|
return {
|
|
53
54
|
...super.getDefaultValue(),
|
|
54
55
|
downsizeOnError: true,
|
|
@@ -58,18 +59,6 @@ export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsIn
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
public override createConnection(device: Adb): ScrcpyClientConnection {
|
|
62
|
-
const options = {
|
|
63
|
-
...this.getDefaultValue(),
|
|
64
|
-
...this.value,
|
|
65
|
-
};
|
|
66
|
-
if (this.value.tunnelForward) {
|
|
67
|
-
return new ScrcpyClientForwardConnection(device, options);
|
|
68
|
-
} else {
|
|
69
|
-
return new ScrcpyClientReverseConnection(device, options);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
62
|
public override serializeInjectScrollControlMessage(
|
|
74
63
|
message: ScrcpyInjectScrollControlMessage1_22,
|
|
75
64
|
): Uint8Array {
|
package/src/options/1_23.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { TransformStream } from
|
|
1
|
+
import { TransformStream } from '@yume-chan/stream-extra';
|
|
2
|
+
|
|
2
3
|
import { ScrcpyOptions1_22, type ScrcpyOptionsInit1_22 } from './1_22.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { ScrcpyVideoStreamPacket } from './types.js';
|
|
4
5
|
|
|
5
6
|
export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
|
|
6
7
|
cleanup: boolean;
|
|
@@ -8,19 +9,20 @@ export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
|
|
|
8
9
|
|
|
9
10
|
const KEYFRAME_PTS = BigInt(1) << BigInt(62);
|
|
10
11
|
|
|
11
|
-
export class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23>
|
|
12
|
+
export class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23>
|
|
13
|
+
extends ScrcpyOptions1_22<T> {
|
|
12
14
|
public constructor(init: Partial<ScrcpyOptionsInit1_23>) {
|
|
13
15
|
super(init);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
public override getDefaultValue(): T {
|
|
17
19
|
return {
|
|
18
20
|
...super.getDefaultValue(),
|
|
19
21
|
cleanup: true,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
public override createVideoStreamTransformer(): TransformStream<Uint8Array,
|
|
25
|
+
public override createVideoStreamTransformer(): TransformStream<Uint8Array, ScrcpyVideoStreamPacket> {
|
|
24
26
|
const superStream = super.createVideoStreamTransformer();
|
|
25
27
|
return {
|
|
26
28
|
writable: superStream.writable,
|
package/src/options/1_24.ts
CHANGED
|
@@ -4,12 +4,13 @@ export interface ScrcpyOptionsInit1_24 extends ScrcpyOptionsInit1_23 {
|
|
|
4
4
|
powerOn: boolean;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24>
|
|
7
|
+
export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24>
|
|
8
|
+
extends ScrcpyOptions1_23<T> {
|
|
8
9
|
public constructor(init: Partial<ScrcpyOptionsInit1_24>) {
|
|
9
10
|
super(init);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
public override getDefaultValue(): T {
|
|
13
14
|
return {
|
|
14
15
|
...super.getDefaultValue(),
|
|
15
16
|
powerOn: true,
|
package/src/options/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22.js";
|
|
1
|
+
import type { TransformStream } from '@yume-chan/stream-extra';
|
|
2
|
+
|
|
3
|
+
import type { ScrcpyControlMessageType } from '../control/index.js';
|
|
4
|
+
import type { ScrcpyBackOrScreenOnControlMessage1_18 } from './1_18.js';
|
|
5
|
+
import type { ScrcpyInjectScrollControlMessage1_22 } from './1_22.js';
|
|
7
6
|
|
|
8
7
|
export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
|
|
9
8
|
|
|
@@ -29,35 +28,55 @@ export function toScrcpyOptionValue<T>(value: any, empty: T): string | T {
|
|
|
29
28
|
return `${value}`;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
export interface
|
|
31
|
+
export interface H264Configuration {
|
|
32
|
+
profileIndex: number;
|
|
33
|
+
constraintSet: number;
|
|
34
|
+
levelIndex: number;
|
|
35
|
+
|
|
36
|
+
encodedWidth: number;
|
|
37
|
+
encodedHeight: number;
|
|
38
|
+
|
|
39
|
+
cropLeft: number;
|
|
40
|
+
cropRight: number;
|
|
41
|
+
|
|
42
|
+
cropTop: number;
|
|
43
|
+
cropBottom: number;
|
|
44
|
+
|
|
45
|
+
croppedWidth: number;
|
|
46
|
+
croppedHeight: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ScrcpyVideoStreamConfigurationPacket {
|
|
33
50
|
type: 'configuration';
|
|
34
51
|
data: H264Configuration;
|
|
35
52
|
}
|
|
36
53
|
|
|
37
|
-
export interface
|
|
54
|
+
export interface ScrcpyVideoStreamFramePacket {
|
|
38
55
|
type: 'frame';
|
|
39
56
|
keyframe?: boolean | undefined;
|
|
40
57
|
pts?: bigint | undefined;
|
|
41
58
|
data: Uint8Array;
|
|
42
59
|
}
|
|
43
60
|
|
|
44
|
-
export type
|
|
61
|
+
export type ScrcpyVideoStreamPacket =
|
|
62
|
+
| ScrcpyVideoStreamConfigurationPacket
|
|
63
|
+
| ScrcpyVideoStreamFramePacket;
|
|
45
64
|
|
|
46
65
|
export interface ScrcpyOptions<T> {
|
|
47
66
|
value: Partial<T>;
|
|
48
67
|
|
|
68
|
+
getDefaultValue(): T;
|
|
69
|
+
|
|
49
70
|
formatServerArguments(): string[];
|
|
50
71
|
|
|
51
72
|
getOutputEncoderNameRegex(): RegExp;
|
|
52
73
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
74
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, ScrcpyVideoStreamPacket>;
|
|
56
75
|
|
|
57
76
|
getControlMessageTypes(): ScrcpyControlMessageType[];
|
|
58
77
|
|
|
59
78
|
serializeBackOrScreenOnControlMessage(
|
|
60
|
-
message:
|
|
79
|
+
message: ScrcpyBackOrScreenOnControlMessage1_18,
|
|
61
80
|
): Uint8Array | undefined;
|
|
62
81
|
|
|
63
82
|
serializeInjectScrollControlMessage(
|