@scrypted/amcrest
Advanced tools
Comparing version 0.0.69 to 0.0.70
{ | ||
"name": "@scrypted/amcrest", | ||
"version": "0.0.69", | ||
"version": "0.0.70", | ||
"description": "Amcrest Plugin for Scrypted", | ||
@@ -5,0 +5,0 @@ "author": "Scrypted", |
@@ -59,6 +59,18 @@ import AxiosDigestAuth from '@koush/axios-digest-auth'; | ||
const data = buffer.toString(); | ||
const parts = data.split(';'); | ||
let index: string; | ||
try { | ||
for (const part of parts) { | ||
if (part.startsWith('index')) { | ||
index = part.split('=')[1]?.trim(); | ||
} | ||
} | ||
} | ||
catch (e) { | ||
this.console.error('error parsing index', data); | ||
} | ||
// this.console?.log('event', data); | ||
for (const event of Object.values(AmcrestEvent)) { | ||
if (data.indexOf(event) !== -1) { | ||
stream.emit('event', event); | ||
stream.emit('event', event, index); | ||
} | ||
@@ -65,0 +77,0 @@ } |
@@ -42,3 +42,9 @@ import sdk, { MediaObject, Camera, ScryptedInterface, Setting, ScryptedDeviceType, Intercom, FFMpegInput, ScryptedMimeTypes, PictureOptions } from "@scrypted/sdk"; | ||
events.on('error', e => ret.emit('error', e)); | ||
events.on('event', (event: AmcrestEvent) => { | ||
events.on('event', (event: AmcrestEvent, index: string) => { | ||
const channelNumber = this.getRtspChannel(); | ||
if (channelNumber) { | ||
const idx = parseInt(index) + 1; | ||
if (idx.toString() !== channelNumber) | ||
return; | ||
} | ||
if (event === AmcrestEvent.MotionStart) { | ||
@@ -45,0 +51,0 @@ this.motionDetected = true; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
225024
686