mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
fix(scrcpy): fix UHID output stream from server version 2.6
This commit also replaced `ScrcpyOptions`'s `parseDeviceMessage`/`endDeviceMessageStream` methods with `deviceMessageParsers`. If you are using that two methods directly, you need to move to the new API
This commit is contained in:
parent
eff718ce36
commit
7edd616b43
28 changed files with 341 additions and 555 deletions
|
@ -1,6 +1,5 @@
|
|||
import type { MaybePromiseLike } from "@yume-chan/async";
|
||||
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
||||
import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
|
||||
|
||||
import type {
|
||||
ScrcpyControlMessageType,
|
||||
|
@ -12,6 +11,7 @@ import type {
|
|||
ScrcpyScrollController,
|
||||
ScrcpyVideoStream,
|
||||
} from "../base/index.js";
|
||||
import { ScrcpyDeviceMessageParsers } from "../base/index.js";
|
||||
import type {
|
||||
ScrcpyBackOrScreenOnControlMessage,
|
||||
ScrcpyInjectTouchControlMessage,
|
||||
|
@ -55,12 +55,22 @@ export class ScrcpyOptions1_22
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
||||
get deviceMessageParsers() {
|
||||
return this.#deviceMessageParsers;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
this.value = { ...Defaults, ...init };
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
this.#ackClipboardHandler = new AckClipboardHandler();
|
||||
this.#clipboard = this.#deviceMessageParsers.add(
|
||||
new ClipboardStream(),
|
||||
);
|
||||
|
||||
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
||||
new AckClipboardHandler(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,31 +100,6 @@ export class ScrcpyOptions1_22
|
|||
return parseVideoStreamMetadata(this.value, stream);
|
||||
}
|
||||
|
||||
async parseDeviceMessage(
|
||||
id: number,
|
||||
stream: ExactReadable | AsyncExactReadable,
|
||||
): Promise<void> {
|
||||
if (await this.#clipboard?.parse(id, stream)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error("Unknown device message");
|
||||
}
|
||||
|
||||
endDeviceMessageStream(e?: unknown): void {
|
||||
if (e) {
|
||||
this.#clipboard?.error(e);
|
||||
this.#ackClipboardHandler?.error(e);
|
||||
} else {
|
||||
this.#clipboard?.close();
|
||||
this.#ackClipboardHandler?.close();
|
||||
}
|
||||
}
|
||||
|
||||
createMediaStreamTransformer(): TransformStream<
|
||||
Uint8Array,
|
||||
ScrcpyMediaStreamPacket
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue