@scrypted/amcrest
Advanced tools
Comparing version 0.0.84 to 0.0.85
{ | ||
"name": "@scrypted/amcrest", | ||
"version": "0.0.84", | ||
"version": "0.0.85", | ||
"description": "Amcrest Plugin for Scrypted", | ||
@@ -5,0 +5,0 @@ "author": "Scrypted", |
@@ -11,2 +11,3 @@ import sdk, { MediaObject, Camera, ScryptedInterface, Setting, ScryptedDeviceType, Intercom, FFMpegInput, ScryptedMimeTypes, PictureOptions, VideoCameraConfiguration, MediaStreamOptions } from "@scrypted/sdk"; | ||
import { readLength } from "../../../common/src/read-stream"; | ||
import { OnvifIntercom } from "../../onvif/src/onvif-intercom"; | ||
@@ -23,2 +24,3 @@ const { mediaManager } = sdk; | ||
maxExtraStreams: number; | ||
onvifIntercom = new OnvifIntercom(this); | ||
@@ -171,13 +173,25 @@ constructor(nativeId: string, provider: RtspProvider) { | ||
const isDoorbell = doorbellType === AMCREST_DOORBELL_TYPE || doorbellType === DAHUA_DOORBELL_TYPE; | ||
if (!isDoorbell) { | ||
ret.push( | ||
{ | ||
title: 'Two Way Audio', | ||
value: this.storage.getItem('twoWayAudio') === 'true', | ||
key: 'twoWayAudio', | ||
type: 'boolean', | ||
}, | ||
) | ||
} | ||
let twoWayAudio = this.storage.getItem('twoWayAudio'); | ||
if (twoWayAudio === 'true') | ||
twoWayAudio = 'Amcrest'; | ||
const choices = [ | ||
'Amcrest', | ||
'ONVIF', | ||
]; | ||
if (!isDoorbell) | ||
choices.unshift('None'); | ||
ret.push( | ||
{ | ||
title: 'Two Way Audio', | ||
value: twoWayAudio, | ||
key: 'twoWayAudio', | ||
description: 'Amcrest cameras may support both Amcrest and ONVIF two way audio protocols. ONVIF generally performs better when supported.', | ||
choices, | ||
}, | ||
) | ||
return ret; | ||
@@ -208,2 +222,10 @@ } | ||
createRtspMediaStreamOptions(url: string, index: number) { | ||
const ret = super.createRtspMediaStreamOptions(url, index); | ||
ret.tool = 'scrypted'; | ||
return ret; | ||
} | ||
async getConstructedVideoStreamOptions(): Promise<UrlMediaStreamOptions[]> { | ||
@@ -238,3 +260,6 @@ let mas = this.maxExtraStreams; | ||
const isDoorbell = doorbellType === AMCREST_DOORBELL_TYPE || doorbellType === DAHUA_DOORBELL_TYPE; | ||
const twoWayAudio = this.storage.getItem('twoWayAudio') === 'true'; | ||
// true is the legacy value before onvif was added. | ||
const twoWayAudio = this.storage.getItem('twoWayAudio') === 'true' | ||
|| this.storage.getItem('twoWayAudio') === 'ONVIF' | ||
|| this.storage.getItem('twoWayAudio') === 'Amcrest'; | ||
@@ -254,2 +279,13 @@ const interfaces = provider.getInterfaces(); | ||
async startIntercom(media: MediaObject): Promise<void> { | ||
if (this.storage.getItem('twoWayAudio') === 'ONVIF') { | ||
const options = await this.getConstructedVideoStreamOptions(); | ||
const stream = options[0]; | ||
const url = new URL(stream.url); | ||
// amcrest onvif requires this proto query parameter, or onvif two way | ||
// will not activate. | ||
url.searchParams.set('proto', 'Onvif'); | ||
this.onvifIntercom.url = url.toString(); | ||
return this.onvifIntercom.startIntercom(media); | ||
} | ||
// not sure if this all works, since i don't actually have a doorbell. | ||
@@ -318,2 +354,6 @@ // good luck! | ||
async stopIntercom(): Promise<void> { | ||
if (this.storage.getItem('twoWayAudio') === 'ONVIF') { | ||
return this.onvifIntercom.stopIntercom(); | ||
} | ||
this.cp?.kill(); | ||
@@ -320,0 +360,0 @@ this.cp = undefined; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
278514
853
6