try to ensure ONVIF device is init when snapshotting

patrol-onvif-ptz-gamepad
Moe 2024-12-17 19:42:57 -08:00
parent 8b40f7f38a
commit 3b2b31579a
1 changed files with 10 additions and 8 deletions

View File

@ -137,14 +137,16 @@ module.exports = function(s,config,lang,app,io){
if(onvifOptions.mid && onvifOptions.ke){
const groupKey = onvifOptions.ke
const monitorId = onvifOptions.mid
const theDevice = s.group[groupKey].activeMonitors[monitorId].onvifConnection
theUrl = addCredentialsToUrl({
username: theDevice.user,
password: theDevice.pass,
url: (await theDevice.services.media.getSnapshotUri({
ProfileToken : theDevice.current_profile.token,
})).data.GetSnapshotUriResponse.MediaUri.Uri
});
const theDevice = s.group[groupKey].activeMonitors[monitorId].onvifConnection || (await s.createOnvifDevice({ id: e.mid, ke: e.ke })).device;
if(theDevice){
theUrl = addCredentialsToUrl({
username: theDevice.user,
password: theDevice.pass,
url: (await theDevice.services.media.getSnapshotUri({
ProfileToken : theDevice.current_profile.token,
})).data.GetSnapshotUriResponse.MediaUri.Uri
});
}
}else{
theUrl = addCredentialsToStreamLink({
username: onvifOptions.username,