@apocaliss92/scrypted-reolink-native 0.1.30 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.nodejs.js +1 -1
- package/dist/plugin.zip +0 -0
- package/logs/composite-stream.txt +16390 -0
- package/logs/lense.txt +44 -0
- package/logs/multifocal.txt +136 -0
- package/logs/multifocal2.txt +3585 -0
- package/package.json +1 -1
- package/src/baichuan-base.ts +0 -4
- package/src/camera-battery.ts +4 -62
- package/src/camera.ts +0 -37
- package/src/common.ts +329 -74
- package/src/debug-options.ts +0 -8
- package/src/main.ts +17 -32
- package/src/multiFocal.ts +3 -42
- package/src/nvr.ts +26 -8
- package/src/stream-utils.ts +86 -11
- package/src/utils.ts +1 -0
package/package.json
CHANGED
package/src/baichuan-base.ts
CHANGED
|
@@ -58,10 +58,6 @@ export class BaichuanLogger implements Console {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
isDebugEnabled(): boolean {
|
|
62
|
-
return this.isDebugEnabledCallback();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
61
|
// Console interface implementation - delegate to baseLogger
|
|
66
62
|
assert(condition?: boolean, ...data: any[]): void {
|
|
67
63
|
this.baseLogger.assert(condition, ...data);
|
package/src/camera-battery.ts
CHANGED
|
@@ -13,8 +13,6 @@ import { ReolinkNativeNvrDevice } from "./nvr";
|
|
|
13
13
|
import { ReolinkNativeMultiFocalDevice } from "./multiFocal";
|
|
14
14
|
|
|
15
15
|
export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
16
|
-
private lastPicture: { mo: MediaObject; atMs: number } | undefined;
|
|
17
|
-
private takePictureInFlight: Promise<MediaObject> | undefined;
|
|
18
16
|
doorbellBinaryTimeout?: NodeJS.Timeout;
|
|
19
17
|
motionDetected: boolean = false;
|
|
20
18
|
motionTimeout: NodeJS.Timeout | undefined;
|
|
@@ -22,17 +20,11 @@ export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
|
22
20
|
private sleepCheckTimer: NodeJS.Timeout | undefined;
|
|
23
21
|
private batteryUpdateTimer: NodeJS.Timeout | undefined;
|
|
24
22
|
private lastBatteryLevel: number | undefined;
|
|
25
|
-
private forceNewSnapshot: boolean = false;
|
|
26
23
|
private batteryUpdateInProgress: boolean = false;
|
|
27
24
|
|
|
28
|
-
private isBatteryInfoLoggingEnabled(): boolean {
|
|
29
|
-
const debugLogs = this.storageSettings.values.debugLogs || [];
|
|
30
|
-
return debugLogs.includes(DebugLogOption.BatteryInfo);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
constructor(
|
|
34
|
-
nativeId: string,
|
|
35
|
-
public plugin: ReolinkNativePlugin,
|
|
26
|
+
nativeId: string,
|
|
27
|
+
public plugin: ReolinkNativePlugin,
|
|
36
28
|
nvrDevice?: ReolinkNativeNvrDevice,
|
|
37
29
|
multiFocalDevice?: ReolinkNativeMultiFocalDevice
|
|
38
30
|
) {
|
|
@@ -43,53 +35,6 @@ export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
|
43
35
|
});
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
async takePicture(options?: RequestPictureOptions): Promise<MediaObject> {
|
|
47
|
-
const logger = this.getBaichuanLogger();
|
|
48
|
-
// Allow new snapshot if:
|
|
49
|
-
// 1. forceNewSnapshot is true, OR
|
|
50
|
-
// 2. Camera is awake AND last snapshot was taken at least 10 seconds ago
|
|
51
|
-
// const minSnapshotIntervalMs = 10_000; // 10 seconds
|
|
52
|
-
// const now = Date.now();
|
|
53
|
-
const shouldTakeNewSnapshot = this.forceNewSnapshot;
|
|
54
|
-
// const now = Date.now();
|
|
55
|
-
// const shouldTakeNewSnapshot = this.forceNewSnapshot ||
|
|
56
|
-
// (!this.sleeping && this.lastPicture && (now - this.lastPicture.atMs >= minSnapshotIntervalMs));
|
|
57
|
-
|
|
58
|
-
if (!shouldTakeNewSnapshot && this.lastPicture) {
|
|
59
|
-
logger.debug(`Returning cached snapshot, taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`);
|
|
60
|
-
return this.lastPicture.mo;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (this.takePictureInFlight) {
|
|
64
|
-
return await this.takePictureInFlight;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
logger.log(`Taking new snapshot from camera (forceNewSnapshot: ${this.forceNewSnapshot})`);
|
|
68
|
-
this.forceNewSnapshot = false;
|
|
69
|
-
|
|
70
|
-
this.takePictureInFlight = (async () => {
|
|
71
|
-
const channel = this.storageSettings.values.rtspChannel;
|
|
72
|
-
const snapshotBuffer = await this.withBaichuanClient(async (api) => {
|
|
73
|
-
return await api.getSnapshot(channel);
|
|
74
|
-
});
|
|
75
|
-
const mo = await sdk.mediaManager.createMediaObject(snapshotBuffer, 'image/jpeg');
|
|
76
|
-
this.lastPicture = { mo, atMs: Date.now() };
|
|
77
|
-
logger.log(`Snapshot taken at ${new Date(this.lastPicture.atMs).toLocaleString()}`);
|
|
78
|
-
return mo;
|
|
79
|
-
})();
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
return await this.takePictureInFlight;
|
|
83
|
-
}
|
|
84
|
-
finally {
|
|
85
|
-
this.takePictureInFlight = undefined;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async getPictureOptions(): Promise<ResponsePictureOptions[]> {
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
38
|
async init(): Promise<void> {
|
|
94
39
|
this.startPeriodicTasks();
|
|
95
40
|
await this.alignAuxDevicesState();
|
|
@@ -154,7 +99,7 @@ export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
|
154
99
|
|
|
155
100
|
async updateSleepingState(sleepStatus: SleepStatus): Promise<void> {
|
|
156
101
|
try {
|
|
157
|
-
if (this.
|
|
102
|
+
if (this.isDebugEnabled()) {
|
|
158
103
|
this.getBaichuanLogger().debug('getSleepStatus result:', JSON.stringify(sleepStatus));
|
|
159
104
|
}
|
|
160
105
|
|
|
@@ -212,7 +157,7 @@ export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
|
212
157
|
const channel = this.storageSettings.values.rtspChannel;
|
|
213
158
|
|
|
214
159
|
const batteryInfo = await api.getBatteryInfo(channel);
|
|
215
|
-
if (this.
|
|
160
|
+
if (this.isDebugEnabled()) {
|
|
216
161
|
this.getBaichuanLogger().debug('getBatteryInfo result:', JSON.stringify(batteryInfo));
|
|
217
162
|
}
|
|
218
163
|
|
|
@@ -379,7 +324,4 @@ export class ReolinkNativeBatteryCamera extends CommonCameraMixin {
|
|
|
379
324
|
return fn(client);
|
|
380
325
|
}
|
|
381
326
|
|
|
382
|
-
async createStreamClient(): Promise<ReolinkBaichuanApi> {
|
|
383
|
-
return await this.ensureClient();
|
|
384
|
-
}
|
|
385
327
|
}
|
package/src/camera.ts
CHANGED
|
@@ -74,28 +74,6 @@ export class ReolinkNativeCamera extends CommonCameraMixin {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
async createStreamClient(): Promise<ReolinkBaichuanApi> {
|
|
78
|
-
const { ipAddress, username, password } = this.storageSettings.values;
|
|
79
|
-
const logger = this.getBaichuanLogger();
|
|
80
|
-
|
|
81
|
-
const debugOptions = this.getBaichuanDebugOptions();
|
|
82
|
-
const api = await createBaichuanApi(
|
|
83
|
-
{
|
|
84
|
-
inputs: {
|
|
85
|
-
host: ipAddress,
|
|
86
|
-
username: username,
|
|
87
|
-
password: password,
|
|
88
|
-
logger,
|
|
89
|
-
debugOptions
|
|
90
|
-
},
|
|
91
|
-
transport: 'tcp',
|
|
92
|
-
},
|
|
93
|
-
);
|
|
94
|
-
await api.login();
|
|
95
|
-
|
|
96
|
-
return api;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
77
|
private passiveRefreshTimer: ReturnType<typeof setTimeout> | undefined;
|
|
100
78
|
|
|
101
79
|
async release() {
|
|
@@ -175,21 +153,6 @@ export class ReolinkNativeCamera extends CommonCameraMixin {
|
|
|
175
153
|
return fn(client);
|
|
176
154
|
}
|
|
177
155
|
|
|
178
|
-
async takePicture(options?: RequestPictureOptions) {
|
|
179
|
-
try {
|
|
180
|
-
return this.withBaichuanRetry(async () => {
|
|
181
|
-
const client = await this.ensureClient();
|
|
182
|
-
const snapshotBuffer = await client.getSnapshot(this.storageSettings.values.rtspChannel);
|
|
183
|
-
const mo = await this.createMediaObject(snapshotBuffer, 'image/jpeg');
|
|
184
|
-
|
|
185
|
-
return mo;
|
|
186
|
-
});
|
|
187
|
-
} catch (e) {
|
|
188
|
-
this.getBaichuanLogger().error('Error taking snapshot', e);
|
|
189
|
-
throw e;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
156
|
async getPictureOptions(): Promise<ResponsePictureOptions[]> {
|
|
194
157
|
return [];
|
|
195
158
|
}
|