@yume-chan/adb-scrcpy
Version:
Use `@yume-chan/adb` to bootstrap `@yume-chan/scrcpy`.
28 lines • 1.03 kB
JavaScript
import { AdbScrcpyClient, AdbScrcpyExitedError } from "../../client.js";
export async function getEncoders(adb, path, options) {
try {
// Similar to `getDisplays`, now the server won't create video sockets,
// so `start` will throw an `AdbScrcpyExitedError` instead
const client = await AdbScrcpyClient.start(adb, path, options);
// If the server didn't exit, manually stop it and throw an error
await client.close();
throw new Error("Unexpected server output");
}
catch (e) {
if (e instanceof AdbScrcpyExitedError) {
if (e.output[0]?.startsWith("[server] ERROR:")) {
throw e;
}
const encoders = [];
for (const line of e.output) {
const encoder = options.parseEncoder(line);
if (encoder) {
encoders.push(encoder);
}
}
return encoders;
}
throw e;
}
}
//# sourceMappingURL=get-encoders.js.map