@scrypted/amcrest
Advanced tools
Comparing version 0.0.164 to 0.0.165
{ | ||
"scrypted.debugHost": "127.0.0.1", | ||
"scrypted.debugHost": "scrypted-nvr", | ||
} |
{ | ||
"name": "@scrypted/amcrest", | ||
"version": "0.0.164", | ||
"version": "0.0.165", | ||
"description": "Amcrest Plugin for Scrypted", | ||
@@ -42,8 +42,10 @@ "author": "Scrypted", | ||
"@scrypted/sdk": "file:../../sdk", | ||
"content-type": "^1.0.5" | ||
"content-type": "^1.0.5", | ||
"xml2js": "^0.6.2" | ||
}, | ||
"devDependencies": { | ||
"@types/content-type": "^1.1.8", | ||
"@types/node": "^20.11.30" | ||
"@types/node": "^20.11.30", | ||
"@types/xml2js": "^0.4.14" | ||
} | ||
} |
import { automaticallyConfigureSettings, checkPluginNeedsAutoConfigure } from "@scrypted/common/src/autoconfigure-codecs"; | ||
import { ffmpegLogInitialOutput } from '@scrypted/common/src/media-helpers'; | ||
import { readLength } from "@scrypted/common/src/read-stream"; | ||
import sdk, { Camera, DeviceCreatorSettings, DeviceInformation, FFmpegInput, Intercom, Lock, MediaObject, MediaStreamOptions, ObjectDetectionTypes, ObjectDetector, ObjectsDetected, Reboot, RequestPictureOptions, RequestRecordingStreamOptions, ResponseMediaStreamOptions, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, ScryptedNativeId, Setting, VideoCameraConfiguration, VideoRecorder } from "@scrypted/sdk"; | ||
import sdk, { Camera, DeviceCreatorSettings, DeviceInformation, FFmpegInput, Intercom, Lock, MediaObject, MediaStreamOptions, ObjectDetectionTypes, ObjectDetector, ObjectsDetected, Reboot, RequestPictureOptions, RequestRecordingStreamOptions, ResponseMediaStreamOptions, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, ScryptedNativeId, Setting, VideoCameraConfiguration, VideoRecorder, VideoTextOverlay, VideoTextOverlays } from "@scrypted/sdk"; | ||
import child_process, { ChildProcess } from 'child_process'; | ||
@@ -11,3 +11,2 @@ import { PassThrough, Readable, Stream } from "stream"; | ||
import { amcrestAutoConfigureSettings, autoconfigureSettings } from "./amcrest-configure"; | ||
import { group } from "console"; | ||
@@ -27,3 +26,3 @@ const { mediaManager } = sdk; | ||
class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, Camera, Intercom, Lock, VideoRecorder, Reboot, ObjectDetector { | ||
class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, Camera, Intercom, Lock, VideoRecorder, Reboot, ObjectDetector, VideoTextOverlays { | ||
eventStream: Stream; | ||
@@ -48,2 +47,88 @@ cp: ChildProcess; | ||
async getVideoTextOverlays(): Promise<Record<string, VideoTextOverlay>> { | ||
const client = this.getClient(); | ||
const response = await client.request({ | ||
method: "GET", | ||
url: `http://${this.getHttpAddress()}/cgi-bin/configManager.cgi?action=getConfig&name=VideoWidget`, | ||
responseType: "text", | ||
headers: { | ||
"Content-Type": "application/xml", | ||
}, | ||
}); | ||
const body: string = response.body; | ||
if (!body.startsWith("<")) { | ||
const encodeBlend = '.EncodeBlend'; | ||
const config: Record<string, VideoTextOverlay> = {}; | ||
for (const line of body.split(/\r?\n/).filter(l => l.includes(encodeBlend + '='))) { | ||
const trimmed = line.trim(); | ||
if (!trimmed) continue; | ||
const splitIndex = trimmed.indexOf("="); | ||
if (splitIndex === -1) continue; | ||
// remove encodeBlend | ||
let key = trimmed.substring(0, splitIndex); | ||
key = key.substring(0, key.length - encodeBlend.length); | ||
config[key] = { | ||
readonly: true, | ||
}; | ||
} | ||
const textValue = '.Text'; | ||
for (const line of body.split(/\r?\n/).filter(l => l.includes(textValue + '='))) { | ||
const trimmed = line.trim(); | ||
if (!trimmed) continue; | ||
const splitIndex = trimmed.indexOf("="); | ||
if (splitIndex === -1) continue; | ||
// remove encodeBlend | ||
let key = trimmed.substring(0, splitIndex); | ||
key = key.substring(0, key.length - textValue.length); | ||
const text = trimmed.substring(splitIndex + 1).trim(); | ||
const c = config[key]; | ||
if (!c) | ||
continue; | ||
delete c.readonly; | ||
c.text = text; | ||
} | ||
return config; | ||
} else { | ||
throw new Error('invalid response'); | ||
// const json = await xml2js.parseStringPromise(body); | ||
// return { json, xml: body }; | ||
} | ||
} | ||
async setVideoTextOverlay(id: string, value: VideoTextOverlay): Promise<void> { | ||
// trim the table. off id | ||
if (id.startsWith('table.')) | ||
id = id.substring('table.'.length); | ||
const client = this.getClient(); | ||
if (value.text) { | ||
const enableUrl = `http://${this.getHttpAddress()}/cgi-bin/configManager.cgi?action=setConfig&${id}.EncodeBlend=true&${id}.PreviewBlend=true`; | ||
await client.request({ | ||
method: "GET", | ||
url: enableUrl, | ||
responseType: "text", | ||
}); | ||
const textUrl = `http://${this.getHttpAddress()}/cgi-bin/configManager.cgi?action=setConfig&${id}.Text=${encodeURIComponent( | ||
value.text | ||
)}`; | ||
await client.request({ | ||
method: "GET", | ||
url: textUrl, | ||
responseType: "text", | ||
}); | ||
} | ||
else { | ||
const disableUrl = `http://${this.getHttpAddress()}/cgi-bin/configManager.cgi?action=setConfig&${id}.EncodeBlend=false&${id}.PreviewBlend=false`; | ||
await client.request({ | ||
method: "GET", | ||
url: disableUrl, | ||
responseType: "text", | ||
}); | ||
} | ||
} | ||
async reboot() { | ||
@@ -637,2 +722,3 @@ const client = this.getClient(); | ||
ScryptedInterface.MotionSensor, | ||
ScryptedInterface.VideoTextOverlays, | ||
]; | ||
@@ -639,0 +725,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
411923
2074
4
3
14
+ Addedxml2js@^0.6.2
+ Addedsax@1.4.1(transitive)
+ Addedxml2js@0.6.2(transitive)
+ Addedxmlbuilder@11.0.1(transitive)