cameras, etc: install pluginDependencies

This commit is contained in:
Koushik Dutta
2022-02-24 13:40:43 -08:00
parent 8c05787043
commit c6f78aaa6c
17 changed files with 48 additions and 69 deletions

View File

@@ -114,7 +114,7 @@ export async function scryptedEval(device: ScryptedDeviceBase, script: string, e
export function createMonacoEvalDefaults(extraLibs: { [lib: string]: string }) {
const bufferTypeDefs = fs.readFileSync('@types/node/buffer.d.ts').toString();
const safeLibs = {
const safeLibs = {
bufferTypeDefs,
};
@@ -193,10 +193,10 @@ export interface ScriptDeviceImpl extends ScriptDevice {
mergeHandler(device: ScryptedDeviceBase): string[];
}
const methodInterfaces: { [method: string]: string } = {};
const methodInterfaces = new Map<string, string>();
for (const desc of Object.values(ScryptedInterfaceDescriptors)) {
for (const method of desc.methods) {
methodInterfaces[method] = desc.name;
methodInterfaces.set(method, desc.name);
}
}
@@ -213,12 +213,19 @@ export function createScriptDevice(baseInterfaces: string[]): ScriptDeviceImpl {
},
mergeHandler: (device: ScryptedDeviceBase) => {
const handler = scriptHandler || {};
for (const method of Object.keys(handler)) {
const iface = methodInterfaces[method];
if (iface)
let keys: string[];
if (handler.constructor === Object)
keys = Object.keys(handler);
else
keys = Object.getOwnPropertyNames(handler.__proto__);
for (const method of keys) {
const iface = methodInterfaces.get(method);
if (iface) {
allInterfaces.push(iface);
device[method] = handler[method].bind(handler);
}
}
Object.assign(device, handler);
return allInterfaces;
},
};

View File

@@ -1,3 +1,5 @@
# FFmpeg Camera Plugin for Scrypted
Add FFmpeg Camera video streams to Scrypted. Cameras often have still image snapshot URLs. To use these snapshots you will also need the [Snapshot Plugin](#/component/plugin/install/@scrypted/snapshot).
FFmpeg Cameras will need a software motion detector like [PAM-Diff](#/component/plugin/install/@scrypted/pam-diff) or [OpenCV](#/component/plugin/install/@scrypted/opencv) to enable HomeKit Secure Video.

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/ffmpeg-camera",
"version": "0.0.9",
"version": "0.0.15",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/ffmpeg-camera",
"version": "0.0.9",
"version": "0.0.15",
"license": "Apache",
"dependencies": {
"@koush/axios-digest-auth": "^0.8.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/ffmpeg-camera",
"version": "0.0.9",
"version": "0.0.15",
"description": "FFmpeg Camera Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
@@ -27,6 +27,11 @@
"interfaces": [
"DeviceProvider",
"DeviceCreator"
],
"pluginDependencies": [
"@scrypted/prebuffer-mixin",
"@scrypted/pam-diff",
"@scrypted/snapshot"
]
},
"devDependencies": {

View File

@@ -1,5 +1,4 @@
import sdk, { ScryptedDeviceBase, DeviceProvider, Settings, Setting, ScryptedDeviceType, VideoCamera, MediaObject, MediaStreamOptions, ScryptedInterface, FFMpegInput, Camera, PictureOptions, SettingValue, DeviceCreator, DeviceCreatorSettings } from "@scrypted/sdk";
import { recommendRebroadcast } from "./recommend";
import AxiosDigestAuth from '@koush/axios-digest-auth';
import https from 'https';
import { randomBytes } from "crypto";
@@ -200,8 +199,6 @@ export abstract class CameraProviderBase<T extends MediaStreamOptions> extends S
if (camId)
this.getDevice(camId);
}
recommendRebroadcast();
}
async createDevice(settings: DeviceCreatorSettings): Promise<string> {

View File

@@ -3,7 +3,6 @@ import { CameraProviderBase, CameraBase, UrlMediaStreamOptions } from "./common"
import { StorageSettings } from "../../../common/src/settings";
import { ffmpegLogInitialOutput, safePrintFFmpegArguments } from "../../../common/src/media-helpers";
import child_process, { ChildProcess } from "child_process";
import { recommendDumbPlugins } from "./recommend";
const { mediaManager } = sdk;
@@ -124,11 +123,6 @@ class FFmpegCamera extends CameraBase<UrlMediaStreamOptions> implements Intercom
}
class FFmpegProvider extends CameraProviderBase<UrlMediaStreamOptions> {
constructor(nativeId?: string) {
super(nativeId);
recommendDumbPlugins();
}
createCamera(nativeId: string): FFmpegCamera {
return new FFmpegCamera(nativeId, this);
}

View File

@@ -1,14 +0,0 @@
import { alertRecommendedPlugins } from "@scrypted/common/src/alert-recommended-plugins";
export async function recommendRebroadcast() {
alertRecommendedPlugins({
'@scrypted/prebuffer-mixin': 'Rebroadcast',
});
}
export async function recommendDumbPlugins() {
alertRecommendedPlugins({
'@scrypted/snapshot': 'Snapshot Plugin',
'@scrypted/opencv': 'OpenCV Motion Detection',
});
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/opencv",
"version": "0.0.40",
"version": "0.0.43",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/opencv",
"version": "0.0.40",
"version": "0.0.43",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -25,10 +25,13 @@
"type": "API",
"interfaces": [
"ObjectDetection"
],
"pluginDependencies": [
"@scrypted/objectdetector"
]
},
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.0.40"
"version": "0.0.43"
}

View File

@@ -3,22 +3,5 @@ from scrypted_sdk import systemManager, remote
import asyncio
from opencv import OpenCVPlugin
async def require_plugins(plugins: Any):
api = remote.api
logger = await api.getLogger(None)
pluginsComponent = await systemManager.getComponent('plugins')
for plugin in plugins:
found = await pluginsComponent.getIdForPluginId(plugin)
if found:
continue
name = plugins[plugin]
await logger.log('a', 'Installation of the %s plugin is also recommended. origin:/#/component/plugin/install/%s' % (name, plugin))
def create_scrypted_plugin():
plugins = {
'@scrypted/objectdetector': "Video Analysis Plugin",
}
asyncio.run_coroutine_threadsafe(require_plugins(plugins), loop=asyncio.get_event_loop())
return OpenCVPlugin()

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/pam-diff",
"version": "0.0.6",
"version": "0.0.8",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/pam-diff",
"version": "0.0.6",
"version": "0.0.8",
"dependencies": {
"@types/node": "^16.6.1",
"pam-diff": "^1.1.0",

View File

@@ -26,6 +26,9 @@
"type": "API",
"interfaces": [
"ObjectDetection"
],
"pluginDependencies": [
"@scrypted/objectdetector"
]
},
"dependencies": {
@@ -38,5 +41,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.0.6"
"version": "0.0.8"
}

View File

@@ -1,7 +1,6 @@
import { BufferConverter, FFMpegInput, MediaObject, ObjectDetection, ObjectDetectionModel, ObjectDetectionSession, ObjectsDetected, OnOff, ScryptedDeviceBase, ScryptedInterface, ScryptedMimeTypes } from '@scrypted/sdk';
import { FFMpegInput, MediaObject, ObjectDetection, ObjectDetectionModel, ObjectDetectionSession, ObjectsDetected, ScryptedDeviceBase, ScryptedInterface, ScryptedMimeTypes } from '@scrypted/sdk';
import sdk from '@scrypted/sdk';
import { ffmpegLogInitialOutput } from "../../../common/src/media-helpers";
import { alertRecommendedPlugins } from "../../../common/src/alert-recommended-plugins";
import child_process, { ChildProcess } from 'child_process';
@@ -23,13 +22,6 @@ interface PamDiffSession {
class PamDiff extends ScryptedDeviceBase implements ObjectDetection {
sessions = new Map<string, PamDiffSession>();
constructor() {
super();
alertRecommendedPlugins({
'@scrypted/objectdetector': 'Video Analysis Plugin',
});
}
endSession(pds: PamDiffSession) {
this.sessions.delete(pds.id);
const event: ObjectsDetected = {

View File

@@ -1,3 +1,5 @@
# RTSP Camera Plugin for Scrypted
Add RTSP Camera video streams to Scrypted. RTSP Cameras often have still image snapshot URLs. To use these snapshots you will also need the [Snapshot Plugin](#/component/plugin/install/@scrypted/snapshot).
RTSP Cameras will need a software motion detector like [PAM-Diff](#/component/plugin/install/@scrypted/pam-diff) or [OpenCV](#/component/plugin/install/@scrypted/opencv) to enable HomeKit Secure Video.

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/rtsp",
"version": "0.0.47",
"version": "0.0.50",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/rtsp",
"version": "0.0.47",
"version": "0.0.50",
"license": "Apache",
"dependencies": {
"@koush/axios-digest-auth": "^0.8.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/rtsp",
"version": "0.0.47",
"version": "0.0.50",
"description": "RTSP Cameras and Streams Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
@@ -27,6 +27,11 @@
"interfaces": [
"DeviceProvider",
"DeviceCreator"
],
"pluginDependencies": [
"@scrypted/prebuffer-mixin",
"@scrypted/pam-diff",
"@scrypted/snapshot"
]
},
"devDependencies": {