From 4460a95f4a185098ba67252c64973d6ecb79b6c8 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 31 Mar 2022 13:55:03 -0700 Subject: [PATCH] sdk: add canResize flag to Camera --- sdk/gen/types.input.ts | 55 +++++++++++-------- sdk/scrypted_python/scrypted_sdk/types.py | 20 +++---- sdk/types/index.d.ts | 32 +++++++---- sdk/types/index.ts | 55 +++++++++++-------- .../scrypted_python/scrypted_sdk/types.py | 20 +++---- 5 files changed, 103 insertions(+), 79 deletions(-) diff --git a/sdk/gen/types.input.ts b/sdk/gen/types.input.ts index dfc9ee8fe..c1992778d 100644 --- a/sdk/gen/types.input.ts +++ b/sdk/gen/types.input.ts @@ -318,14 +318,23 @@ export enum ThermostatMode { On = "On", } export interface PictureDimensions { - width: number; - height: number; + width?: number; + height?: number; } export interface PictureOptions { id?: string; - name?: string; + /** + * The native dimensions of the camera. + */ picture?: PictureDimensions; } +export interface ResponsePictureOptions extends PictureOptions { + name?: string; + /** + * Flag that indicates that the request supports resizing to custom dimensions. + */ + canResize?: boolean; +} export interface RequestPictureOptions extends PictureOptions { reason?: 'user' | 'event'; /** @@ -342,8 +351,7 @@ export interface RequestPictureOptions extends PictureOptions { */ export interface Camera { takePicture(options?: RequestPictureOptions): Promise; - getPictureOptions(): Promise; - + getPictureOptions(): Promise; } export interface VideoStreamOptions { @@ -381,7 +389,7 @@ export type MediaStreamSource = "local" | "cloud"; * is requested when calling getVideoStream. */ export interface MediaStreamOptions { - id: string; + id?: string; name?: string; /** * Prebuffer time in milliseconds. @@ -391,30 +399,33 @@ export interface MediaStreamOptions { * The container type of this stream, ie: mp4, mpegts, rtsp. */ container?: string; - /** - * The tool used to generate the container. Ie, scrypted, - * the ffmpeg tools, gstreamer. - */ - tool?: string; - - video?: VideoStreamOptions; - audio?: AudioStreamOptions; /** * Stream specific metadata. */ metadata?: any; - source?: MediaStreamSource; - userConfigurable?: boolean; + /** + * The tool used to generate the container. Ie, scrypted, + * the ffmpeg tools, gstreamer. + */ + // should this be in the request too as a hint for the preferred tool to use? + tool?: string; + + video?: VideoStreamOptions; + audio?: AudioStreamOptions; } export interface ResponseMediaStreamOptions extends MediaStreamOptions { + id: string; /** * The time in milliseconds that this stream must be refreshed again * via a call to getVideoStream. */ - refreshAt?: number; + refreshAt?: number; + + source?: MediaStreamSource; + userConfigurable?: boolean; } export interface RequestMediaStreamOptions extends ResponseMediaStreamOptions { @@ -686,7 +697,7 @@ export interface SoftwareUpdate { * May optionally accept string urls if accept-url is a fromMimeType parameter. */ export interface BufferConverter { - convert(data: string|Buffer|any, fromMimeType: string, toMimeType: string): Promise; + convert(data: string | Buffer | any, fromMimeType: string, toMimeType: string): Promise; fromMimeType?: string; toMimeType?: string; @@ -890,7 +901,7 @@ export interface MediaManager { * Additional plugin provided convertors to consider for use when converting MediaObjects. */ builtinConverters: BufferConverter[]; - + /** * Convert a media object to a Buffer, primtive type, or RPC Object. */ @@ -1357,7 +1368,7 @@ export enum ScryptedInterface { export type RTCSignalingSendIceCandidate = (candidate: RTCIceCandidateInit) => Promise; export interface RTCSignalingSession { - createLocalDescription(type: 'offer' | 'answer', setup: RTCAVSignalingSetup, sendIceCandidate: undefined|RTCSignalingSendIceCandidate): Promise; + createLocalDescription(type: 'offer' | 'answer', setup: RTCAVSignalingSetup, sendIceCandidate: undefined | RTCSignalingSendIceCandidate): Promise; setRemoteDescription(description: RTCSessionDescriptionInit, setup: RTCAVSignalingSetup): Promise; addIceCandidate(candidate: RTCIceCandidateInit): Promise; getOptions(): Promise; @@ -1382,7 +1393,7 @@ export interface RTCSignalingOptions { } export interface RTCSessionControl { - getRefreshAt(): Promise; + getRefreshAt(): Promise; extendSession(): Promise; endSession(): Promise; } @@ -1401,7 +1412,7 @@ export interface RTCSignalingClient { * strict requirements and expectations on client setup. */ export interface RTCSignalingChannel { - startRTCSignalingSession(session: RTCSignalingSession): Promise; + startRTCSignalingSession(session: RTCSignalingSession): Promise; } export interface RTCAVSignalingSetup { diff --git a/sdk/scrypted_python/scrypted_sdk/types.py b/sdk/scrypted_python/scrypted_sdk/types.py index 1acc5ad29..d069268d1 100644 --- a/sdk/scrypted_python/scrypted_sdk/types.py +++ b/sdk/scrypted_python/scrypted_sdk/types.py @@ -335,9 +335,7 @@ class MediaStreamOptions(TypedDict): metadata: Any name: str prebuffer: float - source: MediaStreamSource tool: str - userConfigurable: bool video: VideoStreamOptions pass @@ -367,12 +365,6 @@ class ObjectsDetected(TypedDict): timestamp: float pass -class PictureOptions(TypedDict): - id: str - name: str - picture: PictureDimensions - pass - class Position(TypedDict): accuracyRadius: float latitude: float @@ -404,7 +396,6 @@ class RequestMediaStreamOptions(TypedDict): class RequestPictureOptions(TypedDict): bulkRequest: bool id: str - name: str periodicRequest: bool picture: PictureDimensions reason: Any | Any @@ -417,13 +408,18 @@ class RequestRecordingStreamOptions(TypedDict): metadata: Any name: str prebuffer: float - source: MediaStreamSource startTime: float tool: str - userConfigurable: bool video: VideoStreamOptions pass +class ResponsePictureOptions(TypedDict): + canResize: bool + id: str + name: str + picture: PictureDimensions + pass + class ScriptSource(TypedDict): language: str monacoEvalDefaults: str @@ -512,7 +508,7 @@ class BufferConverter: pass class Camera: - async def getPictureOptions(self) -> list[PictureOptions]: + async def getPictureOptions(self) -> list[ResponsePictureOptions]: pass async def takePicture(self, options: RequestPictureOptions = None) -> MediaObject: pass diff --git a/sdk/types/index.d.ts b/sdk/types/index.d.ts index 7f61114df..2ea992720 100644 --- a/sdk/types/index.d.ts +++ b/sdk/types/index.d.ts @@ -450,14 +450,23 @@ export declare enum ThermostatMode { On = "On" } export interface PictureDimensions { - width: number; - height: number; + width?: number; + height?: number; } export interface PictureOptions { id?: string; - name?: string; + /** + * The native dimensions of the camera. + */ picture?: PictureDimensions; } +export interface ResponsePictureOptions extends PictureOptions { + name?: string; + /** + * Flag that indicates that the request supports resizing to custom dimensions. + */ + canResize?: boolean; +} export interface RequestPictureOptions extends PictureOptions { reason?: 'user' | 'event'; /** @@ -474,7 +483,7 @@ export interface RequestPictureOptions extends PictureOptions { */ export interface Camera { takePicture(options?: RequestPictureOptions): Promise; - getPictureOptions(): Promise; + getPictureOptions(): Promise; } export interface VideoStreamOptions { codec?: string; @@ -509,7 +518,7 @@ export declare type MediaStreamSource = "local" | "cloud"; * is requested when calling getVideoStream. */ export interface MediaStreamOptions { - id: string; + id?: string; name?: string; /** * Prebuffer time in milliseconds. @@ -519,6 +528,10 @@ export interface MediaStreamOptions { * The container type of this stream, ie: mp4, mpegts, rtsp. */ container?: string; + /** + * Stream specific metadata. + */ + metadata?: any; /** * The tool used to generate the container. Ie, scrypted, * the ffmpeg tools, gstreamer. @@ -526,19 +539,16 @@ export interface MediaStreamOptions { tool?: string; video?: VideoStreamOptions; audio?: AudioStreamOptions; - /** - * Stream specific metadata. - */ - metadata?: any; - source?: MediaStreamSource; - userConfigurable?: boolean; } export interface ResponseMediaStreamOptions extends MediaStreamOptions { + id: string; /** * The time in milliseconds that this stream must be refreshed again * via a call to getVideoStream. */ refreshAt?: number; + source?: MediaStreamSource; + userConfigurable?: boolean; } export interface RequestMediaStreamOptions extends ResponseMediaStreamOptions { /** diff --git a/sdk/types/index.ts b/sdk/types/index.ts index 7fbacaa49..a7e794a72 100644 --- a/sdk/types/index.ts +++ b/sdk/types/index.ts @@ -1015,14 +1015,23 @@ export enum ThermostatMode { On = "On", } export interface PictureDimensions { - width: number; - height: number; + width?: number; + height?: number; } export interface PictureOptions { id?: string; - name?: string; + /** + * The native dimensions of the camera. + */ picture?: PictureDimensions; } +export interface ResponsePictureOptions extends PictureOptions { + name?: string; + /** + * Flag that indicates that the request supports resizing to custom dimensions. + */ + canResize?: boolean; +} export interface RequestPictureOptions extends PictureOptions { reason?: 'user' | 'event'; /** @@ -1039,8 +1048,7 @@ export interface RequestPictureOptions extends PictureOptions { */ export interface Camera { takePicture(options?: RequestPictureOptions): Promise; - getPictureOptions(): Promise; - + getPictureOptions(): Promise; } export interface VideoStreamOptions { @@ -1078,7 +1086,7 @@ export type MediaStreamSource = "local" | "cloud"; * is requested when calling getVideoStream. */ export interface MediaStreamOptions { - id: string; + id?: string; name?: string; /** * Prebuffer time in milliseconds. @@ -1088,30 +1096,33 @@ export interface MediaStreamOptions { * The container type of this stream, ie: mp4, mpegts, rtsp. */ container?: string; - /** - * The tool used to generate the container. Ie, scrypted, - * the ffmpeg tools, gstreamer. - */ - tool?: string; - - video?: VideoStreamOptions; - audio?: AudioStreamOptions; /** * Stream specific metadata. */ metadata?: any; - source?: MediaStreamSource; - userConfigurable?: boolean; + /** + * The tool used to generate the container. Ie, scrypted, + * the ffmpeg tools, gstreamer. + */ + // should this be in the request too as a hint for the preferred tool to use? + tool?: string; + + video?: VideoStreamOptions; + audio?: AudioStreamOptions; } export interface ResponseMediaStreamOptions extends MediaStreamOptions { + id: string; /** * The time in milliseconds that this stream must be refreshed again * via a call to getVideoStream. */ - refreshAt?: number; + refreshAt?: number; + + source?: MediaStreamSource; + userConfigurable?: boolean; } export interface RequestMediaStreamOptions extends ResponseMediaStreamOptions { @@ -1383,7 +1394,7 @@ export interface SoftwareUpdate { * May optionally accept string urls if accept-url is a fromMimeType parameter. */ export interface BufferConverter { - convert(data: string|Buffer|any, fromMimeType: string, toMimeType: string): Promise; + convert(data: string | Buffer | any, fromMimeType: string, toMimeType: string): Promise; fromMimeType?: string; toMimeType?: string; @@ -1587,7 +1598,7 @@ export interface MediaManager { * Additional plugin provided convertors to consider for use when converting MediaObjects. */ builtinConverters: BufferConverter[]; - + /** * Convert a media object to a Buffer, primtive type, or RPC Object. */ @@ -2054,7 +2065,7 @@ export enum ScryptedInterface { export type RTCSignalingSendIceCandidate = (candidate: RTCIceCandidateInit) => Promise; export interface RTCSignalingSession { - createLocalDescription(type: 'offer' | 'answer', setup: RTCAVSignalingSetup, sendIceCandidate: undefined|RTCSignalingSendIceCandidate): Promise; + createLocalDescription(type: 'offer' | 'answer', setup: RTCAVSignalingSetup, sendIceCandidate: undefined | RTCSignalingSendIceCandidate): Promise; setRemoteDescription(description: RTCSessionDescriptionInit, setup: RTCAVSignalingSetup): Promise; addIceCandidate(candidate: RTCIceCandidateInit): Promise; getOptions(): Promise; @@ -2079,7 +2090,7 @@ export interface RTCSignalingOptions { } export interface RTCSessionControl { - getRefreshAt(): Promise; + getRefreshAt(): Promise; extendSession(): Promise; endSession(): Promise; } @@ -2098,7 +2109,7 @@ export interface RTCSignalingClient { * strict requirements and expectations on client setup. */ export interface RTCSignalingChannel { - startRTCSignalingSession(session: RTCSignalingSession): Promise; + startRTCSignalingSession(session: RTCSignalingSession): Promise; } export interface RTCAVSignalingSetup { diff --git a/sdk/types/scrypted_python/scrypted_sdk/types.py b/sdk/types/scrypted_python/scrypted_sdk/types.py index 1acc5ad29..d069268d1 100644 --- a/sdk/types/scrypted_python/scrypted_sdk/types.py +++ b/sdk/types/scrypted_python/scrypted_sdk/types.py @@ -335,9 +335,7 @@ class MediaStreamOptions(TypedDict): metadata: Any name: str prebuffer: float - source: MediaStreamSource tool: str - userConfigurable: bool video: VideoStreamOptions pass @@ -367,12 +365,6 @@ class ObjectsDetected(TypedDict): timestamp: float pass -class PictureOptions(TypedDict): - id: str - name: str - picture: PictureDimensions - pass - class Position(TypedDict): accuracyRadius: float latitude: float @@ -404,7 +396,6 @@ class RequestMediaStreamOptions(TypedDict): class RequestPictureOptions(TypedDict): bulkRequest: bool id: str - name: str periodicRequest: bool picture: PictureDimensions reason: Any | Any @@ -417,13 +408,18 @@ class RequestRecordingStreamOptions(TypedDict): metadata: Any name: str prebuffer: float - source: MediaStreamSource startTime: float tool: str - userConfigurable: bool video: VideoStreamOptions pass +class ResponsePictureOptions(TypedDict): + canResize: bool + id: str + name: str + picture: PictureDimensions + pass + class ScriptSource(TypedDict): language: str monacoEvalDefaults: str @@ -512,7 +508,7 @@ class BufferConverter: pass class Camera: - async def getPictureOptions(self) -> list[PictureOptions]: + async def getPictureOptions(self) -> list[ResponsePictureOptions]: pass async def takePicture(self, options: RequestPictureOptions = None) -> MediaObject: pass