feat(adb-scrcpy): accept string-typed scid

This commit is contained in:
Simon Chan 2024-12-06 11:25:39 +08:00
parent 0f5af05adb
commit 6f00fd5606
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
5 changed files with 9 additions and 7 deletions

View file

@ -16,7 +16,7 @@ import {
} from "@yume-chan/stream-extra"; } from "@yume-chan/stream-extra";
export interface AdbScrcpyConnectionOptions { export interface AdbScrcpyConnectionOptions {
scid: number; scid: string | undefined;
video: boolean; video: boolean;
@ -60,8 +60,8 @@ export abstract class AdbScrcpyConnection implements Disposable {
protected getSocketName(): string { protected getSocketName(): string {
let socketName = "localabstract:" + SCRCPY_SOCKET_NAME_PREFIX; let socketName = "localabstract:" + SCRCPY_SOCKET_NAME_PREFIX;
if (this.options.scid !== undefined && this.options.scid >= 0) { if (this.options.scid !== undefined) {
socketName += "_" + this.options.scid.toString(16).padStart(8, "0"); socketName += "_" + this.options.scid.padStart(8, "0");
} }
return socketName; return socketName;
} }

View file

@ -119,7 +119,7 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
return AdbScrcpyOptions1_16.createConnection( return AdbScrcpyOptions1_16.createConnection(
adb, adb,
{ {
scid: -1, // Not Supported scid: undefined, // Not Supported
video: true, // Always enabled video: true, // Always enabled
audio: false, // Not Supported audio: false, // Not Supported
control: true, // Always enabled even when `--no-control` is specified control: true, // Always enabled even when `--no-control` is specified

View file

@ -38,7 +38,7 @@ export class AdbScrcpyOptions1_22 extends AdbScrcpyOptions<
return AdbScrcpyOptions1_16.createConnection( return AdbScrcpyOptions1_16.createConnection(
adb, adb,
{ {
scid: -1, // Not Supported scid: undefined, // Not Supported
video: true, // Always enabled video: true, // Always enabled
audio: false, // Not Supported audio: false, // Not Supported
control: this.value.control, control: this.value.control,

View file

@ -5,6 +5,7 @@ import type {
ScrcpyOptions1_16Impl, ScrcpyOptions1_16Impl,
ScrcpyOptions2_0Impl, ScrcpyOptions2_0Impl,
} from "@yume-chan/scrcpy"; } from "@yume-chan/scrcpy";
import { toScrcpyOptionValue } from "@yume-chan/scrcpy";
import { AdbScrcpyClient, AdbScrcpyExitedError } from "../client.js"; import { AdbScrcpyClient, AdbScrcpyExitedError } from "../client.js";
import type { AdbScrcpyConnection } from "../connection.js"; import type { AdbScrcpyConnection } from "../connection.js";
@ -77,7 +78,7 @@ export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
return AdbScrcpyOptions1_16.createConnection( return AdbScrcpyOptions1_16.createConnection(
adb, adb,
{ {
scid: this.value.scid.value, scid: toScrcpyOptionValue(this.value.scid, undefined),
video: true, // Always enabled video: true, // Always enabled
audio: this.value.audio, audio: this.value.audio,
control: this.value.control, control: this.value.control,

View file

@ -4,6 +4,7 @@ import type {
ScrcpyEncoder, ScrcpyEncoder,
ScrcpyOptions2_1Impl, ScrcpyOptions2_1Impl,
} from "@yume-chan/scrcpy"; } from "@yume-chan/scrcpy";
import { toScrcpyOptionValue } from "@yume-chan/scrcpy";
import type { AdbScrcpyConnection } from "../connection.js"; import type { AdbScrcpyConnection } from "../connection.js";
@ -44,7 +45,7 @@ export class AdbScrcpyOptions2_1 extends AdbScrcpyOptions<
return AdbScrcpyOptions1_16.createConnection( return AdbScrcpyOptions1_16.createConnection(
adb, adb,
{ {
scid: this.value.scid.value, scid: toScrcpyOptionValue(this.value.scid, undefined),
video: this.value.video, video: this.value.video,
audio: this.value.audio, audio: this.value.audio,
control: this.value.control, control: this.value.control,