@yume-chan/scrcpy 0.0.19 → 0.0.21
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 +30 -0
- package/CHANGELOG.md +17 -1
- package/README.md +76 -266
- package/esm/codec/av1.js +2 -2
- package/esm/codec/av1.js.map +1 -1
- package/esm/codec/h264.d.ts +1 -21
- package/esm/codec/h264.d.ts.map +1 -1
- package/esm/codec/h264.js +15 -236
- package/esm/codec/h264.js.map +1 -1
- package/esm/codec/h265.d.ts +454 -0
- package/esm/codec/h265.d.ts.map +1 -1
- package/esm/codec/h265.js +1062 -2
- package/esm/codec/h265.js.map +1 -1
- package/esm/codec/index.d.ts +1 -0
- package/esm/codec/index.d.ts.map +1 -1
- package/esm/codec/index.js +1 -0
- package/esm/codec/index.js.map +1 -1
- package/esm/codec/nalu.d.ts +37 -0
- package/esm/codec/nalu.d.ts.map +1 -0
- package/esm/codec/nalu.js +323 -0
- package/esm/codec/nalu.js.map +1 -0
- package/esm/control/back-or-screen-on.d.ts +1 -1
- package/esm/control/back-or-screen-on.d.ts.map +1 -1
- package/esm/control/hover-helper.d.ts +1 -1
- package/esm/control/hover-helper.d.ts.map +1 -1
- package/esm/control/hover-helper.js +8 -9
- package/esm/control/hover-helper.js.map +1 -1
- package/esm/control/index.d.ts +2 -0
- package/esm/control/index.d.ts.map +1 -1
- package/esm/control/index.js +2 -0
- package/esm/control/index.js.map +1 -1
- package/esm/control/inject-keycode.d.ts +1 -2
- package/esm/control/inject-keycode.d.ts.map +1 -1
- package/esm/control/inject-keycode.js +4 -5
- package/esm/control/inject-keycode.js.map +1 -1
- package/esm/control/inject-text.d.ts +1 -2
- package/esm/control/inject-text.d.ts.map +1 -1
- package/esm/control/inject-text.js +1 -2
- package/esm/control/inject-text.js.map +1 -1
- package/esm/control/inject-touch.d.ts +15 -20
- package/esm/control/inject-touch.d.ts.map +1 -1
- package/esm/control/inject-touch.js +16 -43
- package/esm/control/inject-touch.js.map +1 -1
- package/esm/control/rotate-device.d.ts +2 -4
- package/esm/control/rotate-device.d.ts.map +1 -1
- package/esm/control/rotate-device.js +2 -3
- package/esm/control/rotate-device.js.map +1 -1
- package/esm/control/serializer.d.ts +11 -23
- package/esm/control/serializer.d.ts.map +1 -1
- package/esm/control/serializer.js +23 -52
- package/esm/control/serializer.js.map +1 -1
- package/esm/control/set-screen-power-mode.d.ts +1 -2
- package/esm/control/set-screen-power-mode.d.ts.map +1 -1
- package/esm/control/set-screen-power-mode.js +2 -3
- package/esm/control/set-screen-power-mode.js.map +1 -1
- package/esm/control/type.d.ts +14 -0
- package/esm/control/type.d.ts.map +1 -1
- package/esm/control/type.js +23 -1
- package/esm/control/type.js.map +1 -1
- package/esm/control/writer.d.ts +26 -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/stream.d.ts.map +1 -1
- package/esm/device-message/stream.js +23 -8
- package/esm/device-message/stream.js.map +1 -1
- package/esm/device-message/type.js +1 -1
- package/esm/device-message/type.js.map +1 -1
- package/esm/index.d.ts +1 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -2
- package/esm/index.js.map +1 -1
- package/esm/options/1_16/codec-options.d.ts +2 -3
- package/esm/options/1_16/codec-options.d.ts.map +1 -1
- package/esm/options/1_16/codec-options.js.map +1 -1
- package/esm/options/1_16/index.d.ts +3 -1
- package/esm/options/1_16/index.d.ts.map +1 -1
- package/esm/options/1_16/index.js +3 -1
- package/esm/options/1_16/index.js.map +1 -1
- package/esm/options/1_16/init.js +2 -2
- package/esm/options/1_16/init.js.map +1 -1
- package/esm/options/1_16/options.d.ts +42 -96
- package/esm/options/1_16/options.d.ts.map +1 -1
- package/esm/options/1_16/options.js +104 -142
- package/esm/options/1_16/options.js.map +1 -1
- package/esm/options/1_16/scroll.d.ts +2 -4
- package/esm/options/1_16/scroll.d.ts.map +1 -1
- package/esm/options/1_16/scroll.js +13 -14
- package/esm/options/1_16/scroll.js.map +1 -1
- package/esm/options/1_17.d.ts +1 -0
- package/esm/options/1_17.d.ts.map +1 -1
- package/esm/options/1_17.js +8 -3
- package/esm/options/1_17.js.map +1 -1
- package/esm/options/1_18.d.ts +49 -11
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +64 -32
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.d.ts +26 -7
- package/esm/options/1_21.d.ts.map +1 -1
- package/esm/options/1_21.js +34 -20
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22/index.d.ts +1 -0
- package/esm/options/1_22/index.d.ts.map +1 -1
- package/esm/options/1_22/index.js +1 -0
- package/esm/options/1_22/index.js.map +1 -1
- package/esm/options/1_22/options.d.ts +32 -26
- package/esm/options/1_22/options.d.ts.map +1 -1
- package/esm/options/1_22/options.js +26 -16
- package/esm/options/1_22/options.js.map +1 -1
- package/esm/options/1_22/scroll.d.ts +1 -1
- package/esm/options/1_22/scroll.d.ts.map +1 -1
- package/esm/options/1_22/scroll.js +1 -1
- package/esm/options/1_22/scroll.js.map +1 -1
- package/esm/options/1_23.d.ts +32 -8
- package/esm/options/1_23.d.ts.map +1 -1
- package/esm/options/1_23.js +23 -14
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts +29 -4
- package/esm/options/1_24.d.ts.map +1 -1
- package/esm/options/1_24.js +16 -7
- package/esm/options/1_24.js.map +1 -1
- package/esm/options/1_25/options.d.ts +6 -2
- package/esm/options/1_25/options.d.ts.map +1 -1
- package/esm/options/1_25/options.js +16 -2
- package/esm/options/1_25/options.js.map +1 -1
- package/esm/options/1_25/scroll.d.ts.map +1 -1
- package/esm/options/1_25/scroll.js +2 -1
- package/esm/options/1_25/scroll.js.map +1 -1
- package/esm/options/2_0.d.ts +12 -8
- package/esm/options/2_0.d.ts.map +1 -1
- package/esm/options/2_0.js +82 -15
- package/esm/options/2_0.js.map +1 -1
- package/esm/options/2_1.d.ts +48 -0
- package/esm/options/2_1.d.ts.map +1 -0
- package/esm/options/2_1.js +23 -0
- package/esm/options/2_1.js.map +1 -0
- package/esm/options/codec.d.ts +4 -4
- package/esm/options/codec.d.ts.map +1 -1
- package/esm/options/codec.js +5 -6
- package/esm/options/codec.js.map +1 -1
- package/esm/options/index.d.ts +5 -0
- package/esm/options/index.d.ts.map +1 -1
- package/esm/options/index.js +5 -0
- package/esm/options/index.js.map +1 -1
- package/esm/options/latest.d.ts +4 -5
- package/esm/options/latest.d.ts.map +1 -1
- package/esm/options/latest.js +2 -3
- package/esm/options/latest.js.map +1 -1
- package/esm/options/types.d.ts +74 -33
- package/esm/options/types.d.ts.map +1 -1
- package/esm/options/types.js +62 -0
- package/esm/options/types.js.map +1 -1
- package/package.json +9 -19
- 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 +391 -0
- package/src/control/back-or-screen-on.ts +1 -1
- package/{esm/control/simple.js → src/control/basic.ts} +3 -3
- package/src/control/hover-helper.ts +10 -11
- package/src/control/index.ts +2 -0
- package/src/control/inject-keycode.ts +1 -3
- package/src/control/inject-text.ts +1 -3
- package/src/control/inject-touch.ts +16 -55
- package/src/control/rotate-device.ts +2 -7
- package/src/control/serializer.ts +50 -113
- package/src/control/set-screen-power-mode.ts +1 -3
- package/src/control/type.ts +32 -0
- package/src/control/writer.ts +85 -0
- package/src/device-message/stream.ts +32 -12
- package/src/index.ts +1 -2
- package/src/options/1_16/codec-options.ts +6 -7
- 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 +147 -260
- package/src/options/1_16/scroll.ts +17 -18
- package/src/options/1_17.ts +66 -0
- package/src/options/1_18.ts +103 -39
- package/src/options/1_21.ts +49 -27
- 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 +38 -45
- package/src/options/1_22/scroll.ts +3 -3
- package/src/options/1_23.ts +34 -22
- package/src/options/1_24.ts +23 -11
- package/src/options/1_25/options.ts +22 -4
- package/src/options/1_25/scroll.ts +4 -3
- package/src/options/2_0.ts +342 -0
- package/src/options/2_1.ts +35 -0
- package/src/options/codec.ts +98 -0
- package/src/options/index.ts +5 -0
- package/src/options/latest.ts +12 -0
- package/src/options/types.ts +164 -43
- package/tsconfig.build.json +9 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +0 -1
- package/bin/version.js +0 -1
- package/esm/adb/client.d.ts +0 -41
- package/esm/adb/client.d.ts.map +0 -1
- package/esm/adb/client.js +0 -224
- package/esm/adb/client.js.map +0 -1
- package/esm/adb/connection.d.ts +0 -49
- package/esm/adb/connection.d.ts.map +0 -1
- package/esm/adb/connection.js +0 -122
- 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/1_26.d.ts +0 -9
- package/esm/adb/options/1_26.d.ts.map +0 -1
- package/esm/adb/options/1_26.js +0 -11
- package/esm/adb/options/1_26.js.map +0 -1
- package/esm/adb/options/2_0.d.ts +0 -8
- package/esm/adb/options/2_0.d.ts.map +0 -1
- package/esm/adb/options/2_0.js +0 -13
- package/esm/adb/options/2_0.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/control/simple.d.ts +0 -5
- package/esm/control/simple.d.ts.map +0 -1
- package/esm/control/simple.js.map +0 -1
- package/esm/decoder.d.ts +0 -2
- package/esm/decoder.d.ts.map +0 -1
- package/esm/decoder.js +0 -2
- package/esm/decoder.js.map +0 -1
- package/esm/options/1.17.d.ts +0 -3
- package/esm/options/1.17.d.ts.map +0 -1
- package/esm/options/1.17.js +0 -2
- package/esm/options/1.17.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/esm/options/1_26.d.ts +0 -57
- package/esm/options/1_26.d.ts.map +0 -1
- package/esm/options/1_26.js +0 -67
- package/esm/options/1_26.js.map +0 -1
- package/esm/options/2.d.ts +0 -57
- package/esm/options/2.d.ts.map +0 -1
- package/esm/options/2.js +0 -67
- package/esm/options/2.js.map +0 -1
- package/scripts/fetch-server.cjs +0 -38
- package/src/adb/client.ts +0 -329
- package/src/adb/connection.ts +0 -209
- package/src/adb/index.ts +0 -3
- package/src/adb/options/1_16.ts +0 -32
- 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/types.d.ts
CHANGED
|
@@ -1,47 +1,88 @@
|
|
|
1
|
-
import type { TransformStream } from "@yume-chan/stream-extra";
|
|
2
|
-
import type {
|
|
1
|
+
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import type { ScrcpyBackOrScreenOnControlMessage, ScrcpyControlMessageType, ScrcpyInjectTouchControlMessage, ScrcpySetClipboardControlMessage } from "../control/index.js";
|
|
3
4
|
import type { ScrcpyScrollController } from "./1_16/scroll.js";
|
|
5
|
+
import type { ScrcpyAudioStreamMetadata, ScrcpyMediaStreamPacket, ScrcpyVideoStream } from "./codec.js";
|
|
4
6
|
export declare const DEFAULT_SERVER_PATH = "/data/local/tmp/scrcpy-server.jar";
|
|
5
7
|
export interface ScrcpyOptionValue {
|
|
6
8
|
toOptionValue(): string | undefined;
|
|
7
9
|
}
|
|
8
10
|
export declare function isScrcpyOptionValue(value: unknown): value is ScrcpyOptionValue;
|
|
9
11
|
export declare function toScrcpyOptionValue<T>(value: unknown, empty: T): string | T;
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
encodedWidth: number;
|
|
15
|
-
encodedHeight: number;
|
|
16
|
-
cropLeft: number;
|
|
17
|
-
cropRight: number;
|
|
18
|
-
cropTop: number;
|
|
19
|
-
cropBottom: number;
|
|
20
|
-
croppedWidth: number;
|
|
21
|
-
croppedHeight: number;
|
|
12
|
+
export interface ScrcpyEncoder {
|
|
13
|
+
type: "video" | "audio";
|
|
14
|
+
codec?: string;
|
|
15
|
+
name: string;
|
|
22
16
|
}
|
|
23
|
-
export interface
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pictureParameterSet: Uint8Array;
|
|
27
|
-
data: H264Configuration;
|
|
17
|
+
export interface ScrcpyDisplay {
|
|
18
|
+
id: number;
|
|
19
|
+
resolution?: string;
|
|
28
20
|
}
|
|
29
|
-
export interface ScrcpyVideoStreamFramePacket {
|
|
30
|
-
type: "frame";
|
|
31
|
-
keyframe?: boolean;
|
|
32
|
-
pts?: bigint;
|
|
33
|
-
data: Uint8Array;
|
|
34
|
-
}
|
|
35
|
-
export type ScrcpyVideoStreamPacket = ScrcpyVideoStreamConfigurationPacket | ScrcpyVideoStreamFramePacket;
|
|
36
21
|
export interface ScrcpyOptions<T extends object> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
readonly defaults: Required<T>;
|
|
23
|
+
readonly controlMessageTypes: readonly ScrcpyControlMessageType[];
|
|
24
|
+
readonly value: Required<T>;
|
|
25
|
+
serialize(): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Set the essential options to let Scrcpy server print out available encoders.
|
|
28
|
+
*/
|
|
29
|
+
setListEncoders(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set the essential options to let Scrcpy server print out available displays.
|
|
32
|
+
*/
|
|
33
|
+
setListDisplays(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Parse encoder information from Scrcpy server output
|
|
36
|
+
* @param line One line of Scrcpy server output
|
|
37
|
+
*/
|
|
38
|
+
parseEncoder(line: string): ScrcpyEncoder | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Parse display information from Scrcpy server output
|
|
41
|
+
* @param line One line of Scrcpy server output
|
|
42
|
+
*/
|
|
43
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Parse the device metadata from video stream according to the current version and options.
|
|
46
|
+
* @param stream The video stream.
|
|
47
|
+
* @returns
|
|
48
|
+
* A tuple of the video stream and the metadata.
|
|
49
|
+
*
|
|
50
|
+
* The returned video stream may be different from the input stream, and should be used for further processing.
|
|
51
|
+
*/
|
|
52
|
+
parseVideoStreamMetadata(stream: ReadableStream<Uint8Array>): ValueOrPromise<ScrcpyVideoStream>;
|
|
53
|
+
parseAudioStreamMetadata(stream: ReadableStream<Uint8Array>): ValueOrPromise<ScrcpyAudioStreamMetadata>;
|
|
54
|
+
createMediaStreamTransformer(): TransformStream<Uint8Array, ScrcpyMediaStreamPacket>;
|
|
55
|
+
serializeInjectTouchControlMessage(message: ScrcpyInjectTouchControlMessage): Uint8Array;
|
|
56
|
+
serializeBackOrScreenOnControlMessage(message: ScrcpyBackOrScreenOnControlMessage): Uint8Array | undefined;
|
|
57
|
+
serializeSetClipboardControlMessage(message: ScrcpySetClipboardControlMessage): Uint8Array;
|
|
58
|
+
createScrollController(): ScrcpyScrollController;
|
|
59
|
+
}
|
|
60
|
+
export declare abstract class ScrcpyOptionsBase<T extends object, B extends ScrcpyOptions<object>> implements ScrcpyOptions<T> {
|
|
61
|
+
#private;
|
|
62
|
+
protected _base: B;
|
|
63
|
+
abstract get defaults(): Required<T>;
|
|
64
|
+
get controlMessageTypes(): readonly ScrcpyControlMessageType[];
|
|
65
|
+
readonly value: Required<T>;
|
|
66
|
+
constructor(base: B, value: Required<T>);
|
|
67
|
+
abstract serialize(): string[];
|
|
68
|
+
setListEncoders(): void;
|
|
69
|
+
setListDisplays(): void;
|
|
70
|
+
parseEncoder(line: string): ScrcpyEncoder | undefined;
|
|
71
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Parse the device metadata from video stream according to the current version and options.
|
|
74
|
+
* @param stream The video stream.
|
|
75
|
+
* @returns
|
|
76
|
+
* A tuple of the video stream and the metadata.
|
|
77
|
+
*
|
|
78
|
+
* The returned video stream may be different from the input stream, and should be used for further processing.
|
|
79
|
+
*/
|
|
80
|
+
parseVideoStreamMetadata(stream: ReadableStream<Uint8Array>): ValueOrPromise<ScrcpyVideoStream>;
|
|
81
|
+
parseAudioStreamMetadata(stream: ReadableStream<Uint8Array>): ValueOrPromise<ScrcpyAudioStreamMetadata>;
|
|
82
|
+
createMediaStreamTransformer(): TransformStream<Uint8Array, ScrcpyMediaStreamPacket>;
|
|
83
|
+
serializeInjectTouchControlMessage(message: ScrcpyInjectTouchControlMessage): Uint8Array;
|
|
43
84
|
serializeBackOrScreenOnControlMessage(message: ScrcpyBackOrScreenOnControlMessage): Uint8Array | undefined;
|
|
44
85
|
serializeSetClipboardControlMessage(message: ScrcpySetClipboardControlMessage): Uint8Array;
|
|
45
|
-
|
|
86
|
+
createScrollController(): ScrcpyScrollController;
|
|
46
87
|
}
|
|
47
88
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/options/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/options/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EACR,kCAAkC,EAClC,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EACnC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EACR,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,mBAAmB,sCAAsC,CAAC;AAEvE,MAAM,WAAW,iBAAiB;IAC9B,aAAa,IAAI,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,iBAAiB,CAO5B;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,CAW3E;AAED,MAAM,WAAW,aAAa;I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17
|
}
|
|
18
|
+
export class ScrcpyOptionsBase {
|
|
19
|
+
_base;
|
|
20
|
+
get controlMessageTypes() {
|
|
21
|
+
return this._base.controlMessageTypes;
|
|
22
|
+
}
|
|
23
|
+
value;
|
|
24
|
+
constructor(base, value) {
|
|
25
|
+
this._base = base;
|
|
26
|
+
this.value = value;
|
|
27
|
+
this.#setValue();
|
|
28
|
+
}
|
|
29
|
+
#setValue() {
|
|
30
|
+
// Share `value` with `_base` class,
|
|
31
|
+
// so updating `_base.value` in `_base.setListEncoders()`/
|
|
32
|
+
// `_base.setListDisplays()` will also update `this.value`.
|
|
33
|
+
Object.assign(this._base, { value: this.value });
|
|
34
|
+
if (this._base instanceof ScrcpyOptionsBase) {
|
|
35
|
+
this._base.#setValue();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
setListEncoders() {
|
|
39
|
+
this._base.setListEncoders();
|
|
40
|
+
}
|
|
41
|
+
setListDisplays() {
|
|
42
|
+
this._base.setListDisplays();
|
|
43
|
+
}
|
|
44
|
+
parseEncoder(line) {
|
|
45
|
+
return this._base.parseEncoder(line);
|
|
46
|
+
}
|
|
47
|
+
parseDisplay(line) {
|
|
48
|
+
return this._base.parseDisplay(line);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse the device metadata from video stream according to the current version and options.
|
|
52
|
+
* @param stream The video stream.
|
|
53
|
+
* @returns
|
|
54
|
+
* A tuple of the video stream and the metadata.
|
|
55
|
+
*
|
|
56
|
+
* The returned video stream may be different from the input stream, and should be used for further processing.
|
|
57
|
+
*/
|
|
58
|
+
parseVideoStreamMetadata(stream) {
|
|
59
|
+
return this._base.parseVideoStreamMetadata(stream);
|
|
60
|
+
}
|
|
61
|
+
parseAudioStreamMetadata(stream) {
|
|
62
|
+
return this._base.parseAudioStreamMetadata(stream);
|
|
63
|
+
}
|
|
64
|
+
createMediaStreamTransformer() {
|
|
65
|
+
return this._base.createMediaStreamTransformer();
|
|
66
|
+
}
|
|
67
|
+
serializeInjectTouchControlMessage(message) {
|
|
68
|
+
return this._base.serializeInjectTouchControlMessage(message);
|
|
69
|
+
}
|
|
70
|
+
serializeBackOrScreenOnControlMessage(message) {
|
|
71
|
+
return this._base.serializeBackOrScreenOnControlMessage(message);
|
|
72
|
+
}
|
|
73
|
+
serializeSetClipboardControlMessage(message) {
|
|
74
|
+
return this._base.serializeSetClipboardControlMessage(message);
|
|
75
|
+
}
|
|
76
|
+
createScrollController() {
|
|
77
|
+
return this._base.createScrollController();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
18
80
|
//# sourceMappingURL=types.js.map
|
package/esm/options/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/options/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/options/types.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAMvE,MAAM,UAAU,mBAAmB,CAC/B,KAAc;IAEd,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,eAAe,IAAI,KAAK;QACxB,OAAO,KAAK,CAAC,aAAa,KAAK,UAAU,CAC5C,CAAC;AACN,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAI,KAAc,EAAE,KAAQ;IAC3D,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;QAC5B,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;KACjC;IAED,uDAAuD;IACvD,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAgFD,MAAM,OAAgB,iBAAiB;IAKzB,KAAK,CAAI;IAInB,IAAI,mBAAmB;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC;IAC1C,CAAC;I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,qCAAqC,CACjC,OAA2C;QAE3C,OAAO,IAAI,CAAC,KAAK,CAAC,qCAAqC,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,mCAAmC,CAC/B,OAAyC;QAEzC,OAAO,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;IAED,sBAAsB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC;IAC/C,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/scrcpy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "TypeScript implementation of Scrcpy.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -22,40 +22,30 @@
|
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
|
24
24
|
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"fetch-scrcpy-server": "scripts/fetch-server.cjs"
|
|
27
|
-
},
|
|
28
25
|
"type": "module",
|
|
29
26
|
"main": "esm/index.js",
|
|
30
27
|
"types": "esm/index.d.ts",
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"@yume-chan/
|
|
33
|
-
"@yume-chan/
|
|
34
|
-
"
|
|
35
|
-
"@yume-chan/struct": "^0.0.19",
|
|
36
|
-
"tslib": "^2.4.1"
|
|
29
|
+
"@yume-chan/stream-extra": "^0.0.21",
|
|
30
|
+
"@yume-chan/struct": "^0.0.21",
|
|
31
|
+
"tslib": "^2.6.0"
|
|
37
32
|
},
|
|
38
33
|
"devDependencies": {
|
|
39
|
-
"@jest/globals": "^29.
|
|
40
|
-
"@yume-chan/adb": "^0.0.19",
|
|
34
|
+
"@jest/globals": "^29.6.1",
|
|
41
35
|
"@yume-chan/eslint-config": "^1.0.0",
|
|
42
36
|
"@yume-chan/tsconfig": "^1.0.0",
|
|
43
37
|
"cross-env": "^7.0.3",
|
|
44
|
-
"eslint": "^8.
|
|
38
|
+
"eslint": "^8.44.0",
|
|
45
39
|
"gh-release-fetch": "^3.0.2",
|
|
46
40
|
"jest": "^29.5.0",
|
|
47
|
-
"prettier": "^
|
|
48
|
-
"ts-jest": "^29.
|
|
49
|
-
"typescript": "^
|
|
41
|
+
"prettier": "^3.0.0",
|
|
42
|
+
"ts-jest": "^29.1.1",
|
|
43
|
+
"typescript": "^5.1.6"
|
|
50
44
|
},
|
|
51
45
|
"peerDependencies": {
|
|
52
|
-
"@yume-chan/adb": "^0.0.19",
|
|
53
46
|
"gh-release-fetch": "^3.0.2"
|
|
54
47
|
},
|
|
55
48
|
"peerDependenciesMeta": {
|
|
56
|
-
"@yume-chan/adb": {
|
|
57
|
-
"optional": true
|
|
58
|
-
},
|
|
59
49
|
"gh-release-fetch": {
|
|
60
50
|
"optional": true
|
|
61
51
|
}
|
package/src/codec/av1.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export enum AndroidAv1Profile {
|
|
2
|
+
Main8 = 1 << 0,
|
|
3
|
+
Main10 = 1 << 1,
|
|
4
|
+
Main10Hdr10 = 1 << 12,
|
|
5
|
+
Main10Hdr10Plus = 1 << 13,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum AndroidAv1Level {
|
|
9
|
+
Level2 = 1 << 0,
|
|
10
|
+
Level21 = 1 << 1,
|
|
11
|
+
Level22 = 1 << 2,
|
|
12
|
+
Level23 = 1 << 3,
|
|
13
|
+
Level3 = 1 << 4,
|
|
14
|
+
Level31 = 1 << 5,
|
|
15
|
+
Level32 = 1 << 6,
|
|
16
|
+
Level33 = 1 << 7,
|
|
17
|
+
Level4 = 1 << 8,
|
|
18
|
+
Level41 = 1 << 9,
|
|
19
|
+
Level42 = 1 << 10,
|
|
20
|
+
Level43 = 1 << 11,
|
|
21
|
+
Level5 = 1 << 12,
|
|
22
|
+
Level51 = 1 << 13,
|
|
23
|
+
Level52 = 1 << 14,
|
|
24
|
+
Level53 = 1 << 15,
|
|
25
|
+
Level6 = 1 << 16,
|
|
26
|
+
Level61 = 1 << 17,
|
|
27
|
+
Level62 = 1 << 18,
|
|
28
|
+
Level63 = 1 << 19,
|
|
29
|
+
Level7 = 1 << 20,
|
|
30
|
+
Level71 = 1 << 21,
|
|
31
|
+
Level72 = 1 << 22,
|
|
32
|
+
Level73 = 1 << 23,
|
|
33
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// cspell: ignore golomb
|
|
2
|
+
// cspell: ignore qpprime
|
|
3
|
+
// cspell: ignore colour
|
|
4
|
+
|
|
5
|
+
import { NaluSodbBitReader, annexBSplitNalu } from "./nalu.js";
|
|
6
|
+
|
|
7
|
+
// From https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel
|
|
8
|
+
export enum AndroidAvcProfile {
|
|
9
|
+
Baseline = 1 << 0,
|
|
10
|
+
Main = 1 << 1,
|
|
11
|
+
Extended = 1 << 2,
|
|
12
|
+
High = 1 << 3,
|
|
13
|
+
High10 = 1 << 4,
|
|
14
|
+
High422 = 1 << 5,
|
|
15
|
+
High444 = 1 << 6,
|
|
16
|
+
ConstrainedBaseline = 1 << 16,
|
|
17
|
+
ConstrainedHigh = 1 << 19,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum AndroidAvcLevel {
|
|
21
|
+
Level1 = 1 << 0,
|
|
22
|
+
Level1b = 1 << 1,
|
|
23
|
+
Level11 = 1 << 2,
|
|
24
|
+
Level12 = 1 << 3,
|
|
25
|
+
Level13 = 1 << 4,
|
|
26
|
+
Level2 = 1 << 5,
|
|
27
|
+
Level21 = 1 << 6,
|
|
28
|
+
Level22 = 1 << 7,
|
|
29
|
+
Level3 = 1 << 8,
|
|
30
|
+
Level31 = 1 << 9,
|
|
31
|
+
Level32 = 1 << 10,
|
|
32
|
+
Level4 = 1 << 11,
|
|
33
|
+
Level41 = 1 << 12,
|
|
34
|
+
Level42 = 1 << 13,
|
|
35
|
+
Level5 = 1 << 14,
|
|
36
|
+
Level51 = 1 << 15,
|
|
37
|
+
Level52 = 1 << 16,
|
|
38
|
+
Level6 = 1 << 17,
|
|
39
|
+
Level61 = 1 << 18,
|
|
40
|
+
Level62 = 1 << 19,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// H.264 has two standards: ITU-T H.264 and ISO/IEC 14496-10
|
|
44
|
+
// they have the same content, and refer themselves as "H.264".
|
|
45
|
+
// The name "AVC" (Advanced Video Coding) is only used in ISO spec name,
|
|
46
|
+
// and other ISO specs referring to H.264.
|
|
47
|
+
// Because this module parses H.264 Annex B format,
|
|
48
|
+
// it's named "h264" instead of "avc".
|
|
49
|
+
|
|
50
|
+
// 7.3.2.1.1 Sequence parameter set data syntax
|
|
51
|
+
// Variable names in this method uses the snake_case convention as in the spec for easier referencing.
|
|
52
|
+
export function h264ParseSequenceParameterSet(nalu: Uint8Array) {
|
|
53
|
+
const reader = new NaluSodbBitReader(nalu);
|
|
54
|
+
if (reader.next() !== 0) {
|
|
55
|
+
throw new Error("Invalid data");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const nal_ref_idc = reader.read(2);
|
|
59
|
+
const nal_unit_type = reader.read(5);
|
|
60
|
+
|
|
61
|
+
if (nal_unit_type !== 7) {
|
|
62
|
+
throw new Error("Invalid data");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (nal_ref_idc === 0) {
|
|
66
|
+
throw new Error("Invalid data");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const profile_idc = reader.read(8);
|
|
70
|
+
const constraint_set = reader.peek(8);
|
|
71
|
+
|
|
72
|
+
const constraint_set0_flag = !!reader.next();
|
|
73
|
+
const constraint_set1_flag = !!reader.next();
|
|
74
|
+
const constraint_set2_flag = !!reader.next();
|
|
75
|
+
const constraint_set3_flag = !!reader.next();
|
|
76
|
+
const constraint_set4_flag = !!reader.next();
|
|
77
|
+
const constraint_set5_flag = !!reader.next();
|
|
78
|
+
|
|
79
|
+
// reserved_zero_2bits
|
|
80
|
+
if (reader.read(2) !== 0) {
|
|
81
|
+
throw new Error("Invalid data");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const level_idc = reader.read(8);
|
|
85
|
+
const seq_parameter_set_id = reader.decodeExponentialGolombNumber();
|
|
86
|
+
|
|
87
|
+
if (
|
|
88
|
+
profile_idc === 100 ||
|
|
89
|
+
profile_idc === 110 ||
|
|
90
|
+
profile_idc === 122 ||
|
|
91
|
+
profile_idc === 244 ||
|
|
92
|
+
profile_idc === 44 ||
|
|
93
|
+
profile_idc === 83 ||
|
|
94
|
+
profile_idc === 86 ||
|
|
95
|
+
profile_idc === 118 ||
|
|
96
|
+
profile_idc === 128 ||
|
|
97
|
+
profile_idc === 138 ||
|
|
98
|
+
profile_idc === 139 ||
|
|
99
|
+
profile_idc === 134
|
|
100
|
+
) {
|
|
101
|
+
const chroma_format_idc = reader.decodeExponentialGolombNumber();
|
|
102
|
+
if (chroma_format_idc === 3) {
|
|
103
|
+
// separate_colour_plane_flag
|
|
104
|
+
reader.next();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// bit_depth_luma_minus8
|
|
108
|
+
reader.decodeExponentialGolombNumber();
|
|
109
|
+
// bit_depth_chroma_minus8
|
|
110
|
+
reader.decodeExponentialGolombNumber();
|
|
111
|
+
|
|
112
|
+
// qpprime_y_zero_transform_bypass_flag
|
|
113
|
+
reader.next();
|
|
114
|
+
|
|
115
|
+
const seq_scaling_matrix_present_flag = !!reader.next();
|
|
116
|
+
if (seq_scaling_matrix_present_flag) {
|
|
117
|
+
const seq_scaling_list_present_flag: boolean[] = [];
|
|
118
|
+
for (let i = 0; i < (chroma_format_idc !== 3 ? 8 : 12); i += 1) {
|
|
119
|
+
seq_scaling_list_present_flag[i] = !!reader.next();
|
|
120
|
+
if (seq_scaling_list_present_flag[i])
|
|
121
|
+
if (i < 6) {
|
|
122
|
+
// TODO
|
|
123
|
+
// scaling_list( ScalingList4x4[ i ], 16,
|
|
124
|
+
// UseDefaultScalingMatrix4x4Flag[ i ])
|
|
125
|
+
} else {
|
|
126
|
+
// TODO
|
|
127
|
+
// scaling_list( ScalingList8x8[ i − 6 ], 64,
|
|
128
|
+
// UseDefaultScalingMatrix8x8Flag[ i − 6 ] )
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// log2_max_frame_num_minus4
|
|
135
|
+
reader.decodeExponentialGolombNumber();
|
|
136
|
+
const pic_order_cnt_type = reader.decodeExponentialGolombNumber();
|
|
137
|
+
if (pic_order_cnt_type === 0) {
|
|
138
|
+
// log2_max_pic_order_cnt_lsb_minus4
|
|
139
|
+
reader.decodeExponentialGolombNumber();
|
|
140
|
+
} else if (pic_order_cnt_type === 1) {
|
|
141
|
+
// delta_pic_order_always_zero_flag
|
|
142
|
+
reader.next();
|
|
143
|
+
// offset_for_non_ref_pic
|
|
144
|
+
reader.decodeExponentialGolombNumber();
|
|
145
|
+
// offset_for_top_to_bottom_field
|
|
146
|
+
reader.decodeExponentialGolombNumber();
|
|
147
|
+
const num_ref_frames_in_pic_order_cnt_cycle =
|
|
148
|
+
reader.decodeExponentialGolombNumber();
|
|
149
|
+
const offset_for_ref_frame: number[] = [];
|
|
150
|
+
for (let i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i += 1) {
|
|
151
|
+
offset_for_ref_frame[i] = reader.decodeExponentialGolombNumber();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// max_num_ref_frames
|
|
156
|
+
reader.decodeExponentialGolombNumber();
|
|
157
|
+
// gaps_in_frame_num_value_allowed_flag
|
|
158
|
+
reader.next();
|
|
159
|
+
const pic_width_in_mbs_minus1 = reader.decodeExponentialGolombNumber();
|
|
160
|
+
const pic_height_in_map_units_minus1 =
|
|
161
|
+
reader.decodeExponentialGolombNumber();
|
|
162
|
+
|
|
163
|
+
const frame_mbs_only_flag = reader.next();
|
|
164
|
+
if (!frame_mbs_only_flag) {
|
|
165
|
+
// mb_adaptive_frame_field_flag
|
|
166
|
+
reader.next();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// direct_8x8_inference_flag
|
|
170
|
+
reader.next();
|
|
171
|
+
|
|
172
|
+
const frame_cropping_flag = !!reader.next();
|
|
173
|
+
let frame_crop_left_offset: number;
|
|
174
|
+
let frame_crop_right_offset: number;
|
|
175
|
+
let frame_crop_top_offset: number;
|
|
176
|
+
let frame_crop_bottom_offset: number;
|
|
177
|
+
if (frame_cropping_flag) {
|
|
178
|
+
frame_crop_left_offset = reader.decodeExponentialGolombNumber();
|
|
179
|
+
frame_crop_right_offset = reader.decodeExponentialGolombNumber();
|
|
180
|
+
frame_crop_top_offset = reader.decodeExponentialGolombNumber();
|
|
181
|
+
frame_crop_bottom_offset = reader.decodeExponentialGolombNumber();
|
|
182
|
+
} else {
|
|
183
|
+
frame_crop_left_offset = 0;
|
|
184
|
+
frame_crop_right_offset = 0;
|
|
185
|
+
frame_crop_top_offset = 0;
|
|
186
|
+
frame_crop_bottom_offset = 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const vui_parameters_present_flag = !!reader.next();
|
|
190
|
+
if (vui_parameters_present_flag) {
|
|
191
|
+
// TODO
|
|
192
|
+
// vui_parameters( )
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
profile_idc,
|
|
197
|
+
constraint_set,
|
|
198
|
+
constraint_set0_flag,
|
|
199
|
+
constraint_set1_flag,
|
|
200
|
+
constraint_set2_flag,
|
|
201
|
+
constraint_set3_flag,
|
|
202
|
+
constraint_set4_flag,
|
|
203
|
+
constraint_set5_flag,
|
|
204
|
+
level_idc,
|
|
205
|
+
seq_parameter_set_id,
|
|
206
|
+
pic_width_in_mbs_minus1,
|
|
207
|
+
pic_height_in_map_units_minus1,
|
|
208
|
+
frame_mbs_only_flag,
|
|
209
|
+
frame_cropping_flag,
|
|
210
|
+
frame_crop_left_offset,
|
|
211
|
+
frame_crop_right_offset,
|
|
212
|
+
frame_crop_top_offset,
|
|
213
|
+
frame_crop_bottom_offset,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Find Sequence Parameter Set (SPS) and Picture Parameter Set (PPS)
|
|
219
|
+
* from H.264 Annex B formatted data.
|
|
220
|
+
*/
|
|
221
|
+
export function h264SearchConfiguration(buffer: Uint8Array) {
|
|
222
|
+
let sequenceParameterSet: Uint8Array | undefined;
|
|
223
|
+
let pictureParameterSet: Uint8Array | undefined;
|
|
224
|
+
|
|
225
|
+
for (const nalu of annexBSplitNalu(buffer)) {
|
|
226
|
+
const naluType = nalu[0]! & 0x1f;
|
|
227
|
+
switch (naluType) {
|
|
228
|
+
case 7: // Sequence parameter set
|
|
229
|
+
sequenceParameterSet = nalu;
|
|
230
|
+
if (pictureParameterSet) {
|
|
231
|
+
return {
|
|
232
|
+
sequenceParameterSet,
|
|
233
|
+
pictureParameterSet,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case 8: // Picture parameter set
|
|
238
|
+
pictureParameterSet = nalu;
|
|
239
|
+
if (sequenceParameterSet) {
|
|
240
|
+
return {
|
|
241
|
+
sequenceParameterSet,
|
|
242
|
+
pictureParameterSet,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
// ignore
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
throw new Error("Invalid data");
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface H264Configuration {
|
|
256
|
+
pictureParameterSet: Uint8Array;
|
|
257
|
+
sequenceParameterSet: Uint8Array;
|
|
258
|
+
|
|
259
|
+
profileIndex: number;
|
|
260
|
+
constraintSet: number;
|
|
261
|
+
levelIndex: number;
|
|
262
|
+
|
|
263
|
+
encodedWidth: number;
|
|
264
|
+
encodedHeight: number;
|
|
265
|
+
|
|
266
|
+
cropLeft: number;
|
|
267
|
+
cropRight: number;
|
|
268
|
+
cropTop: number;
|
|
269
|
+
cropBottom: number;
|
|
270
|
+
croppedWidth: number;
|
|
271
|
+
croppedHeight: number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function h264ParseConfiguration(data: Uint8Array): H264Configuration {
|
|
275
|
+
const { sequenceParameterSet, pictureParameterSet } =
|
|
276
|
+
h264SearchConfiguration(data);
|
|
277
|
+
|
|
278
|
+
const {
|
|
279
|
+
profile_idc: profileIndex,
|
|
280
|
+
constraint_set: constraintSet,
|
|
281
|
+
level_idc: levelIndex,
|
|
282
|
+
pic_width_in_mbs_minus1,
|
|
283
|
+
pic_height_in_map_units_minus1,
|
|
284
|
+
frame_mbs_only_flag,
|
|
285
|
+
frame_crop_left_offset,
|
|
286
|
+
frame_crop_right_offset,
|
|
287
|
+
frame_crop_top_offset,
|
|
288
|
+
frame_crop_bottom_offset,
|
|
289
|
+
} = h264ParseSequenceParameterSet(sequenceParameterSet);
|
|
290
|
+
|
|
291
|
+
const encodedWidth = (pic_width_in_mbs_minus1 + 1) * 16;
|
|
292
|
+
const encodedHeight =
|
|
293
|
+
(pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag) * 16;
|
|
294
|
+
const cropLeft = frame_crop_left_offset * 2;
|
|
295
|
+
const cropRight = frame_crop_right_offset * 2;
|
|
296
|
+
const cropTop = frame_crop_top_offset * 2;
|
|
297
|
+
const cropBottom = frame_crop_bottom_offset * 2;
|
|
298
|
+
|
|
299
|
+
const croppedWidth = encodedWidth - cropLeft - cropRight;
|
|
300
|
+
const croppedHeight = encodedHeight - cropTop - cropBottom;
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
pictureParameterSet,
|
|
304
|
+
sequenceParameterSet,
|
|
305
|
+
profileIndex,
|
|
306
|
+
constraintSet,
|
|
307
|
+
levelIndex,
|
|
308
|
+
encodedWidth,
|
|
309
|
+
encodedHeight,
|
|
310
|
+
cropLeft,
|
|
311
|
+
cropRight,
|
|
312
|
+
cropTop,
|
|
313
|
+
cropBottom,
|
|
314
|
+
croppedWidth,
|
|
315
|
+
croppedHeight,
|
|
316
|
+
};
|
|
317
|
+
}
|