amcrest: fix initial setup bug

This commit is contained in:
Koushik Dutta
2022-03-24 10:31:28 -07:00
parent 8125fc439d
commit 3cf82a02ff
3 changed files with 8 additions and 16 deletions

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.93",
"version": "0.0.94",
"description": "Amcrest Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -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<number>;
videoStreamOptions: Promise<UrlMediaStreamOptions[]>;
onvifIntercom = new OnvifIntercom(this);
@@ -265,8 +263,8 @@ class AmcrestCamera extends RtspSmartCamera implements VideoCameraConfiguration,
async getConstructedVideoStreamOptions(): Promise<UrlMediaStreamOptions[]> {
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');