From 3cf82a02ff0709c8a5d841a1bb46399fc4899257 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 24 Mar 2022 10:31:28 -0700 Subject: [PATCH] amcrest: fix initial setup bug --- plugins/amcrest/package-lock.json | 4 ++-- plugins/amcrest/package.json | 2 +- plugins/amcrest/src/main.ts | 18 +++++------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/plugins/amcrest/package-lock.json b/plugins/amcrest/package-lock.json index 4215fa269..482d7c9f5 100644 --- a/plugins/amcrest/package-lock.json +++ b/plugins/amcrest/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/amcrest", - "version": "0.0.93", + "version": "0.0.94", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/amcrest", - "version": "0.0.93", + "version": "0.0.94", "license": "Apache", "dependencies": { "@koush/axios-digest-auth": "^0.8.5", diff --git a/plugins/amcrest/package.json b/plugins/amcrest/package.json index c6798efe6..fc74147e0 100644 --- a/plugins/amcrest/package.json +++ b/plugins/amcrest/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/amcrest", - "version": "0.0.93", + "version": "0.0.94", "description": "Amcrest Plugin for Scrypted", "author": "Scrypted", "license": "Apache", diff --git a/plugins/amcrest/src/main.ts b/plugins/amcrest/src/main.ts index 23dd4f449..228f02701 100644 --- a/plugins/amcrest/src/main.ts +++ b/plugins/amcrest/src/main.ts @@ -9,7 +9,6 @@ import net from 'net'; import { listenZero } from "@scrypted/common/src/listen-cluster"; import { readLength } from "@scrypted/common/src/read-stream"; import { OnvifIntercom } from "../../onvif/src/onvif-intercom"; -import { parse } from "path"; const { mediaManager } = sdk; @@ -30,7 +29,6 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, eventStream: Stream; cp: ChildProcess; client: AmcrestCameraClient; - maxExtraStreams: Promise; videoStreamOptions: Promise; onvifIntercom = new OnvifIntercom(this); @@ -265,8 +263,8 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, async getConstructedVideoStreamOptions(): Promise { const client = this.getClient(); - if (!this.maxExtraStreams) { - this.maxExtraStreams = (async () => { + if (!this.videoStreamOptions) { + this.videoStreamOptions = (async () => { let mas: string; try { const response = await client.digestAuth.request({ @@ -280,17 +278,11 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, catch (e) { this.console.error('error retrieving max extra streams', e); mas = this.storage.getItem('maxExtraStreams'); - this.maxExtraStreams = undefined; } - return parseInt(mas) || 1; - })(); - } - if (!this.videoStreamOptions) { - this.videoStreamOptions = (async () => { - const mas = await this.maxExtraStreams; + const maxExtraStreams = parseInt(mas) || 1; const channel = parseInt(this.getRtspChannel()) || 1; - const vsos = [...Array(mas + 1).keys()].map(subtype => this.createRtspMediaStreamOptions(`rtsp://${this.getRtspAddress()}/cam/realmonitor?channel=${channel}&subtype=${subtype}`, subtype)); + const vsos = [...Array(maxExtraStreams + 1).keys()].map(subtype => this.createRtspMediaStreamOptions(`rtsp://${this.getRtspAddress()}/cam/realmonitor?channel=${channel}&subtype=${subtype}`, subtype)); try { const capResponse = await client.digestAuth.request({ @@ -364,7 +356,7 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration, } this.client = undefined; - this.maxExtraStreams = undefined; + this.videoStreamOptions = undefined; super.putSetting(key, value); const doorbellType = this.storage.getItem('doorbellType');