Loading libraries/scrcpy/src/2_0/impl/parse-encoder.ts +11 −21 Original line number Diff line number Diff line import type { ScrcpyEncoder } from "../../base/index.js"; export function parseEncoder(line: string): ScrcpyEncoder | undefined { let match = line.match( /^\s+--video-codec=(\S+)\s+--video-encoder='([^']+)'$/, ); if (match) { return { type: "video", codec: match[1]!, name: match[2]!, }; } const EncoderRegex = /^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder='([^']+)'$/; match = line.match(/^\s+--audio-codec=(\S+)\s+--audio-encoder='([^']+)'$/); if (match) { return { type: "audio", codec: match[1]!, name: match[2]!, }; export function parseEncoder(line: string): ScrcpyEncoder | undefined { const match = line.match(EncoderRegex); return match ? { type: match[1]! as "video" | "audio", name: match[3]!, codec: match[2]!, } return undefined; : undefined; } libraries/scrcpy/src/3_0/impl/index.ts +2 −1 Original line number Diff line number Diff line Loading @@ -6,5 +6,6 @@ export { LockOrientation, NewDisplay, Orientation, type Init, } from "./init.js"; export type { Init } from "./init.js"; export { parseEncoder } from "./parse-encoder.js"; libraries/scrcpy/src/3_0/impl/parse-encoder.ts 0 → 100644 +31 −0 Original line number Diff line number Diff line import type { ScrcpyEncoder } from "../../base/index.js"; const EncoderRegex = /^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/; function toHardwareType(value: string): ScrcpyEncoder["hardwareType"] { switch (value) { case "sw": return "software"; case "hw": return "hardware"; case "hybrid": return "hybrid"; default: throw new Error(`Unknown hardware type: ${value}`); } } export function parseEncoder(line: string): ScrcpyEncoder | undefined { const match = line.match(EncoderRegex); return match ? { type: match[1]! as "video" | "audio", name: match[3]!, codec: match[2]!, hardwareType: match[4] ? toHardwareType(match[4]) : undefined, vendor: !!match[5], aliasFor: match[6], } : undefined; } libraries/scrcpy/src/base/encoder.ts +4 −1 Original line number Diff line number Diff line export interface ScrcpyEncoder { type: "video" | "audio"; codec?: string; name: string; codec?: string; hardwareType?: "hardware" | "software" | "hybrid" | undefined; vendor?: boolean | undefined; aliasFor?: string | undefined; } Loading
libraries/scrcpy/src/2_0/impl/parse-encoder.ts +11 −21 Original line number Diff line number Diff line import type { ScrcpyEncoder } from "../../base/index.js"; export function parseEncoder(line: string): ScrcpyEncoder | undefined { let match = line.match( /^\s+--video-codec=(\S+)\s+--video-encoder='([^']+)'$/, ); if (match) { return { type: "video", codec: match[1]!, name: match[2]!, }; } const EncoderRegex = /^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder='([^']+)'$/; match = line.match(/^\s+--audio-codec=(\S+)\s+--audio-encoder='([^']+)'$/); if (match) { return { type: "audio", codec: match[1]!, name: match[2]!, }; export function parseEncoder(line: string): ScrcpyEncoder | undefined { const match = line.match(EncoderRegex); return match ? { type: match[1]! as "video" | "audio", name: match[3]!, codec: match[2]!, } return undefined; : undefined; }
libraries/scrcpy/src/3_0/impl/index.ts +2 −1 Original line number Diff line number Diff line Loading @@ -6,5 +6,6 @@ export { LockOrientation, NewDisplay, Orientation, type Init, } from "./init.js"; export type { Init } from "./init.js"; export { parseEncoder } from "./parse-encoder.js";
libraries/scrcpy/src/3_0/impl/parse-encoder.ts 0 → 100644 +31 −0 Original line number Diff line number Diff line import type { ScrcpyEncoder } from "../../base/index.js"; const EncoderRegex = /^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/; function toHardwareType(value: string): ScrcpyEncoder["hardwareType"] { switch (value) { case "sw": return "software"; case "hw": return "hardware"; case "hybrid": return "hybrid"; default: throw new Error(`Unknown hardware type: ${value}`); } } export function parseEncoder(line: string): ScrcpyEncoder | undefined { const match = line.match(EncoderRegex); return match ? { type: match[1]! as "video" | "audio", name: match[3]!, codec: match[2]!, hardwareType: match[4] ? toHardwareType(match[4]) : undefined, vendor: !!match[5], aliasFor: match[6], } : undefined; }
libraries/scrcpy/src/base/encoder.ts +4 −1 Original line number Diff line number Diff line export interface ScrcpyEncoder { type: "video" | "audio"; codec?: string; name: string; codec?: string; hardwareType?: "hardware" | "software" | "hybrid" | undefined; vendor?: boolean | undefined; aliasFor?: string | undefined; }