mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 17:59:50 +02:00
feat(scrcpy): add support for server version 3.3.1
This commit is contained in:
parent
7edd616b43
commit
e0def5b8ac
8 changed files with 217 additions and 5 deletions
5
.changeset/common-shoes-share.md
Normal file
5
.changeset/common-shoes-share.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@yume-chan/scrcpy": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for server version 3.3.1
|
6
libraries/scrcpy/src/3_3_1/impl/index.ts
Normal file
6
libraries/scrcpy/src/3_3_1/impl/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export * from "../../3_2/impl/index.js";
|
||||||
|
|
||||||
|
export {
|
||||||
|
createScrollController,
|
||||||
|
ScrollController,
|
||||||
|
} from "./scroll-controller.js";
|
1
libraries/scrcpy/src/3_3_1/impl/prev.ts
Normal file
1
libraries/scrcpy/src/3_3_1/impl/prev.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * as PrevImpl from "../../3_2/impl/index.js";
|
21
libraries/scrcpy/src/3_3_1/impl/scroll-controller.ts
Normal file
21
libraries/scrcpy/src/3_3_1/impl/scroll-controller.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import type { ScrcpyScrollController } from "../../base/index.js";
|
||||||
|
import type { ScrcpyInjectScrollControlMessage } from "../../latest.js";
|
||||||
|
|
||||||
|
import { PrevImpl } from "./prev.js";
|
||||||
|
|
||||||
|
export class ScrollController implements ScrcpyScrollController {
|
||||||
|
serializeScrollMessage(
|
||||||
|
message: ScrcpyInjectScrollControlMessage,
|
||||||
|
): Uint8Array | undefined {
|
||||||
|
message = {
|
||||||
|
...message,
|
||||||
|
scrollX: message.scrollX / 16,
|
||||||
|
scrollY: message.scrollY / 16,
|
||||||
|
};
|
||||||
|
return PrevImpl.InjectScrollControlMessage.serialize(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createScrollController(): ScrcpyScrollController {
|
||||||
|
return new ScrollController();
|
||||||
|
}
|
1
libraries/scrcpy/src/3_3_1/index.ts
Normal file
1
libraries/scrcpy/src/3_3_1/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./options.js";
|
177
libraries/scrcpy/src/3_3_1/options.ts
Normal file
177
libraries/scrcpy/src/3_3_1/options.ts
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
||||||
|
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
||||||
|
|
||||||
|
import type {
|
||||||
|
ScrcpyAudioStreamMetadata,
|
||||||
|
ScrcpyControlMessageType,
|
||||||
|
ScrcpyDisplay,
|
||||||
|
ScrcpyEncoder,
|
||||||
|
ScrcpyMediaStreamPacket,
|
||||||
|
ScrcpyOptions,
|
||||||
|
ScrcpyOptionsListEncoders,
|
||||||
|
ScrcpyScrollController,
|
||||||
|
ScrcpyVideoStream,
|
||||||
|
} from "../base/index.js";
|
||||||
|
import { ScrcpyDeviceMessageParsers } from "../base/index.js";
|
||||||
|
import type {
|
||||||
|
ScrcpyBackOrScreenOnControlMessage,
|
||||||
|
ScrcpyInjectTouchControlMessage,
|
||||||
|
ScrcpySetClipboardControlMessage,
|
||||||
|
ScrcpyUHidCreateControlMessage,
|
||||||
|
ScrcpyUHidOutputDeviceMessage,
|
||||||
|
} from "../latest.js";
|
||||||
|
|
||||||
|
import type { Init } from "./impl/index.js";
|
||||||
|
import {
|
||||||
|
AckClipboardHandler,
|
||||||
|
ClipboardStream,
|
||||||
|
ControlMessageTypes,
|
||||||
|
createMediaStreamTransformer,
|
||||||
|
createScrollController,
|
||||||
|
Defaults,
|
||||||
|
parseAudioStreamMetadata,
|
||||||
|
parseDisplay,
|
||||||
|
parseEncoder,
|
||||||
|
parseVideoStreamMetadata,
|
||||||
|
serialize,
|
||||||
|
serializeBackOrScreenOnControlMessage,
|
||||||
|
serializeInjectTouchControlMessage,
|
||||||
|
serializeUHidCreateControlMessage,
|
||||||
|
setListDisplays,
|
||||||
|
setListEncoders,
|
||||||
|
UHidOutputStream,
|
||||||
|
} from "./impl/index.js";
|
||||||
|
|
||||||
|
export class ScrcpyOptions3_3_1<TVideo extends boolean>
|
||||||
|
implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
|
||||||
|
{
|
||||||
|
static readonly Defaults = Defaults;
|
||||||
|
|
||||||
|
readonly value: Required<Init<TVideo>>;
|
||||||
|
|
||||||
|
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||||
|
return ControlMessageTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
#clipboard: ClipboardStream | undefined;
|
||||||
|
get clipboard(): ReadableStream<string> | undefined {
|
||||||
|
return this.#clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||||
|
|
||||||
|
#uHidOutput: UHidOutputStream | undefined;
|
||||||
|
get uHidOutput():
|
||||||
|
| ReadableStream<ScrcpyUHidOutputDeviceMessage>
|
||||||
|
| undefined {
|
||||||
|
return this.#uHidOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
||||||
|
get deviceMessageParsers() {
|
||||||
|
return this.#deviceMessageParsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(init: Init<TVideo>) {
|
||||||
|
this.value = { ...Defaults, ...init } as never;
|
||||||
|
|
||||||
|
if (this.value.videoSource === "camera") {
|
||||||
|
this.value.control = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.value.audioDup) {
|
||||||
|
this.value.audioSource = "playback";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.value.control) {
|
||||||
|
if (this.value.clipboardAutosync) {
|
||||||
|
this.#clipboard = this.#deviceMessageParsers.add(
|
||||||
|
new ClipboardStream(),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
||||||
|
new AckClipboardHandler(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#uHidOutput = this.#deviceMessageParsers.add(
|
||||||
|
new UHidOutputStream(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serialize(): string[] {
|
||||||
|
return serialize<Init<boolean>>(this.value, Defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
setListDisplays(): void {
|
||||||
|
setListDisplays(this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
||||||
|
return parseDisplay(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
setListEncoders() {
|
||||||
|
setListEncoders(this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseEncoder(line: string): ScrcpyEncoder | undefined {
|
||||||
|
return parseEncoder(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseVideoStreamMetadata(
|
||||||
|
stream: ReadableStream<Uint8Array>,
|
||||||
|
): MaybePromiseLike<ScrcpyVideoStream> {
|
||||||
|
return parseVideoStreamMetadata(this.value, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseAudioStreamMetadata(
|
||||||
|
stream: ReadableStream<Uint8Array>,
|
||||||
|
): MaybePromiseLike<ScrcpyAudioStreamMetadata> {
|
||||||
|
return parseAudioStreamMetadata(stream, this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
createMediaStreamTransformer(): TransformStream<
|
||||||
|
Uint8Array,
|
||||||
|
ScrcpyMediaStreamPacket
|
||||||
|
> {
|
||||||
|
return createMediaStreamTransformer(this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
serializeInjectTouchControlMessage(
|
||||||
|
message: ScrcpyInjectTouchControlMessage,
|
||||||
|
): Uint8Array {
|
||||||
|
return serializeInjectTouchControlMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
serializeBackOrScreenOnControlMessage(
|
||||||
|
message: ScrcpyBackOrScreenOnControlMessage,
|
||||||
|
): Uint8Array | undefined {
|
||||||
|
return serializeBackOrScreenOnControlMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
serializeSetClipboardControlMessage(
|
||||||
|
message: ScrcpySetClipboardControlMessage,
|
||||||
|
): Uint8Array | [Uint8Array, Promise<void>] {
|
||||||
|
return this.#ackClipboardHandler!.serializeSetClipboardControlMessage(
|
||||||
|
message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
createScrollController(): ScrcpyScrollController {
|
||||||
|
return createScrollController();
|
||||||
|
}
|
||||||
|
|
||||||
|
serializeUHidCreateControlMessage(
|
||||||
|
message: ScrcpyUHidCreateControlMessage,
|
||||||
|
): Uint8Array {
|
||||||
|
return serializeUHidCreateControlMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Init_<TVideo extends boolean> = Init<TVideo>;
|
||||||
|
|
||||||
|
export namespace ScrcpyOptions3_3_1 {
|
||||||
|
export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ export * from "./3_0_2.js";
|
||||||
export * from "./3_1/index.js";
|
export * from "./3_1/index.js";
|
||||||
export * from "./3_2/index.js";
|
export * from "./3_2/index.js";
|
||||||
export * from "./3_3.js";
|
export * from "./3_3.js";
|
||||||
|
export * from "./3_3_1/index.js";
|
||||||
export * from "./android/index.js";
|
export * from "./android/index.js";
|
||||||
export * from "./base/index.js";
|
export * from "./base/index.js";
|
||||||
export * from "./codec/index.js";
|
export * from "./codec/index.js";
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { ScrcpyOptions3_3 } from "./3_3.js";
|
import { ScrcpyOptions3_3_1 } from "./3_3_1/index.js";
|
||||||
|
|
||||||
export class ScrcpyOptionsLatest<
|
export class ScrcpyOptionsLatest<
|
||||||
TVideo extends boolean,
|
TVideo extends boolean,
|
||||||
> extends ScrcpyOptions3_3<TVideo> {
|
> extends ScrcpyOptions3_3_1<TVideo> {
|
||||||
constructor(init: ScrcpyOptions3_3.Init<TVideo>) {
|
constructor(init: ScrcpyOptions3_3_1.Init<TVideo>) {
|
||||||
super(init);
|
super(init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace ScrcpyOptionsLatest {
|
export namespace ScrcpyOptionsLatest {
|
||||||
export type Init<TVideo extends boolean = boolean> =
|
export type Init<TVideo extends boolean = boolean> =
|
||||||
ScrcpyOptions3_3.Init<TVideo>;
|
ScrcpyOptions3_3_1.Init<TVideo>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -28,4 +28,4 @@ export {
|
||||||
SetClipboardControlMessage as ScrcpySetClipboardControlMessage,
|
SetClipboardControlMessage as ScrcpySetClipboardControlMessage,
|
||||||
UHidCreateControlMessage as ScrcpyUHidCreateControlMessage,
|
UHidCreateControlMessage as ScrcpyUHidCreateControlMessage,
|
||||||
UHidOutputDeviceMessage as ScrcpyUHidOutputDeviceMessage,
|
UHidOutputDeviceMessage as ScrcpyUHidOutputDeviceMessage,
|
||||||
} from "./3_2/impl/index.js";
|
} from "./3_3_1/impl/index.js";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue