pam-diff: fix session abruptly ending

This commit is contained in:
Koushik Dutta
2022-10-05 13:24:37 -07:00
parent 0ddbb5c03b
commit af789a27dd
3 changed files with 7 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/pam-diff",
"version": "0.0.8",
"version": "0.0.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/pam-diff",
"version": "0.0.8",
"version": "0.0.9",
"hasInstallScript": true,
"dependencies": {
"@types/node": "^16.6.1",

View File

@@ -43,5 +43,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.0.8"
"version": "0.0.9"
}

View File

@@ -1,4 +1,4 @@
import { FFmpegInput, MediaObject, ObjectDetection, ObjectDetectionModel, ObjectDetectionSession, ObjectsDetected, ScryptedDeviceBase, ScryptedInterface, ScryptedMimeTypes } from '@scrypted/sdk';
import { FFmpegInput, MediaObject, ObjectDetection, ObjectDetectionCallbacks, ObjectDetectionModel, ObjectDetectionSession, ObjectsDetected, ScryptedDeviceBase, ScryptedInterface, ScryptedMimeTypes } from '@scrypted/sdk';
import sdk from '@scrypted/sdk';
import { ffmpegLogInitialOutput } from "../../../common/src/media-helpers";
@@ -39,16 +39,15 @@ class PamDiff extends ScryptedDeviceBase implements ObjectDetection {
pds.timeout = setTimeout(() => this.endSession(pds), duration);
}
async detectObjects(mediaObject: MediaObject, session?: ObjectDetectionSession): Promise<ObjectsDetected> {
async detectObjects(mediaObject: MediaObject, session?: ObjectDetectionSession, callbacks?: ObjectDetectionCallbacks): Promise<ObjectsDetected> {
if (mediaObject && mediaObject.mimeType?.startsWith('image/'))
throw new Error('can not run motion detection on image')
let { detectionId } = session;
let pds = this.sessions.get(detectionId);
if (!mediaObject) {
if (pds) {
if (!session?.duration || !pds) {
if (pds)
this.endSession(pds);
}
return {
detectionId,
running: false,