node-red-contrib-hik-media-buffer 1.1.122 → 1.1.123
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/hik-media-buffer.js +11 -11
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = function(RED) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// --- 1. PRENDE IL NOME REALE DELLA TELECAMERA DAL DIGITAL PROXY ---
|
|
40
|
-
async function
|
|
40
|
+
async function getCameraName(channelID) {
|
|
41
41
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
42
42
|
try {
|
|
43
43
|
// In accordo con la pag. 58 della documentazione, interroghiamo l'InputProxy del canale digitale
|
|
@@ -62,7 +62,7 @@ module.exports = function(RED) {
|
|
|
62
62
|
if (isClosing || !nvrOnline) return;
|
|
63
63
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
64
64
|
try {
|
|
65
|
-
// Chiamata all'endpoint
|
|
65
|
+
// Chiamata all'endpoint di status dei canali proxy (Pag. 322)
|
|
66
66
|
const res = await nvrAuth.request({
|
|
67
67
|
method: 'GET',
|
|
68
68
|
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels/status`,
|
|
@@ -77,24 +77,24 @@ module.exports = function(RED) {
|
|
|
77
77
|
for (let block of channelBlocks) {
|
|
78
78
|
const idMatch = block.match(/<id>([\s\S]*?)<\/id>/i);
|
|
79
79
|
const onlineMatch = block.match(/<online>[ \t]*(true|false)[ \t]*<\/online>/i);
|
|
80
|
-
const nameMatch = block.match(/<channelName>([^<]+)<\/channelName>/i);
|
|
81
80
|
|
|
82
81
|
if (idMatch) {
|
|
83
82
|
const ch = idMatch[1].trim();
|
|
84
83
|
// Estraiamo lo stato online nativo (true/false)
|
|
85
84
|
const isOnline = onlineMatch ? onlineMatch[1].trim().toLowerCase() === "true" : false;
|
|
86
|
-
// Estraiamo il nome reale configurato nell'NVR (se vuoto o "--", usiamo un fallback)
|
|
87
|
-
let nomeCameraReal = nameMatch ? nameMatch[1].trim() : `Camera ${ch}`;
|
|
88
|
-
if (nomeCameraReal === "--") nomeCameraReal = `Camera ${ch}`;
|
|
89
85
|
|
|
90
86
|
if (isOnline && statoCamera[ch] === false) {
|
|
91
|
-
|
|
87
|
+
// 🌟 RECUPERO REALE DEL NOME: Usiamo getCameraName per avere il nome corretto OSD ("ufficio")
|
|
88
|
+
const nomeOnline = await getCameraName(ch);
|
|
89
|
+
|
|
90
|
+
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "online", nome_cliente: node.name, nome_telecamera: nomeOnline, ip_telecamera: node.host, channel: ch, msg: "Camera ripristinata" } });
|
|
92
91
|
statoCamera[ch] = true;
|
|
93
92
|
} else if (!isOnline && statoCamera[ch] === true) {
|
|
94
|
-
|
|
93
|
+
// Per l'offline usiamo un fallback sul canale, dato che la cam non risponderebbe a getCameraName
|
|
94
|
+
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "offline", nome_cliente: node.name, nome_telecamera: `Camera ${ch}`, ip_telecamera: node.host, channel: ch, msg: "Camera non raggiungibile" } });
|
|
95
95
|
statoCamera[ch] = false;
|
|
96
96
|
} else if (statoCamera[ch] === undefined) {
|
|
97
|
-
//
|
|
97
|
+
// Memorizzazione iniziale dello stato al boot
|
|
98
98
|
statoCamera[ch] = isOnline;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -126,14 +126,14 @@ module.exports = function(RED) {
|
|
|
126
126
|
lastTriggerTime[channelID] = nowTime;
|
|
127
127
|
|
|
128
128
|
node.status({fill:"yellow", shape:"dot", text:`Attesa scrittura NVR (6s)...`});
|
|
129
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
129
|
+
await new Promise(resolve => setTimeout(resolve, 8000));
|
|
130
130
|
|
|
131
131
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
132
132
|
const referenceTime = new Date();
|
|
133
133
|
const timestamp = Math.floor(referenceTime.getTime() / 1000);
|
|
134
134
|
|
|
135
135
|
const videoTrackID = (parseInt(channelID) * 100) + 1;
|
|
136
|
-
const nomeCamera = await
|
|
136
|
+
const nomeCamera = await getCameraName(channelID);
|
|
137
137
|
node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
|
|
138
138
|
|
|
139
139
|
const inizioFinestra = new Date(referenceTime.getTime() - (2 * 60 * 1000));
|