@apocaliss92/scrypted-reolink-native 0.4.34 → 0.4.35
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/package.json +1 -1
- package/src/intercom-mixin.ts +17 -99
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/intercom-mixin.ts
CHANGED
|
@@ -25,48 +25,8 @@ export class ReolinkNativeIntercomMixin
|
|
|
25
25
|
private intercomEngine?: ReolinkBaichuanIntercom;
|
|
26
26
|
|
|
27
27
|
storageSettings = new StorageSettings(this, {
|
|
28
|
-
// Connection settings (hidden when attached to an internal Reolink Native camera)
|
|
29
|
-
intercomIpAddress: {
|
|
30
|
-
group: "Connection",
|
|
31
|
-
title: "IP Address",
|
|
32
|
-
description: "Camera IP address for Baichuan connection",
|
|
33
|
-
type: "string",
|
|
34
|
-
},
|
|
35
|
-
intercomUsername: {
|
|
36
|
-
group: "Connection",
|
|
37
|
-
title: "Username",
|
|
38
|
-
type: "string",
|
|
39
|
-
defaultValue: "admin",
|
|
40
|
-
},
|
|
41
|
-
intercomPassword: {
|
|
42
|
-
group: "Connection",
|
|
43
|
-
title: "Password",
|
|
44
|
-
type: "password",
|
|
45
|
-
},
|
|
46
|
-
intercomUid: {
|
|
47
|
-
group: "Connection",
|
|
48
|
-
title: "UID",
|
|
49
|
-
description: "Required for battery/UDP cameras",
|
|
50
|
-
type: "string",
|
|
51
|
-
},
|
|
52
|
-
intercomChannel: {
|
|
53
|
-
group: "Connection",
|
|
54
|
-
title: "Channel",
|
|
55
|
-
description: "RTSP channel number (0-based)",
|
|
56
|
-
type: "number",
|
|
57
|
-
defaultValue: 0,
|
|
58
|
-
},
|
|
59
|
-
intercomTransport: {
|
|
60
|
-
group: "Connection",
|
|
61
|
-
title: "Transport",
|
|
62
|
-
description: "Connection transport protocol",
|
|
63
|
-
type: "string",
|
|
64
|
-
choices: ["tcp", "udp"],
|
|
65
|
-
defaultValue: "tcp",
|
|
66
|
-
},
|
|
67
|
-
// Audio pipeline settings (always visible)
|
|
68
28
|
intercomBlocksPerPayload: {
|
|
69
|
-
group: "
|
|
29
|
+
group: "Intercom",
|
|
70
30
|
title: "Blocks Per Payload",
|
|
71
31
|
description:
|
|
72
32
|
"Lower reduces latency (more packets). Typical: 1-4. Requires restarting talk session to take effect.",
|
|
@@ -74,7 +34,7 @@ export class ReolinkNativeIntercomMixin
|
|
|
74
34
|
defaultValue: 1,
|
|
75
35
|
},
|
|
76
36
|
intercomMaxBacklogMs: {
|
|
77
|
-
group: "
|
|
37
|
+
group: "Intercom",
|
|
78
38
|
title: "Max Backlog (ms)",
|
|
79
39
|
description:
|
|
80
40
|
"Maximum PCM backlog before dropping old audio to cap latency. Higher improves stability on slow systems but increases latency. Typical: 80-250. Requires restarting talk session to take effect.",
|
|
@@ -82,7 +42,7 @@ export class ReolinkNativeIntercomMixin
|
|
|
82
42
|
defaultValue: 120,
|
|
83
43
|
},
|
|
84
44
|
intercomGain: {
|
|
85
|
-
group: "
|
|
45
|
+
group: "Intercom",
|
|
86
46
|
title: "Gain",
|
|
87
47
|
description:
|
|
88
48
|
"Output gain multiplier applied before encoding. 1.0 = normal, 2.0 ≈ +6dB, 0.5 ≈ -6dB. Requires restarting talk session to take effect.",
|
|
@@ -103,21 +63,13 @@ export class ReolinkNativeIntercomMixin
|
|
|
103
63
|
return this.provider.plugin?.camerasMap?.get(this.id);
|
|
104
64
|
}
|
|
105
65
|
|
|
106
|
-
private isReolinkPluginCamera(): boolean {
|
|
107
|
-
try {
|
|
108
|
-
const device = sdk.systemManager.getDeviceById(this.id);
|
|
109
|
-
return device?.pluginId === "@scrypted/reolink";
|
|
110
|
-
} catch {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
66
|
private async getReolinkPluginCredentials(): Promise<
|
|
116
67
|
{ host?: string; username?: string; password?: string } | undefined
|
|
117
68
|
> {
|
|
118
|
-
if (!this.isReolinkPluginCamera()) return undefined;
|
|
119
|
-
|
|
120
69
|
try {
|
|
70
|
+
const device = sdk.systemManager.getDeviceById(this.id);
|
|
71
|
+
if (device?.pluginId !== "@scrypted/reolink") return undefined;
|
|
72
|
+
|
|
121
73
|
const settings: Setting[] = await this.mixinDevice.getSettings();
|
|
122
74
|
const map = new Map(
|
|
123
75
|
settings.map((s: Setting) => [s.key, s.value?.toString()]),
|
|
@@ -174,7 +126,7 @@ export class ReolinkNativeIntercomMixin
|
|
|
174
126
|
};
|
|
175
127
|
}
|
|
176
128
|
|
|
177
|
-
// External path: use shared client from plugin registry
|
|
129
|
+
// External path (@scrypted/reolink): use shared client from plugin registry
|
|
178
130
|
return {
|
|
179
131
|
get blocksPerPayload() {
|
|
180
132
|
return Math.max(
|
|
@@ -194,10 +146,10 @@ export class ReolinkNativeIntercomMixin
|
|
|
194
146
|
return Number.isFinite(v) ? Math.max(20, Math.min(5000, v)) : 120;
|
|
195
147
|
},
|
|
196
148
|
get channel() {
|
|
197
|
-
return
|
|
149
|
+
return 0;
|
|
198
150
|
},
|
|
199
151
|
get isBatteryCamera() {
|
|
200
|
-
return
|
|
152
|
+
return false;
|
|
201
153
|
},
|
|
202
154
|
get deviceId() {
|
|
203
155
|
return self.id;
|
|
@@ -211,34 +163,20 @@ export class ReolinkNativeIntercomMixin
|
|
|
211
163
|
}
|
|
212
164
|
|
|
213
165
|
private async ensureExternalApi(): Promise<ReolinkBaichuanApi> {
|
|
214
|
-
|
|
215
|
-
intercomUid, intercomTransport } =
|
|
216
|
-
this.storageSettings.values;
|
|
166
|
+
const creds = await this.getReolinkPluginCredentials();
|
|
217
167
|
|
|
218
|
-
|
|
219
|
-
if (!intercomIpAddress || !intercomUsername || !intercomPassword) {
|
|
220
|
-
const creds = await this.getReolinkPluginCredentials();
|
|
221
|
-
if (creds) {
|
|
222
|
-
intercomIpAddress ||= creds.host;
|
|
223
|
-
intercomUsername ||= creds.username;
|
|
224
|
-
intercomPassword ||= creds.password;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!intercomIpAddress || !intercomUsername || !intercomPassword) {
|
|
168
|
+
if (!creds?.host || !creds?.username || !creds?.password) {
|
|
229
169
|
throw new Error(
|
|
230
|
-
"
|
|
170
|
+
"Could not read camera credentials from @scrypted/reolink settings",
|
|
231
171
|
);
|
|
232
172
|
}
|
|
233
173
|
|
|
234
|
-
const transport: BaichuanTransport =
|
|
235
|
-
intercomTransport === "udp" ? "udp" : "tcp";
|
|
174
|
+
const transport: BaichuanTransport = "tcp";
|
|
236
175
|
|
|
237
176
|
return await this.provider.plugin.acquireExternalClient(this.id, {
|
|
238
|
-
host:
|
|
239
|
-
username:
|
|
240
|
-
password:
|
|
241
|
-
uid: intercomUid,
|
|
177
|
+
host: creds.host,
|
|
178
|
+
username: creds.username,
|
|
179
|
+
password: creds.password,
|
|
242
180
|
transport,
|
|
243
181
|
logger: this.console,
|
|
244
182
|
});
|
|
@@ -258,27 +196,7 @@ export class ReolinkNativeIntercomMixin
|
|
|
258
196
|
}
|
|
259
197
|
|
|
260
198
|
async getMixinSettings(): Promise<Setting[]> {
|
|
261
|
-
|
|
262
|
-
const isReolinkPlugin = this.isReolinkPluginCamera();
|
|
263
|
-
const hideConnection = isInternal || isReolinkPlugin;
|
|
264
|
-
const settings = await this.storageSettings.getSettings();
|
|
265
|
-
|
|
266
|
-
const connectionKeys = new Set([
|
|
267
|
-
"intercomIpAddress",
|
|
268
|
-
"intercomUsername",
|
|
269
|
-
"intercomPassword",
|
|
270
|
-
"intercomUid",
|
|
271
|
-
"intercomChannel",
|
|
272
|
-
"intercomTransport",
|
|
273
|
-
]);
|
|
274
|
-
|
|
275
|
-
for (const setting of settings) {
|
|
276
|
-
if (connectionKeys.has(setting.key)) {
|
|
277
|
-
(setting as any).hide = hideConnection;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return settings;
|
|
199
|
+
return this.storageSettings.getSettings();
|
|
282
200
|
}
|
|
283
201
|
|
|
284
202
|
async putMixinSetting(
|