mirror of
https://github.com/koush/scrypted.git
synced 2026-03-20 16:40:24 +00:00
sdk: add env to FFmpegInput + fix python parameterized class generator (#1532)
* sdk: add env to FFmpegInput + fix python parameterized class generator * downgrade node for gh actions
This commit is contained in:
6
.github/workflows/build-sdk.yml
vendored
6
.github/workflows/build-sdk.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
pull_request:
|
||||
paths: ["sdk/**"]
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
@@ -15,11 +15,11 @@ jobs:
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./sdk
|
||||
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 22.4.1
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
@@ -518,6 +518,7 @@ class FFmpegInput(TypedDict):
|
||||
|
||||
container: str
|
||||
destinationVideoBitrate: float
|
||||
env: Any # Environment variables to set when launching FFmpeg.
|
||||
h264EncoderArguments: list[str]
|
||||
h264FilterArguments: list[str]
|
||||
inputArguments: list[str]
|
||||
@@ -1465,7 +1466,7 @@ class StartStop:
|
||||
class StreamService:
|
||||
"""Generic bidirectional stream connection."""
|
||||
|
||||
async def connectStream(self, input: AsyncGenerator[Input, None] = None, options: Any = None) -> AsyncGenerator[Output, None]:
|
||||
async def connectStream(self, input: AsyncGenerator[Any, None] = None, options: Any = None) -> AsyncGenerator[Any, None]:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -142,24 +142,11 @@ function toPythonMethodDeclaration(method: any) {
|
||||
}
|
||||
|
||||
function selfSignature(method: any) {
|
||||
for (const typeParameter of method.signatures[0].typeParameter || []) {
|
||||
parameterTypes.add(typeParameter.name);
|
||||
}
|
||||
const params = (method.signatures[0].parameters || []).map((p: any) => toPythonParameter(p));
|
||||
parameterTypes.clear();
|
||||
params.unshift('self');
|
||||
return params.join(', ');
|
||||
}
|
||||
|
||||
function selfReturnType(method: any) {
|
||||
for (const typeParameter of method.signatures[0].typeParameter || []) {
|
||||
parameterTypes.add(typeParameter.name);
|
||||
}
|
||||
const retType = toPythonReturnType(method.signatures[0].type);
|
||||
parameterTypes.clear();
|
||||
return retType
|
||||
}
|
||||
|
||||
const enums = schema.children?.filter((child: any) => child.kindString === 'Enumeration') ?? [];
|
||||
const interfaces = schema.children?.filter((child: any) => Object.values(ScryptedInterface).includes(child.name)) ?? [];
|
||||
let python = '';
|
||||
@@ -223,6 +210,10 @@ function addNonDictionaryType(td: any) {
|
||||
class ${td.name}:
|
||||
${toDocstring(td)}
|
||||
`;
|
||||
// cache type parameters so underlying generators can map them to Any
|
||||
for (const typeParameter of td.typeParameters || []) {
|
||||
parameterTypes.add(typeParameter.name);
|
||||
}
|
||||
|
||||
const children = td.children || [];
|
||||
const properties = children.filter((child: any) => child.kindString === 'Property');
|
||||
@@ -232,7 +223,7 @@ ${toDocstring(td)}
|
||||
`
|
||||
}
|
||||
for (const method of methods) {
|
||||
python += ` ${toPythonMethodDeclaration(method)} ${method.name}(${selfSignature(method)}) -> ${selfReturnType(method)}:
|
||||
python += ` ${toPythonMethodDeclaration(method)} ${method.name}(${selfSignature(method)}) -> ${toPythonReturnType(method.signatures[0].type)}:
|
||||
${toDocstring(method, true)}
|
||||
|
||||
`
|
||||
@@ -241,6 +232,9 @@ ${toDocstring(td)}
|
||||
python += `
|
||||
pass
|
||||
`
|
||||
|
||||
// reset for the next type
|
||||
parameterTypes.clear();
|
||||
}
|
||||
|
||||
for (const td of interfaces) {
|
||||
|
||||
@@ -1703,6 +1703,10 @@ export interface FFmpegInput extends MediaContainer {
|
||||
h264EncoderArguments?: string[];
|
||||
videoDecoderArguments?: string[];
|
||||
h264FilterArguments?: string[];
|
||||
/**
|
||||
* Environment variables to set when launching FFmpeg.
|
||||
*/
|
||||
env?: { [key: string]: string };
|
||||
}
|
||||
export interface DeviceInformation {
|
||||
model?: string;
|
||||
|
||||
Reference in New Issue
Block a user