]> git.basschouten.com Git - openhab-addons.git/commitdiff
fix mjpeg does not work if overridden (#17544)
authorMatthew Skinner <matt@pcmus.com>
Sat, 12 Oct 2024 08:04:53 +0000 (19:04 +1100)
committerGitHub <noreply@github.com>
Sat, 12 Oct 2024 08:04:53 +0000 (10:04 +0200)
Signed-off-by: Matthew Skinner <matt@pcmus.com>
bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/DahuaHandler.java
bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/ReolinkHandler.java
bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java
bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/onvif/OnvifConnection.java

index fa97c5ddc451a22467e7ba82ae2f19ba55dbe1cb..37d4c889227fa4fbda4d7024e6f77ebda2d290dc 100644 (file)
@@ -20,6 +20,7 @@ import java.util.regex.Pattern;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.ipcamera.internal.handler.IpCameraHandler;
+import org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.RequestType;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -156,6 +157,7 @@ public class DahuaHandler extends ChannelDuplexHandler {
                     ipCameraHandler.setChannelState(CHANNEL_TOO_DARK_ALARM, OnOffType.OFF);
                 }
                 break;
+            case "SceneChange":
             case "VideoAbnormalDetection":
                 if ("Start".equals(action)) {
                     ipCameraHandler.setChannelState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.ON);
@@ -191,10 +193,14 @@ public class DahuaHandler extends ChannelDuplexHandler {
             case "LensMaskClose":
                 ipCameraHandler.setChannelState(CHANNEL_ENABLE_PRIVACY_MODE, OnOffType.OFF);
                 break;
-            // Skip these so they are not logged.
             case "TimeChange":
+                // Check updated time matches openHAB's and store the offset which is needed for ONVIF
+                ipCameraHandler.onvifCamera.sendOnvifRequest(RequestType.GetSystemDateAndTime,
+                        ipCameraHandler.onvifCamera.deviceXAddr);
+                break;
+            // Skip these so they are not logged.
+            case "NTPAdjustTime": // will trigger a TimeChange event no need to check twice
             case "IntelliFrame":
-            case "NTPAdjustTime":
             case "StorageChange":
             case "Reboot":
             case "NewFile":
@@ -202,6 +208,7 @@ public class DahuaHandler extends ChannelDuplexHandler {
             case "RtspSessionDisconnect":
             case "LeFunctionStatusSync":
             case "RecordDelete":
+            case "InterVideoAccess":
                 break;
             default:
                 ipCameraHandler.logger.debug("Unrecognised Dahua event, Code={}, action={}", code, action);
@@ -324,7 +331,7 @@ public class DahuaHandler extends ChannelDuplexHandler {
                 } else if (command instanceof PercentType percentCommand) {
                     ipCameraHandler.sendHttpGET("/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2["
                             + nvrChannelAdjusted + "][0][1].Mode=Manual&Lighting_V2[" + nvrChannelAdjusted
-                            + "][0][1].NearLight[0].Light=" + command.toString());
+                            + "][0][1].NearLight[0].Light=" + percentCommand.toString());
                 }
                 return;
             case CHANNEL_AUTO_WHITE_LED:
index c4f8100df3dbbf180d082f02399d5d079e654c1f..5ea9b76eccd2f007666f6482c101ac15636613d3 100644 (file)
@@ -452,7 +452,7 @@ public class ReolinkHandler extends ChannelDuplexHandler {
                     ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetIrLights" + ipCameraHandler.reolinkAuth,
                             "[{\"cmd\": \"SetIrLights\",\"action\": 0,\"param\": {\"IrLights\": {\"channel\": "
                                     + ipCameraHandler.cameraConfig.getNvrChannel() + ",\"state\": \"Off\"}}}]");
-                } else if (OnOffType.ON.equals(command) || command instanceof PercentType percentCommand) {
+                } else if (OnOffType.ON.equals(command) || command instanceof PercentType) {
                     ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetIrLights" + ipCameraHandler.reolinkAuth,
                             "[{\"cmd\": \"SetIrLights\",\"action\": 0,\"param\": {\"IrLights\": {\"channel\": "
                                     + ipCameraHandler.cameraConfig.getNvrChannel() + ",\"state\": \"On\"}}}]");
index 94c9cb437c51c640490517e0ebec32b22b22bf48..70223f7b5effa4fb77c171c043ca1872873e9694 100644 (file)
@@ -241,7 +241,7 @@ public class IpCameraHandler extends BaseThingHandler {
                             }
                             if (contentType.contains("multipart")) {
                                 boundary = Helper.searchString(contentType, "boundary=");
-                                if (mjpegUri.equals(requestUrl)) {
+                                if (mjpegUri.endsWith(requestUrl)) {
                                     if (msg instanceof HttpMessage) {
                                         // very start of stream only
                                         mjpegContentType = contentType;
index 71c0d7ac0a74fe29204ee8dec3e4c54bf9a3fa68..bbe4457e073a447aaf0f8c4224906564dc2807e9 100644 (file)
@@ -124,7 +124,7 @@ public class OnvifConnection {
     private String user = "";
     private String password = "";
     private int onvifPort = 80;
-    private String deviceXAddr = "http://" + ipAddress + "/onvif/device_service";
+    public String deviceXAddr = "http://" + ipAddress + "/onvif/device_service";
     private String eventXAddr = "http://" + ipAddress + "/onvif/device_service";
     private String mediaXAddr = "http://" + ipAddress + "/onvif/device_service";
     @SuppressWarnings("unused")