Allow ONVIF to come online if they dont support events. (#16332)

Remove commented out code.

Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Matthew Skinner 2024-02-04 21:19:24 +11:00 committed by Ciprian Pascu
parent 769e3c44c0
commit 0c2b95e48f
2 changed files with 12 additions and 7 deletions

View File

@ -514,17 +514,16 @@ public class IpCameraHandler extends BaseThingHandler {
private void checkCameraConnection() {
if (snapshotPolling) { // Currently polling a real URL for snapshots, so camera must be online.
return;
} else if (ffmpegSnapshotGeneration) { // Use RTSP stream creating snapshots to know camera is online.
} else if (ffmpegSnapshotGeneration) {
Ffmpeg localSnapshot = ffmpegSnapshot;
if (localSnapshot != null && !localSnapshot.isAlive()) {
cameraCommunicationError("FFmpeg Snapshots Stopped: Check that your camera can be reached.");
}
return; // ffmpeg snapshot stream is still alive
return; // RTSP stream is creating snapshots, so camera is online.
}
// ONVIF cameras get regular event messages from the camera
if (supportsOnvifEvents() && onvifCamera.isConnected()) {
return;
if (supportsOnvifEvents() && onvifCamera.isConnected() && onvifCamera.getEventsSupported()) {
return;// ONVIF cameras that are getting event messages must be online
}
// Open a HTTP connection without sending any requests as we do not need a snapshot.

View File

@ -131,9 +131,10 @@ public class OnvifConnection {
private String subscriptionXAddr = "http://" + ipAddress + "/onvif/device_service";
private boolean isConnected = false;
private int mediaProfileIndex = 0;
// private String snapshotUri = "";
private String rtspUri = "";
private IpCameraHandler ipCameraHandler;
private boolean supportsEvents = false; // camera has replied that it can do events
// Use/skip events even if camera support them. API cameras skip, as their own methods give better results.
private boolean usingEvents = false;
// These hold the cameras PTZ position in the range that the camera uses, ie
@ -312,7 +313,7 @@ public class OnvifConnection {
} else if (message.contains("RenewResponse")) {
sendOnvifRequest(RequestType.PullMessages, subscriptionXAddr);
} else if (message.contains("GetSystemDateAndTimeResponse")) {// 1st to be sent.
setIsConnected(true);
setIsConnected(true);// Instar profile T only cameras need this
parseDateAndTime(message);
logger.debug("openHAB UTC dateTime is: {}", getUTCdateTime());
} else if (message.contains("GetCapabilitiesResponse")) {// 2nd to be sent.
@ -337,6 +338,7 @@ public class OnvifConnection {
} else if (message.contains("GetEventPropertiesResponse")) {
sendOnvifRequest(RequestType.CreatePullPointSubscription, eventXAddr);
} else if (message.contains("CreatePullPointSubscriptionResponse")) {
supportsEvents = true;
subscriptionXAddr = Helper.fetchXML(message, "SubscriptionReference>", "Address>");
logger.debug("subscriptionXAddr={}", subscriptionXAddr);
sendOnvifRequest(RequestType.PullMessages, subscriptionXAddr);
@ -958,6 +960,10 @@ public class OnvifConnection {
}
}
public boolean getEventsSupported() {
return supportsEvents;
}
public void setIsConnected(boolean isConnected) {
connecting.lock();
try {