@yume-chan/scrcpy 0.0.12 → 0.0.13
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 +12 -0
- package/CHANGELOG.md +8 -1
- package/README.md +1 -0
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +1 -1
- package/bin/version.js +1 -1
- package/esm/client.d.ts +2 -2
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +4 -4
- package/esm/client.js.map +1 -1
- package/esm/connection.d.ts +4 -4
- package/esm/connection.d.ts.map +1 -1
- package/esm/connection.js +22 -7
- package/esm/connection.js.map +1 -1
- package/esm/decoder/web-codecs/index.d.ts.map +1 -1
- package/esm/decoder/web-codecs/index.js +2 -1
- package/esm/decoder/web-codecs/index.js.map +1 -1
- package/esm/options/1_16/index.d.ts +3 -3
- package/esm/options/1_16/index.d.ts.map +1 -1
- package/esm/options/1_16/index.js +55 -65
- package/esm/options/1_16/index.js.map +1 -1
- package/esm/options/1_23.d.ts +12 -0
- package/esm/options/1_23.d.ts.map +1 -0
- package/esm/options/1_23.js +31 -0
- package/esm/options/1_23.js.map +1 -0
- package/esm/options/common.d.ts +4 -2
- package/esm/options/common.d.ts.map +1 -1
- package/esm/options/index.d.ts +1 -0
- package/esm/options/index.d.ts.map +1 -1
- package/esm/options/index.js +1 -0
- package/esm/options/index.js.map +1 -1
- package/esm/push-server.d.ts +2 -2
- package/esm/push-server.d.ts.map +1 -1
- package/esm/push-server.js +4 -6
- package/esm/push-server.js.map +1 -1
- package/esm/utils.d.ts +0 -2
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +0 -8
- package/esm/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/client.ts +5 -5
- package/src/connection.ts +33 -11
- package/src/decoder/web-codecs/index.ts +2 -1
- package/src/options/1_16/index.ts +26 -33
- package/src/options/1_23.ts +44 -0
- package/src/options/common.ts +4 -2
- package/src/options/index.ts +1 -0
- package/src/push-server.ts +6 -8
- package/src/utils.ts +0 -11
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/scrcpy",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.13",
|
|
6
|
+
"tag": "@yume-chan/scrcpy_v0.0.13",
|
|
7
|
+
"date": "Thu, 28 Apr 2022 01:23:53 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add support for 1.23"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.0.12",
|
|
6
18
|
"tag": "@yume-chan/scrcpy_v0.0.12",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @yume-chan/scrcpy
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 28 Apr 2022 01:23:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.13
|
|
6
|
+
Thu, 28 Apr 2022 01:23:53 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Add support for 1.23
|
|
4
11
|
|
|
5
12
|
## 0.0.12
|
|
6
13
|
Sun, 03 Apr 2022 11:18:47 GMT
|
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ Scrcpy server has no backward compatibility on options input format. Currently t
|
|
|
50
50
|
| 1.18~1.20 | `ScrcpyOptions1_18` |
|
|
51
51
|
| 1.21 | `ScrcpyOptions1_21` |
|
|
52
52
|
| 1.22 | `ScrcpyOptions1_22` |
|
|
53
|
+
| 1.23 | `ScrcpyOptions1_23` |
|
|
53
54
|
|
|
54
55
|
You must use the correct type according to the server version.
|
|
55
56
|
|
package/bin/scrcpy-server
CHANGED
|
Binary file
|
package/bin/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.23';
|
package/bin/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.23';
|
package/esm/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Adb, type AdbSocket, type AdbSubprocessProtocol, type ReadableStream } from '@yume-chan/adb';
|
|
2
2
|
import { ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message.js';
|
|
3
3
|
import type { ScrcpyInjectScrollControlMessage1_22, ScrcpyOptions, VideoStreamPacket } from "./options/index.js";
|
|
4
4
|
export declare class ScrcpyClient {
|
|
@@ -24,7 +24,7 @@ export declare class ScrcpyClient {
|
|
|
24
24
|
<TThis, TArgs extends unknown[]>(listener: import("@yume-chan/event").EventListener<string, TThis, TArgs, unknown>, thisArg: TThis, ...args: TArgs): import("@yume-chan/event").RemoveEventListener;
|
|
25
25
|
};
|
|
26
26
|
private lastTouchMessage;
|
|
27
|
-
constructor(adb: Adb, options: ScrcpyOptions<any>, process: AdbSubprocessProtocol, videoStream:
|
|
27
|
+
constructor(adb: Adb, options: ScrcpyOptions<any>, process: AdbSubprocessProtocol, videoStream: AdbSocket, controlStream: AdbSocket | undefined);
|
|
28
28
|
private checkControlStream;
|
|
29
29
|
injectKeyCode(message: Omit<ScrcpyInjectKeyCodeControlMessage, 'type'>): Promise<void>;
|
|
30
30
|
injectText(text: string): Promise<void>;
|
package/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkH,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,KAAK,qB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AO,CAAC,kBAAkB;IAQb,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,iCAAiC,EAAE,MAAM,CAAC;IAStE,UAAU,CAAC,IAAI,EAAE,MAAM;IASvB,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,+BAA+B,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,CAAC;IA2BnG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,oCAAoC,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,CAAC;IAgBzG,uBAAuB,CAAC,MAAM,EAAE,qBAAqB;IAYrD,KAAK;CAIrB"}
|
package/esm/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { AdbBufferedStream,
|
|
2
|
+
import { AdbBufferedStream, AdbSubprocessNoneProtocol, DecodeUtf8Stream, InspectStream, TransformStream, WritableStream } from '@yume-chan/adb';
|
|
3
3
|
import { EventEmitter } from '@yume-chan/event';
|
|
4
4
|
import Struct from '@yume-chan/struct';
|
|
5
5
|
import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage } from './message.js';
|
|
@@ -37,8 +37,8 @@ export class ScrcpyClient {
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
}));
|
|
40
|
-
this._videoStream =
|
|
41
|
-
.
|
|
40
|
+
this._videoStream = videoStream.readable
|
|
41
|
+
.pipeThrough(options.createVideoStreamTransformer())
|
|
42
42
|
.pipeThrough(new InspectStream(packet => {
|
|
43
43
|
if (packet.type === 'configuration') {
|
|
44
44
|
this._screenWidth = packet.data.croppedWidth;
|
|
@@ -108,7 +108,7 @@ export class ScrcpyClient {
|
|
|
108
108
|
], {
|
|
109
109
|
// Scrcpy server doesn't split stdout and stderr,
|
|
110
110
|
// so disable Shell Protocol to simplify processing
|
|
111
|
-
protocols: [
|
|
111
|
+
protocols: [AdbSubprocessNoneProtocol],
|
|
112
112
|
});
|
|
113
113
|
const result = yield Promise.race([
|
|
114
114
|
process.exit,
|
package/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAA+G,MAAM,gBAAgB,CAAC;AAC7P,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,iCAAiC,EAAE,8BAA8B,EAAE,+BAA+B,EAA8B,MAAM,cAAc,CAAC;AAGlN,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAY;IAC7B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,IAAI,EAAE;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,OAAO;SACV;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC;QAEX,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;KACrB;AACL,CAAC;AAED,MAAM,gBAAgB,GAClB,IAAI,MAAM,EAAE;KACP,MAAM,CAAC,QAAQ,CAAC;KAChB,MAAM,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEtD,MAAM,OAAO,YAAY;IA0GrB,YACI,GAAQ,EACR,OAA2B,EAC3B,OAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EA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ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adb,
|
|
1
|
+
import type { Adb, AdbSocket } from "@yume-chan/adb";
|
|
2
2
|
import type { Disposable } from "@yume-chan/event";
|
|
3
3
|
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
4
4
|
export interface ScrcpyClientConnectionOptions {
|
|
@@ -17,21 +17,21 @@ export declare abstract class ScrcpyClientConnection implements Disposable {
|
|
|
17
17
|
protected options: ScrcpyClientConnectionOptions;
|
|
18
18
|
constructor(device: Adb, options: ScrcpyClientConnectionOptions);
|
|
19
19
|
initialize(): ValueOrPromise<void>;
|
|
20
|
-
abstract getStreams(): ValueOrPromise<[videoSteam:
|
|
20
|
+
abstract getStreams(): ValueOrPromise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]>;
|
|
21
21
|
dispose(): void;
|
|
22
22
|
}
|
|
23
23
|
export declare class ScrcpyClientForwardConnection extends ScrcpyClientConnection {
|
|
24
24
|
private connect;
|
|
25
25
|
private connectAndRetry;
|
|
26
26
|
private connectVideoStream;
|
|
27
|
-
getStreams(): Promise<[videoSteam:
|
|
27
|
+
getStreams(): Promise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]>;
|
|
28
28
|
}
|
|
29
29
|
export declare class ScrcpyClientReverseConnection extends ScrcpyClientConnection {
|
|
30
30
|
private streams;
|
|
31
31
|
private address;
|
|
32
32
|
initialize(): Promise<void>;
|
|
33
33
|
private accept;
|
|
34
|
-
getStreams(): Promise<[videoSteam:
|
|
34
|
+
getStreams(): Promise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]>;
|
|
35
35
|
dispose(): void;
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=connection.d.ts.map
|
package/esm/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,
|
|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esm/connection.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { AdbBufferedStream } from "@yume-chan/adb";
|
|
3
2
|
import { delay } from "./utils.js";
|
|
4
3
|
export class ScrcpyClientConnection {
|
|
5
4
|
constructor(device, options) {
|
|
@@ -30,11 +29,15 @@ export class ScrcpyClientForwardConnection extends ScrcpyClientConnection {
|
|
|
30
29
|
}
|
|
31
30
|
connectVideoStream() {
|
|
32
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const
|
|
34
|
-
const stream = new AdbBufferedStream(socket);
|
|
32
|
+
const stream = yield this.connectAndRetry();
|
|
35
33
|
if (this.options.sendDummyByte) {
|
|
34
|
+
const reader = stream.readable.getReader();
|
|
35
|
+
const { done, value } = yield reader.read();
|
|
36
36
|
// server will write a `0` to signal connection success
|
|
37
|
-
|
|
37
|
+
if (done || value.byteLength !== 1 || value[0] !== 0) {
|
|
38
|
+
throw new Error('Unexpected response from server');
|
|
39
|
+
}
|
|
40
|
+
reader.releaseLock();
|
|
38
41
|
}
|
|
39
42
|
return stream;
|
|
40
43
|
});
|
|
@@ -46,9 +49,15 @@ export class ScrcpyClientForwardConnection extends ScrcpyClientConnection {
|
|
|
46
49
|
if (this.options.control) {
|
|
47
50
|
controlStream = yield this.connectAndRetry();
|
|
48
51
|
}
|
|
52
|
+
// Server only writes device meta after control socket is connected (if enabled)
|
|
49
53
|
if (this.options.sendDeviceMeta) {
|
|
54
|
+
const reader = videoStream.readable.getReader();
|
|
55
|
+
const { done, value } = yield reader.read();
|
|
50
56
|
// 64 bytes device name + 2 bytes video width + 2 bytes video height
|
|
51
|
-
|
|
57
|
+
if (done || value.byteLength !== 64 + 2 + 2) {
|
|
58
|
+
throw new Error('Unexpected response from server');
|
|
59
|
+
}
|
|
60
|
+
reader.releaseLock();
|
|
52
61
|
}
|
|
53
62
|
return [videoStream, controlStream];
|
|
54
63
|
});
|
|
@@ -81,14 +90,20 @@ export class ScrcpyClientReverseConnection extends ScrcpyClientConnection {
|
|
|
81
90
|
}
|
|
82
91
|
getStreams() {
|
|
83
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const videoStream =
|
|
93
|
+
const videoStream = yield this.accept();
|
|
85
94
|
let controlStream;
|
|
86
95
|
if (this.options.control) {
|
|
87
96
|
controlStream = yield this.accept();
|
|
88
97
|
}
|
|
98
|
+
// Server only writes device meta after control socket is connected (if enabled)
|
|
89
99
|
if (this.options.sendDeviceMeta) {
|
|
100
|
+
const reader = videoStream.readable.getReader();
|
|
101
|
+
const { done, value } = yield reader.read();
|
|
90
102
|
// 64 bytes device name + 2 bytes video width + 2 bytes video height
|
|
91
|
-
|
|
103
|
+
if (done || value.byteLength !== 64 + 2 + 2) {
|
|
104
|
+
throw new Error('Unexpected response from server');
|
|
105
|
+
}
|
|
106
|
+
reader.releaseLock();
|
|
92
107
|
}
|
|
93
108
|
return [videoStream, controlStream];
|
|
94
109
|
});
|
package/esm/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAgBnC,MAAM,OAAgB,sBAAsB;IAKxC,YAAmB,MAAW,EAAE,OAAsC;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,UAAU,KAA2B,CAAC;IAItC,OAAO,KAAW,CAAC;CAC7B;AAED,MAAM,OAAO,6BAA8B,SAAQ,sBAAsB;IACvD,OAAO;;YACjB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;QAClE,CAAC;KAAA;IAEa,eAAe;;YACzB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AAW,aAAa,WAAkC;IAE1D,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,OAAO,CAAe;IAG9B,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,cAAc,CAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decoder/web-codecs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,aAAa,CAAC;AAMlE,qBAAa,gBAAiB,YAAW,WAAW;IAGhD,SAAgB,UAAU,YAAa;IACvC,SAAgB,QAAQ,YAAa;IAErC,OAAO,CAAC,SAAS,CAAoC;IACrD,IAAW,QAAQ,sCAA6B;IAEhD,OAAO,CAAC,SAAS,CAAoB;IACrC,IAAW,QAAQ,sBAA6B;IAEhD,OAAO,CAAC,cAAc,CAAK;IAC3B,IAAW,aAAa,WAAkC;IAE1D,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,OAAO,CAAe;IAG9B,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,cAAc,CAAa;;IAwCnC,OAAO,CAAC,MAAM,CASZ;IAEF,OAAO,CAAC,SAAS;IAeV,OAAO;CAIjB"}
|
|
@@ -43,7 +43,8 @@ export class WebCodecsDecoder {
|
|
|
43
43
|
break;
|
|
44
44
|
case 'frame':
|
|
45
45
|
this.decoder.decode(new EncodedVideoChunk({
|
|
46
|
-
|
|
46
|
+
// Treat `undefined` as `key`, otherwise won't decode.
|
|
47
|
+
type: packet.keyframe === false ? 'delta' : 'key',
|
|
47
48
|
timestamp: 0,
|
|
48
49
|
data: packet.data,
|
|
49
50
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decoder/web-codecs/index.ts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AAC,SAAS,CAAC,CAAC,CAAC;IAGhD,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAGhD,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IA0DlD,SAAS,CAAC,MAAyB;QACvC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAE3D,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;QAE7C,qDAAqD;QACrD,wCAAwC;QACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACtF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;YACnB,KAAK,EAAE,KAAK;YACZ,kBAAkB,EAAE,IAAI;SAC3B,CAAC,CAAC;IACP,CAAC;IAEM,OAAO;QACV,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformStream, type Adb } from "@yume-chan/adb";
|
|
2
2
|
import Struct from "@yume-chan/struct";
|
|
3
3
|
import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
|
|
4
4
|
import { ScrcpyClientConnection } from "../../connection.js";
|
|
@@ -79,7 +79,7 @@ export declare const VideoPacket: Struct<{
|
|
|
79
79
|
size: number;
|
|
80
80
|
data: Uint8Array;
|
|
81
81
|
}, "size", {}, undefined>;
|
|
82
|
-
export declare const
|
|
82
|
+
export declare const NO_PTS: bigint;
|
|
83
83
|
export declare const ScrcpyBackOrScreenOnEvent1_16: Struct<{
|
|
84
84
|
type: ScrcpyControlMessageType.BackOrScreenOn;
|
|
85
85
|
}, never, {}, undefined>;
|
|
@@ -100,7 +100,7 @@ export declare class ScrcpyOptions1_16<T extends ScrcpyOptionsInit1_16 = ScrcpyO
|
|
|
100
100
|
formatServerArguments(): string[];
|
|
101
101
|
createConnection(adb: Adb): ScrcpyClientConnection;
|
|
102
102
|
getOutputEncoderNameRegex(): RegExp;
|
|
103
|
-
|
|
103
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
104
104
|
serializeBackOrScreenOnControlMessage(message: ScrcpyBackOrScreenOnEvent1_18): Uint8Array | undefined;
|
|
105
105
|
serializeInjectScrollControlMessage(message: ScrcpyInjectScrollControlMessage1_22): Uint8Array;
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/options/1_16/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/options/1_16/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,eAAe,EAAE,KAAK,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,MAAuB,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAoG,MAAM,qBAAqB,CAAC;AAC/J,OAAO,EAAyB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvH,oBAAY,c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B,qBAAa,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACxG,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAEN,KAAK,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAcxD,SAAS,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE;IAmBzC,SAAS,CAAC,eAAe,IAAI,CAAC;IAmBvB,qBAAqB,IAAI,MAAM,EAAE;IAMjC,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,sBAAsB;IAclD,yBAAyB,IAAI,MAAM;IAInC,4BAA4B,IAAI,eAAe,CAAC,UAAU,EAAE,iBAAiB,CAAC;IAsF9E,qCAAqC,CACxC,OAAO,EAAE,6BAA6B;IASnC,mCAAmC,CACtC,OAAO,EAAE,oCAAoC,GAC9C,UAAU;CAGhB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BufferedStreamEndedError, ReadableStream, TransformStream } from "@yume-chan/adb";
|
|
1
|
+
import { StructDeserializeStream, TransformStream } from "@yume-chan/adb";
|
|
3
2
|
import Struct, { placeholder } from "@yume-chan/struct";
|
|
4
3
|
import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection } from "../../connection.js";
|
|
5
4
|
import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../../message.js";
|
|
@@ -38,10 +37,10 @@ export class CodecOptions {
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
export const VideoPacket = new Struct()
|
|
41
|
-
.
|
|
40
|
+
.uint64('pts')
|
|
42
41
|
.uint32('size')
|
|
43
42
|
.uint8Array('data', { lengthField: 'size' });
|
|
44
|
-
export const
|
|
43
|
+
export const NO_PTS = BigInt(1) << BigInt(63);
|
|
45
44
|
export const ScrcpyBackOrScreenOnEvent1_16 = new Struct()
|
|
46
45
|
.uint8('type', placeholder());
|
|
47
46
|
export const ScrcpyInjectScrollControlMessage1_16 = new Struct()
|
|
@@ -122,81 +121,72 @@ export class ScrcpyOptions1_16 {
|
|
|
122
121
|
getOutputEncoderNameRegex() {
|
|
123
122
|
return /\s+scrcpy --encoder-name '(.*?)'/;
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
createVideoStreamTransformer() {
|
|
126
125
|
// Optimized path for video frames only
|
|
127
126
|
if (this.value.sendFrameMeta === false) {
|
|
128
|
-
return
|
|
129
|
-
.release()
|
|
130
|
-
.pipeThrough(new TransformStream({
|
|
127
|
+
return new TransformStream({
|
|
131
128
|
transform(chunk, controller) {
|
|
132
129
|
controller.enqueue({
|
|
133
130
|
type: 'frame',
|
|
134
131
|
data: chunk,
|
|
135
132
|
});
|
|
136
133
|
},
|
|
137
|
-
})
|
|
134
|
+
});
|
|
138
135
|
}
|
|
139
136
|
let header;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
controller.enqueue({
|
|
158
|
-
type: 'configuration',
|
|
159
|
-
data: {
|
|
160
|
-
profileIndex,
|
|
161
|
-
constraintSet,
|
|
162
|
-
levelIndex,
|
|
163
|
-
encodedWidth,
|
|
164
|
-
encodedHeight,
|
|
165
|
-
cropLeft,
|
|
166
|
-
cropRight,
|
|
167
|
-
cropTop,
|
|
168
|
-
cropBottom,
|
|
169
|
-
croppedWidth,
|
|
170
|
-
croppedHeight,
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
let frameData;
|
|
176
|
-
if (header) {
|
|
177
|
-
frameData = new Uint8Array(header.byteLength + data.byteLength);
|
|
178
|
-
frameData.set(header);
|
|
179
|
-
frameData.set(data, header.byteLength);
|
|
180
|
-
header = undefined;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
frameData = data;
|
|
184
|
-
}
|
|
137
|
+
let deserializeStream = new StructDeserializeStream(VideoPacket);
|
|
138
|
+
return {
|
|
139
|
+
writable: deserializeStream.writable,
|
|
140
|
+
readable: deserializeStream.readable.pipeThrough(new TransformStream({
|
|
141
|
+
transform(packet, controller) {
|
|
142
|
+
if (packet.pts === NO_PTS) {
|
|
143
|
+
const sequenceParameterSet = parse_sequence_parameter_set(packet.data.slice().buffer);
|
|
144
|
+
const { profile_idc: profileIndex, constraint_set: constraintSet, level_idc: levelIndex, pic_width_in_mbs_minus1, pic_height_in_map_units_minus1, frame_mbs_only_flag, frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset, } = sequenceParameterSet;
|
|
145
|
+
const encodedWidth = (pic_width_in_mbs_minus1 + 1) * 16;
|
|
146
|
+
const encodedHeight = (pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag) * 16;
|
|
147
|
+
const cropLeft = frame_crop_left_offset * 2;
|
|
148
|
+
const cropRight = frame_crop_right_offset * 2;
|
|
149
|
+
const cropTop = frame_crop_top_offset * 2;
|
|
150
|
+
const cropBottom = frame_crop_bottom_offset * 2;
|
|
151
|
+
const croppedWidth = encodedWidth - cropLeft - cropRight;
|
|
152
|
+
const croppedHeight = encodedHeight - cropTop - cropBottom;
|
|
153
|
+
header = packet.data;
|
|
185
154
|
controller.enqueue({
|
|
186
|
-
type: '
|
|
187
|
-
data:
|
|
155
|
+
type: 'configuration',
|
|
156
|
+
data: {
|
|
157
|
+
profileIndex,
|
|
158
|
+
constraintSet,
|
|
159
|
+
levelIndex,
|
|
160
|
+
encodedWidth,
|
|
161
|
+
encodedHeight,
|
|
162
|
+
cropLeft,
|
|
163
|
+
cropRight,
|
|
164
|
+
cropTop,
|
|
165
|
+
cropBottom,
|
|
166
|
+
croppedWidth,
|
|
167
|
+
croppedHeight,
|
|
168
|
+
}
|
|
188
169
|
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
let frameData;
|
|
173
|
+
if (header) {
|
|
174
|
+
frameData = new Uint8Array(header.byteLength + packet.data.byteLength);
|
|
175
|
+
frameData.set(header);
|
|
176
|
+
frameData.set(packet.data, header.byteLength);
|
|
177
|
+
header = undefined;
|
|
189
178
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
controller.close();
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
throw e;
|
|
179
|
+
else {
|
|
180
|
+
frameData = packet.data;
|
|
196
181
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
182
|
+
controller.enqueue({
|
|
183
|
+
type: 'frame',
|
|
184
|
+
pts: packet.pts,
|
|
185
|
+
data: frameData,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}))
|
|
189
|
+
};
|
|
200
190
|
}
|
|
201
191
|
serializeBackOrScreenOnControlMessage(message) {
|
|
202
192
|
if (message.action === AndroidKeyEventAction.Down) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/options/1_16/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/options/1_16/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAY,MAAM,gBAAgB,CAAC;AACpF,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAA0B,6BAA6B,EAAE,6BAA6B,EAAsC,MAAM,qBAAqB,CAAC;AAC/J,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAGnF,OAAO,EAAE,mBAAmB,EAAsE,MAAM,cAAc,CAAC;AACvH,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,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Y;gCACZ,aAAa;gCACb,UAAU;gCACV,YAAY;gCACZ,aAAa;gCACb,QAAQ;gCACR,SAAS;gCACT,OAAO;gCACP,UAAU;gCACV,YAAY;gCACZ,aAAa;6BAChB;yBACJ,CAAC,CAAC;wBACH,OAAO;qBACV;oBAED,IAAI,SAAqB,CAAC;oBAC1B,IAAI,MAAM,EAAE;wBACR,SAAS,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;wBACvE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;wBACtB,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;wBAC9C,MAAM,GAAG,SAAS,CAAC;qBACtB;yBAAM;wBACH,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;qBAC3B;oBAED,UAAU,CAAC,OAAO,CAAC;wBACf,IAAI,EAAE,OAAO;wBACb,GAAG,EAAE,MAAM,CAAC,GAAG;wBACf,IAAI,EAAE,SAAS;qBAClB,CAAC,CAAC;gBACP,CAAC;aACJ,CAAC,CAAC;SACN,CAAC;IACN,CAAC;IAEM,qCAAqC,CACxC,OAAsC;QAEtC,IAAI,OAAO,CAAC,MAAM,KAAK,qBAAqB,CAAC,IAAI,EAAE;YAC/C,OAAO,6BAA6B,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SAC3D;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,mCAAmC,CACtC,OAA6C;QAE7C,OAAO,oCAAoC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;CACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TransformStream } from "@yume-chan/adb";
|
|
2
|
+
import { ScrcpyOptions1_22, type ScrcpyOptionsInit1_22 } from './1_22.js';
|
|
3
|
+
import type { VideoStreamPacket } from "./common.js";
|
|
4
|
+
export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
|
|
5
|
+
cleanup: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23> extends ScrcpyOptions1_22<T> {
|
|
8
|
+
constructor(init: Partial<ScrcpyOptionsInit1_23>);
|
|
9
|
+
protected getDefaultValue(): T;
|
|
10
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=1_23.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_23.d.ts","sourceRoot":"","sources":["../../src/options/1_23.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAChE,OAAO,EAAE,OAAO,CAAC;CACpB;AAID,qBAAa,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;gBAC7F,IAAI,EAAE,OAAO,CAAC,qBAAqB,CAAC;cAIpC,eAAe,IAAI,CAAC;IAOvB,4BAA4B,IAAI,eAAe,CAAC,UAAU,EAAE,iBAAiB,CAAC;CAqBjG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TransformStream } from "@yume-chan/adb";
|
|
2
|
+
import { ScrcpyOptions1_22 } from './1_22.js';
|
|
3
|
+
const KEYFRAME_PTS = BigInt(1) << BigInt(62);
|
|
4
|
+
export class ScrcpyOptions1_23 extends ScrcpyOptions1_22 {
|
|
5
|
+
constructor(init) {
|
|
6
|
+
super(init);
|
|
7
|
+
}
|
|
8
|
+
getDefaultValue() {
|
|
9
|
+
return Object.assign(Object.assign({}, super.getDefaultValue()), { cleanup: true });
|
|
10
|
+
}
|
|
11
|
+
createVideoStreamTransformer() {
|
|
12
|
+
const superStream = super.createVideoStreamTransformer();
|
|
13
|
+
return {
|
|
14
|
+
writable: superStream.writable,
|
|
15
|
+
readable: superStream.readable.pipeThrough(new TransformStream({
|
|
16
|
+
transform(packet, controller) {
|
|
17
|
+
if (packet.type !== 'frame') {
|
|
18
|
+
controller.enqueue(packet);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (packet.pts !== undefined && packet.pts & KEYFRAME_PTS) {
|
|
22
|
+
packet.keyframe = true;
|
|
23
|
+
packet.pts &= ~KEYFRAME_PTS;
|
|
24
|
+
}
|
|
25
|
+
controller.enqueue(packet);
|
|
26
|
+
}
|
|
27
|
+
}))
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=1_23.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_23.js","sourceRoot":"","sources":["../../src/options/1_23.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAA8B,MAAM,WAAW,CAAC;AAO1E,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;AAE7C,MAAM,OAAO,iBAA2E,SAAQ,iBAAoB;IAChH,YAAmB,IAAoC;QACnD,KAAK,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEkB,eAAe;QAC9B,uCACO,KAAK,CAAC,eAAe,EAAE,KAC1B,OAAO,EAAE,IAAI,IACf;IACN,CAAC;IAEe,4BAA4B;QACxC,MAAM,WAAW,GAAG,KAAK,CAAC,4BAA4B,EAAE,CAAC;QACzD,OAAO;YACH,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,eAAe,CAAC;gBAC3D,SAAS,CAAC,MAAM,EAAE,UAAU;oBACxB,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;wBACzB,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;wBAC3B,OAAO;qBACV;oBAED,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,GAAG,YAAY,EAAE;wBACvD,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;wBACvB,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;qBAC/B;oBAED,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC;aACJ,CAAC,CAAC;SACN,CAAC;IACN,CAAC;CACJ"}
|
package/esm/options/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Adb,
|
|
1
|
+
import type { Adb, TransformStream } from "@yume-chan/adb";
|
|
2
2
|
import type { ScrcpyClientConnection } from "../connection.js";
|
|
3
3
|
import type { H264Configuration } from "../decoder/index.js";
|
|
4
4
|
import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js";
|
|
@@ -15,6 +15,8 @@ export interface VideoStreamConfigurationPacket {
|
|
|
15
15
|
}
|
|
16
16
|
export interface VideoStreamFramePacket {
|
|
17
17
|
type: 'frame';
|
|
18
|
+
keyframe?: boolean | undefined;
|
|
19
|
+
pts?: bigint | undefined;
|
|
18
20
|
data: Uint8Array;
|
|
19
21
|
}
|
|
20
22
|
export declare type VideoStreamPacket = VideoStreamConfigurationPacket | VideoStreamFramePacket;
|
|
@@ -23,7 +25,7 @@ export interface ScrcpyOptions<T> {
|
|
|
23
25
|
formatServerArguments(): string[];
|
|
24
26
|
getOutputEncoderNameRegex(): RegExp;
|
|
25
27
|
createConnection(adb: Adb): ScrcpyClientConnection;
|
|
26
|
-
|
|
28
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
27
29
|
serializeBackOrScreenOnControlMessage(message: ScrcpyBackOrScreenOnEvent1_18): Uint8Array | undefined;
|
|
28
30
|
serializeInjectScrollControlMessage(message: ScrcpyInjectScrollControlMessage1_22): Uint8Array;
|
|
29
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/options/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/options/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,WAAW,CAAC;AAEtE,eAAO,MAAM,mBAAmB,sCAAsC,CAAC;AAEvE,MAAM,WAAW,iBAAiB;IAC9B,aAAa,IAAI,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,iBAAiB,CAI1E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,CAUvE;AAED,MAAM,WAAW,8BAA8B;IAC3C,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;CACpB;AAED,oBAAY,iBAAiB,GAAG,8BAA8B,GAAG,sBAAsB,CAAC;AAExF,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAElB,qBAAqB,IAAI,MAAM,EAAE,CAAC;IAElC,yBAAyB,IAAI,MAAM,CAAC;IAEpC,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,sBAAsB,CAAC;IAEnD,4BAA4B,IAAI,eAAe,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IAE/E,qCAAqC,CACjC,OAAO,EAAE,6BAA6B,GACvC,UAAU,GAAG,SAAS,CAAC;IAE1B,mCAAmC,CAC/B,OAAO,EAAE,oCAAoC,GAC9C,UAAU,CAAC;CACjB"}
|
package/esm/options/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/esm/options/index.js
CHANGED
package/esm/options/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/esm/push-server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WrapWritableStream, type Adb } from "@yume-chan/adb";
|
|
2
2
|
export interface PushServerOptions {
|
|
3
3
|
path?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function pushServer(device: Adb, options?: PushServerOptions): WrapWritableStream<Uint8Array
|
|
5
|
+
export declare function pushServer(device: Adb, options?: PushServerOptions): WrapWritableStream<Uint8Array>;
|
|
6
6
|
//# sourceMappingURL=push-server.d.ts.map
|
package/esm/push-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-server.d.ts","sourceRoot":"","sources":["../src/push-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"push-server.d.ts","sourceRoot":"","sources":["../src/push-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,GAAG,EAAgB,MAAM,gBAAgB,CAAC;AAG5E,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CACtB,MAAM,EAAE,GAAG,EACX,OAAO,GAAE,iBAAsB,kCAclC"}
|
package/esm/push-server.js
CHANGED
|
@@ -3,17 +3,15 @@ import { WrapWritableStream } from "@yume-chan/adb";
|
|
|
3
3
|
import { DEFAULT_SERVER_PATH } from "./options/index.js";
|
|
4
4
|
export function pushServer(device, options = {}) {
|
|
5
5
|
const { path = DEFAULT_SERVER_PATH } = options;
|
|
6
|
+
let sync;
|
|
6
7
|
return new WrapWritableStream({
|
|
7
8
|
start() {
|
|
8
9
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
writable: sync.write(path),
|
|
12
|
-
state: sync,
|
|
13
|
-
};
|
|
10
|
+
sync = yield device.sync();
|
|
11
|
+
return sync.write(path);
|
|
14
12
|
});
|
|
15
13
|
},
|
|
16
|
-
close(
|
|
14
|
+
close() {
|
|
17
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
16
|
yield sync.dispose();
|
|
19
17
|
});
|
package/esm/push-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-server.js","sourceRoot":"","sources":["../src/push-server.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"push-server.js","sourceRoot":"","sources":["../src/push-server.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAMzD,MAAM,UAAU,UAAU,CACtB,MAAW,EACX,UAA6B,EAAE;IAE/B,MAAM,EAAE,IAAI,GAAG,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE/C,IAAI,IAAc,CAAC;IACnB,OAAO,IAAI,kBAAkB,CAAa;QAChC,KAAK;;gBACP,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;SAAA;QACK,KAAK;;gBACP,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACzB,CAAC;SAAA;KACJ,CAAC,CAAC;AACP,CAAC"}
|
package/esm/utils.d.ts
CHANGED
package/esm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjD
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjD"}
|
package/esm/utils.js
CHANGED
|
@@ -3,12 +3,4 @@ export function delay(time) {
|
|
|
3
3
|
globalThis.setTimeout(resolve, time);
|
|
4
4
|
});
|
|
5
5
|
}
|
|
6
|
-
const Utf8Encoder = new TextEncoder();
|
|
7
|
-
const Utf8Decoder = new TextDecoder();
|
|
8
|
-
export function encodeUtf8(input) {
|
|
9
|
-
return Utf8Encoder.encode(input).buffer;
|
|
10
|
-
}
|
|
11
|
-
export function decodeUtf8(buffer) {
|
|
12
|
-
return Utf8Decoder.decode(buffer);
|
|
13
|
-
}
|
|
14
6
|
//# sourceMappingURL=utils.js.map
|
package/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,IAAY;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QACxB,UAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,IAAY;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QACxB,UAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/scrcpy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "TypeScript implementation of Scrcpy.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"main": "esm/index.js",
|
|
30
30
|
"types": "esm/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@yume-chan/adb": "^0.0.
|
|
32
|
+
"@yume-chan/adb": "^0.0.13",
|
|
33
33
|
"@yume-chan/async": "^2.1.4",
|
|
34
|
-
"@yume-chan/event": "^0.0.
|
|
35
|
-
"@yume-chan/struct": "^0.0.
|
|
34
|
+
"@yume-chan/event": "^0.0.13",
|
|
35
|
+
"@yume-chan/struct": "^0.0.13",
|
|
36
36
|
"tslib": "^2.3.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"gh-release-fetch": "^2.0.4",
|
|
43
43
|
"jest": "^27.5.1",
|
|
44
44
|
"tinyh264": "^0.0.7",
|
|
45
|
-
"typescript": "
|
|
45
|
+
"typescript": "4.7.0-beta",
|
|
46
46
|
"yuv-buffer": "^1.0.0",
|
|
47
47
|
"yuv-canvas": "^1.2.7"
|
|
48
48
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"build:watch": "build-ts-package --incremental",
|
|
58
58
|
"test": "jest --coverage"
|
|
59
59
|
},
|
|
60
|
-
"readme": "# @yume-chan/scrcpy\r\n\r\nTypeScript implementation of [Scrcpy](https://github.com/Genymobile/scrcpy) client.\r\n\r\nIt uses the official Scrcpy server releases.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n## Download Server Binary\r\n\r\nThis package has a script `fetch-scrcpy-server` to help you download the official server binary.\r\n\r\nThe server binary is subject to [Apache License 2.0](https://github.com/Genymobile/scrcpy/blob/master/LICENSE).\r\n\r\nUsage:\r\n\r\n```\r\n$ npx fetch-scrcpy-server <version>\r\n```\r\n\r\nFor example:\r\n\r\n```\r\n$ npx fetch-scrcpy-server 1.21\r\n```\r\n\r\nYou can also add it to the `postinstall` script of your `package.json` so it will run automatically when you do `npm install`:\r\n\r\n```json\r\n\"scripts\": {\r\n \"postinstall\": \"fetch-scrcpy-server 1.21\",\r\n},\r\n```\r\n\r\nIt will download the binary to `bin/scrcpy` and write the version string to `bin/version.js`. You can import the version string with\r\n\r\n```js\r\nimport SCRCPY_SERVER_VERSION from '@yume-chan/scrcpy/bin/version';\r\n```\r\n\r\nAnd import the server binary with [file-loader](https://v4.webpack.js.org/loaders/file-loader/) (Webpack 4) or [Asset Modules](https://webpack.js.org/guides/asset-modules/) (Webpack 5).\r\n\r\n## Option versions\r\n\r\nScrcpy server has no backward compatibility on options input format. Currently the following versions are supported:\r\n\r\n| versions | type |\r\n| --------- | ------------------- |\r\n| 1.16~1.17 | `ScrcpyOptions1_16` |\r\n| 1.18~1.20 | `ScrcpyOptions1_18` |\r\n| 1.21 | `ScrcpyOptions1_21` |\r\n| 1.22 | `ScrcpyOptions1_22` |\r\n\r\nYou must use the correct type according to the server version.\r\n\r\n## Video stream\r\n\r\nThe data from `onVideoData` event is a raw H.264 stream. You can process it as you want, or use the following built-in decoders to render it in browsers:\r\n\r\n* WebCodecs decoder: Uses the [WebCodecs API](https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API). The video stream will be decoded into `VideoFrame`s and drawn on a 2D canvas.\r\n* TinyH264 decoder: TinyH264 compiles the old Android H.264 software decoder (now deprecated and removed) into WebAssembly, and wrap it in Web Worker to prevent blocking the main thread. The video stream will be decoded into YUV frames, then converted to RGB using a WebGL shader.\r\n\r\n| Name | Chrome | Firefox | Safari | Performance | Supported H.264 profile/level |\r\n| ----------------- | ------ | ------- | ------ | ------------------------------- | ----------------------------- |\r\n| WebCodecs decoder | 94 | No | No | High with Hardware acceleration | High level 5 |\r\n| TinyH264 decoder | 57 | 52 | 11 | Poor | Baseline level 4 |\r\n\r\nTinyH264 decoder needs some extra setup:\r\n\r\n1. `tinyh264`, `yuv-buffer` and `yuv-canvas` packages are peer dependencies. You must install them separately.\r\n2. The bundler you use must support the `new Worker(new URL('./worker.js', import.meta.url))` syntax. It's known to work with Webpack 5.\r\n\r\nExample usage:\r\n\r\n```ts\r\nconst client = new ScrcpyClient(adb);\r\nconst decoder = new WebCodecsDecoder(); // Or `new TinyH264Decoder()`\r\nclient.onSizeChanged(size => decoder.setSize(size));\r\nclient.onVideoData(data => decoder.feed(data));\r\nclient.start(serverPath, serverVersion, new ScrcpyOptionsX_XX({\r\n ...options,\r\n codecOptions: new CodecOptions({\r\n profile: decoder.maxProfile,\r\n level: decoder.maxLevel,\r\n }),\r\n}));\r\ndocument.body.appendChild(decoder.element);\r\n```\r\n"
|
|
60
|
+
"readme": "# @yume-chan/scrcpy\r\n\r\nTypeScript implementation of [Scrcpy](https://github.com/Genymobile/scrcpy) client.\r\n\r\nIt uses the official Scrcpy server releases.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n## Download Server Binary\r\n\r\nThis package has a script `fetch-scrcpy-server` to help you download the official server binary.\r\n\r\nThe server binary is subject to [Apache License 2.0](https://github.com/Genymobile/scrcpy/blob/master/LICENSE).\r\n\r\nUsage:\r\n\r\n```\r\n$ npx fetch-scrcpy-server <version>\r\n```\r\n\r\nFor example:\r\n\r\n```\r\n$ npx fetch-scrcpy-server 1.21\r\n```\r\n\r\nYou can also add it to the `postinstall` script of your `package.json` so it will run automatically when you do `npm install`:\r\n\r\n```json\r\n\"scripts\": {\r\n \"postinstall\": \"fetch-scrcpy-server 1.21\",\r\n},\r\n```\r\n\r\nIt will download the binary to `bin/scrcpy` and write the version string to `bin/version.js`. You can import the version string with\r\n\r\n```js\r\nimport SCRCPY_SERVER_VERSION from '@yume-chan/scrcpy/bin/version';\r\n```\r\n\r\nAnd import the server binary with [file-loader](https://v4.webpack.js.org/loaders/file-loader/) (Webpack 4) or [Asset Modules](https://webpack.js.org/guides/asset-modules/) (Webpack 5).\r\n\r\n## Option versions\r\n\r\nScrcpy server has no backward compatibility on options input format. Currently the following versions are supported:\r\n\r\n| versions | type |\r\n| --------- | ------------------- |\r\n| 1.16~1.17 | `ScrcpyOptions1_16` |\r\n| 1.18~1.20 | `ScrcpyOptions1_18` |\r\n| 1.21 | `ScrcpyOptions1_21` |\r\n| 1.22 | `ScrcpyOptions1_22` |\r\n| 1.23 | `ScrcpyOptions1_23` |\r\n\r\nYou must use the correct type according to the server version.\r\n\r\n## Video stream\r\n\r\nThe data from `onVideoData` event is a raw H.264 stream. You can process it as you want, or use the following built-in decoders to render it in browsers:\r\n\r\n* WebCodecs decoder: Uses the [WebCodecs API](https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API). The video stream will be decoded into `VideoFrame`s and drawn on a 2D canvas.\r\n* TinyH264 decoder: TinyH264 compiles the old Android H.264 software decoder (now deprecated and removed) into WebAssembly, and wrap it in Web Worker to prevent blocking the main thread. The video stream will be decoded into YUV frames, then converted to RGB using a WebGL shader.\r\n\r\n| Name | Chrome | Firefox | Safari | Performance | Supported H.264 profile/level |\r\n| ----------------- | ------ | ------- | ------ | ------------------------------- | ----------------------------- |\r\n| WebCodecs decoder | 94 | No | No | High with Hardware acceleration | High level 5 |\r\n| TinyH264 decoder | 57 | 52 | 11 | Poor | Baseline level 4 |\r\n\r\nTinyH264 decoder needs some extra setup:\r\n\r\n1. `tinyh264`, `yuv-buffer` and `yuv-canvas` packages are peer dependencies. You must install them separately.\r\n2. The bundler you use must support the `new Worker(new URL('./worker.js', import.meta.url))` syntax. It's known to work with Webpack 5.\r\n\r\nExample usage:\r\n\r\n```ts\r\nconst client = new ScrcpyClient(adb);\r\nconst decoder = new WebCodecsDecoder(); // Or `new TinyH264Decoder()`\r\nclient.onSizeChanged(size => decoder.setSize(size));\r\nclient.onVideoData(data => decoder.feed(data));\r\nclient.start(serverPath, serverVersion, new ScrcpyOptionsX_XX({\r\n ...options,\r\n codecOptions: new CodecOptions({\r\n profile: decoder.maxProfile,\r\n level: decoder.maxLevel,\r\n }),\r\n}));\r\ndocument.body.appendChild(decoder.element);\r\n```\r\n"
|
|
61
61
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdbBufferedStream,
|
|
1
|
+
import { AdbBufferedStream, AdbSubprocessNoneProtocol, DecodeUtf8Stream, InspectStream, TransformStream, WritableStream, type Adb, type AdbSocket, type AdbSubprocessProtocol, type ReadableStream, type WritableStreamDefaultWriter } from '@yume-chan/adb';
|
|
2
2
|
import { EventEmitter } from '@yume-chan/event';
|
|
3
3
|
import Struct from '@yume-chan/struct';
|
|
4
4
|
import { AndroidMotionEventAction, ScrcpyControlMessageType, ScrcpyInjectKeyCodeControlMessage, ScrcpyInjectTextControlMessage, ScrcpyInjectTouchControlMessage, type AndroidKeyEventAction } from './message.js';
|
|
@@ -81,7 +81,7 @@ export class ScrcpyClient {
|
|
|
81
81
|
{
|
|
82
82
|
// Scrcpy server doesn't split stdout and stderr,
|
|
83
83
|
// so disable Shell Protocol to simplify processing
|
|
84
|
-
protocols: [
|
|
84
|
+
protocols: [AdbSubprocessNoneProtocol],
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
|
|
@@ -135,7 +135,7 @@ export class ScrcpyClient {
|
|
|
135
135
|
adb: Adb,
|
|
136
136
|
options: ScrcpyOptions<any>,
|
|
137
137
|
process: AdbSubprocessProtocol,
|
|
138
|
-
videoStream:
|
|
138
|
+
videoStream: AdbSocket,
|
|
139
139
|
controlStream: AdbSocket | undefined,
|
|
140
140
|
) {
|
|
141
141
|
this._adb = adb;
|
|
@@ -155,8 +155,8 @@ export class ScrcpyClient {
|
|
|
155
155
|
},
|
|
156
156
|
}));
|
|
157
157
|
|
|
158
|
-
this._videoStream =
|
|
159
|
-
.
|
|
158
|
+
this._videoStream = videoStream.readable
|
|
159
|
+
.pipeThrough(options.createVideoStreamTransformer())
|
|
160
160
|
.pipeThrough(new InspectStream(packet => {
|
|
161
161
|
if (packet.type === 'configuration') {
|
|
162
162
|
this._screenWidth = packet.data.croppedWidth;
|
package/src/connection.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adb,
|
|
1
|
+
import type { Adb, AdbSocket } from "@yume-chan/adb";
|
|
2
2
|
import type { Disposable } from "@yume-chan/event";
|
|
3
3
|
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
4
4
|
import { delay } from "./utils.js";
|
|
@@ -29,7 +29,7 @@ export abstract class ScrcpyClientConnection implements Disposable {
|
|
|
29
29
|
|
|
30
30
|
public initialize(): ValueOrPromise<void> { }
|
|
31
31
|
|
|
32
|
-
public abstract getStreams(): ValueOrPromise<[videoSteam:
|
|
32
|
+
public abstract getStreams(): ValueOrPromise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]>;
|
|
33
33
|
|
|
34
34
|
public dispose(): void { }
|
|
35
35
|
}
|
|
@@ -50,26 +50,39 @@ export class ScrcpyClientForwardConnection extends ScrcpyClientConnection {
|
|
|
50
50
|
throw new Error(`Can't connect to server after 100 retries`);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
private async connectVideoStream(): Promise<
|
|
54
|
-
const
|
|
55
|
-
const stream = new AdbBufferedStream(socket);
|
|
53
|
+
private async connectVideoStream(): Promise<AdbSocket> {
|
|
54
|
+
const stream = await this.connectAndRetry();
|
|
56
55
|
if (this.options.sendDummyByte) {
|
|
56
|
+
const reader = stream.readable.getReader();
|
|
57
|
+
const { done, value } = await reader.read();
|
|
57
58
|
// server will write a `0` to signal connection success
|
|
58
|
-
|
|
59
|
+
if (done || value.byteLength !== 1 || value[0] !== 0) {
|
|
60
|
+
throw new Error('Unexpected response from server');
|
|
61
|
+
}
|
|
62
|
+
reader.releaseLock();
|
|
59
63
|
}
|
|
60
64
|
return stream;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
public async getStreams(): Promise<[videoSteam:
|
|
67
|
+
public async getStreams(): Promise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]> {
|
|
64
68
|
const videoStream = await this.connectVideoStream();
|
|
69
|
+
|
|
65
70
|
let controlStream: AdbSocket | undefined;
|
|
66
71
|
if (this.options.control) {
|
|
67
72
|
controlStream = await this.connectAndRetry();
|
|
68
73
|
}
|
|
74
|
+
|
|
75
|
+
// Server only writes device meta after control socket is connected (if enabled)
|
|
69
76
|
if (this.options.sendDeviceMeta) {
|
|
77
|
+
const reader = videoStream.readable.getReader();
|
|
78
|
+
const { done, value } = await reader.read();
|
|
70
79
|
// 64 bytes device name + 2 bytes video width + 2 bytes video height
|
|
71
|
-
|
|
80
|
+
if (done || value.byteLength !== 64 + 2 + 2) {
|
|
81
|
+
throw new Error('Unexpected response from server');
|
|
82
|
+
}
|
|
83
|
+
reader.releaseLock();
|
|
72
84
|
}
|
|
85
|
+
|
|
73
86
|
return [videoStream, controlStream];
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -101,16 +114,25 @@ export class ScrcpyClientReverseConnection extends ScrcpyClientConnection {
|
|
|
101
114
|
return (await this.streams.read()).value!;
|
|
102
115
|
}
|
|
103
116
|
|
|
104
|
-
public async getStreams(): Promise<[videoSteam:
|
|
105
|
-
const videoStream =
|
|
117
|
+
public async getStreams(): Promise<[videoSteam: AdbSocket, controlStream: AdbSocket | undefined]> {
|
|
118
|
+
const videoStream = await this.accept();
|
|
119
|
+
|
|
106
120
|
let controlStream: AdbSocket | undefined;
|
|
107
121
|
if (this.options.control) {
|
|
108
122
|
controlStream = await this.accept();
|
|
109
123
|
}
|
|
124
|
+
|
|
125
|
+
// Server only writes device meta after control socket is connected (if enabled)
|
|
110
126
|
if (this.options.sendDeviceMeta) {
|
|
127
|
+
const reader = videoStream.readable.getReader();
|
|
128
|
+
const { done, value } = await reader.read();
|
|
111
129
|
// 64 bytes device name + 2 bytes video width + 2 bytes video height
|
|
112
|
-
|
|
130
|
+
if (done || value.byteLength !== 64 + 2 + 2) {
|
|
131
|
+
throw new Error('Unexpected response from server');
|
|
132
|
+
}
|
|
133
|
+
reader.releaseLock();
|
|
113
134
|
}
|
|
135
|
+
|
|
114
136
|
return [videoStream, controlStream];
|
|
115
137
|
}
|
|
116
138
|
|
|
@@ -55,7 +55,8 @@ export class WebCodecsDecoder implements H264Decoder {
|
|
|
55
55
|
break;
|
|
56
56
|
case 'frame':
|
|
57
57
|
this.decoder.decode(new EncodedVideoChunk({
|
|
58
|
-
|
|
58
|
+
// Treat `undefined` as `key`, otherwise won't decode.
|
|
59
|
+
type: packet.keyframe === false ? 'delta' : 'key',
|
|
59
60
|
timestamp: 0,
|
|
60
61
|
data: packet.data,
|
|
61
62
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StructDeserializeStream, TransformStream, type Adb } from "@yume-chan/adb";
|
|
2
2
|
import Struct, { placeholder } from "@yume-chan/struct";
|
|
3
3
|
import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
|
|
4
4
|
import { ScrcpyClientConnection, ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnectionOptions } from "../../connection.js";
|
|
@@ -112,11 +112,11 @@ export interface ScrcpyOptionsInit1_16 {
|
|
|
112
112
|
|
|
113
113
|
export const VideoPacket =
|
|
114
114
|
new Struct()
|
|
115
|
-
.
|
|
115
|
+
.uint64('pts')
|
|
116
116
|
.uint32('size')
|
|
117
117
|
.uint8Array('data', { lengthField: 'size' });
|
|
118
118
|
|
|
119
|
-
export const
|
|
119
|
+
export const NO_PTS = BigInt(1) << BigInt(63);
|
|
120
120
|
|
|
121
121
|
export const ScrcpyBackOrScreenOnEvent1_16 =
|
|
122
122
|
new Struct()
|
|
@@ -211,29 +211,28 @@ export class ScrcpyOptions1_16<T extends ScrcpyOptionsInit1_16 = ScrcpyOptionsIn
|
|
|
211
211
|
return /\s+scrcpy --encoder-name '(.*?)'/;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
public
|
|
214
|
+
public createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket> {
|
|
215
215
|
// Optimized path for video frames only
|
|
216
216
|
if (this.value.sendFrameMeta === false) {
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
},
|
|
226
|
-
}));
|
|
217
|
+
return new TransformStream({
|
|
218
|
+
transform(chunk, controller) {
|
|
219
|
+
controller.enqueue({
|
|
220
|
+
type: 'frame',
|
|
221
|
+
data: chunk,
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
});
|
|
227
225
|
}
|
|
228
226
|
|
|
229
227
|
let header: Uint8Array | undefined;
|
|
230
228
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
229
|
+
let deserializeStream = new StructDeserializeStream(VideoPacket);
|
|
230
|
+
return {
|
|
231
|
+
writable: deserializeStream.writable,
|
|
232
|
+
readable: deserializeStream.readable.pipeThrough(new TransformStream({
|
|
233
|
+
transform(packet, controller) {
|
|
234
|
+
if (packet.pts === NO_PTS) {
|
|
235
|
+
const sequenceParameterSet = parse_sequence_parameter_set(packet.data.slice().buffer);
|
|
237
236
|
|
|
238
237
|
const {
|
|
239
238
|
profile_idc: profileIndex,
|
|
@@ -258,7 +257,7 @@ export class ScrcpyOptions1_16<T extends ScrcpyOptionsInit1_16 = ScrcpyOptionsIn
|
|
|
258
257
|
const croppedWidth = encodedWidth - cropLeft - cropRight;
|
|
259
258
|
const croppedHeight = encodedHeight - cropTop - cropBottom;
|
|
260
259
|
|
|
261
|
-
header = data;
|
|
260
|
+
header = packet.data;
|
|
262
261
|
controller.enqueue({
|
|
263
262
|
type: 'configuration',
|
|
264
263
|
data: {
|
|
@@ -280,28 +279,22 @@ export class ScrcpyOptions1_16<T extends ScrcpyOptionsInit1_16 = ScrcpyOptionsIn
|
|
|
280
279
|
|
|
281
280
|
let frameData: Uint8Array;
|
|
282
281
|
if (header) {
|
|
283
|
-
frameData = new Uint8Array(header.byteLength + data.byteLength);
|
|
282
|
+
frameData = new Uint8Array(header.byteLength + packet.data.byteLength);
|
|
284
283
|
frameData.set(header);
|
|
285
|
-
frameData.set(data
|
|
284
|
+
frameData.set(packet.data, header.byteLength);
|
|
286
285
|
header = undefined;
|
|
287
286
|
} else {
|
|
288
|
-
frameData = data;
|
|
287
|
+
frameData = packet.data;
|
|
289
288
|
}
|
|
290
289
|
|
|
291
290
|
controller.enqueue({
|
|
292
291
|
type: 'frame',
|
|
292
|
+
pts: packet.pts,
|
|
293
293
|
data: frameData,
|
|
294
294
|
});
|
|
295
|
-
} catch (e) {
|
|
296
|
-
if (e instanceof BufferedStreamEndedError) {
|
|
297
|
-
controller.close();
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
throw e;
|
|
302
295
|
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
296
|
+
}))
|
|
297
|
+
};
|
|
305
298
|
}
|
|
306
299
|
|
|
307
300
|
public serializeBackOrScreenOnControlMessage(
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TransformStream } from "@yume-chan/adb";
|
|
2
|
+
import { ScrcpyOptions1_22, type ScrcpyOptionsInit1_22 } from './1_22.js';
|
|
3
|
+
import type { VideoStreamPacket } from "./common.js";
|
|
4
|
+
|
|
5
|
+
export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
|
|
6
|
+
cleanup: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const KEYFRAME_PTS = BigInt(1) << BigInt(62);
|
|
10
|
+
|
|
11
|
+
export class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23> extends ScrcpyOptions1_22<T> {
|
|
12
|
+
public constructor(init: Partial<ScrcpyOptionsInit1_23>) {
|
|
13
|
+
super(init);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected override getDefaultValue(): T {
|
|
17
|
+
return {
|
|
18
|
+
...super.getDefaultValue(),
|
|
19
|
+
cleanup: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public override createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket> {
|
|
24
|
+
const superStream = super.createVideoStreamTransformer();
|
|
25
|
+
return {
|
|
26
|
+
writable: superStream.writable,
|
|
27
|
+
readable: superStream.readable.pipeThrough(new TransformStream({
|
|
28
|
+
transform(packet, controller): void {
|
|
29
|
+
if (packet.type !== 'frame') {
|
|
30
|
+
controller.enqueue(packet);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (packet.pts !== undefined && packet.pts & KEYFRAME_PTS) {
|
|
35
|
+
packet.keyframe = true;
|
|
36
|
+
packet.pts &= ~KEYFRAME_PTS;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
controller.enqueue(packet);
|
|
40
|
+
}
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/options/common.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Adb,
|
|
1
|
+
import type { Adb, TransformStream } from "@yume-chan/adb";
|
|
2
2
|
import type { ScrcpyClientConnection } from "../connection.js";
|
|
3
3
|
import type { H264Configuration } from "../decoder/index.js";
|
|
4
4
|
import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js";
|
|
@@ -35,6 +35,8 @@ export interface VideoStreamConfigurationPacket {
|
|
|
35
35
|
|
|
36
36
|
export interface VideoStreamFramePacket {
|
|
37
37
|
type: 'frame';
|
|
38
|
+
keyframe?: boolean | undefined;
|
|
39
|
+
pts?: bigint | undefined;
|
|
38
40
|
data: Uint8Array;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -49,7 +51,7 @@ export interface ScrcpyOptions<T> {
|
|
|
49
51
|
|
|
50
52
|
createConnection(adb: Adb): ScrcpyClientConnection;
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
53
55
|
|
|
54
56
|
serializeBackOrScreenOnControlMessage(
|
|
55
57
|
message: ScrcpyBackOrScreenOnEvent1_18,
|
package/src/options/index.ts
CHANGED
package/src/push-server.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WrapWritableStream, type Adb, type AdbSync } from "@yume-chan/adb";
|
|
2
2
|
import { DEFAULT_SERVER_PATH } from "./options/index.js";
|
|
3
3
|
|
|
4
4
|
export interface PushServerOptions {
|
|
@@ -11,15 +11,13 @@ export function pushServer(
|
|
|
11
11
|
) {
|
|
12
12
|
const { path = DEFAULT_SERVER_PATH } = options;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
let sync!: AdbSync;
|
|
15
|
+
return new WrapWritableStream<Uint8Array>({
|
|
15
16
|
async start() {
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
writable: sync.write(path),
|
|
19
|
-
state: sync,
|
|
20
|
-
};
|
|
17
|
+
sync = await device.sync();
|
|
18
|
+
return sync.write(path);
|
|
21
19
|
},
|
|
22
|
-
async close(
|
|
20
|
+
async close() {
|
|
23
21
|
await sync.dispose();
|
|
24
22
|
},
|
|
25
23
|
});
|
package/src/utils.ts
CHANGED
|
@@ -3,14 +3,3 @@ export function delay(time: number): Promise<void> {
|
|
|
3
3
|
(globalThis as any).setTimeout(resolve, time);
|
|
4
4
|
});
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
const Utf8Encoder = new TextEncoder();
|
|
8
|
-
const Utf8Decoder = new TextDecoder();
|
|
9
|
-
|
|
10
|
-
export function encodeUtf8(input: string): ArrayBuffer {
|
|
11
|
-
return Utf8Encoder.encode(input).buffer;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function decodeUtf8(buffer: ArrayBuffer): string {
|
|
15
|
-
return Utf8Decoder.decode(buffer);
|
|
16
|
-
}
|