From e476c43e34613b56b16927299aa980a3515ba036 Mon Sep 17 00:00:00 2001 From: Matthew Skinner Date: Sun, 31 Oct 2021 03:00:34 +1100 Subject: [PATCH] [ipcamera] Fix Hikvision digest stopping ipcamera.mjpeg (#11457) * Stop hik logging 401 with digest. Signed-off-by: Matthew Skinner * Improve and fix generic cams Signed-off-by: Matthew Skinner * Stop dahua IntelliFrame logging Signed-off-by: Matthew Skinner * Catch IllegalStateException Signed-off-by: Matthew Skinner * Trial reusing channels. Signed-off-by: Matthew Skinner * Tidy up Signed-off-by: Matthew Skinner * cleanup 2 Signed-off-by: Matthew Skinner * Cleanup 3 Signed-off-by: Matthew Skinner * Disable checking connection with event stream. Signed-off-by: Matthew Skinner * Bug fix Signed-off-by: Matthew Skinner * more cleanup Signed-off-by: Matthew Skinner * more cleanup Signed-off-by: Matthew Skinner * Reduce logging to only whats needed. Signed-off-by: Matthew Skinner * fix offline detection. Signed-off-by: Matthew Skinner * fixes to ipcamera.mjpeg Signed-off-by: Matthew Skinner * reverse some connection checks Signed-off-by: Matthew Skinner * Fix Hikvision Digest stops ipcamera.mjpeg Signed-off-by: Matthew Skinner Signed-off-by: Nick Waterton --- .../ipcamera/internal/handler/IpCameraHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java index b96ff172083e3..f88f669094841 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java @@ -252,12 +252,15 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms incomingJpeg = new byte[bytesToRecieve]; } } + } else { + // 401 errors already handled in pipeline by MyNettyAuthHandler.java + return; } } if (msg instanceof HttpContent) { - if (mjpegUri.equals(requestUrl)) { + HttpContent content = (HttpContent) msg; + if (mjpegUri.equals(requestUrl) && !(content instanceof LastHttpContent)) { // multiple MJPEG stream packets come back as this. - HttpContent content = (HttpContent) msg; byte[] chunkedFrame = new byte[content.content().readableBytes()]; content.content().getBytes(content.content().readerIndex(), chunkedFrame); CameraServlet localServlet = servlet; @@ -265,7 +268,6 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms localServlet.openStreams.queueFrame(chunkedFrame); } } else { - HttpContent content = (HttpContent) msg; // Found some cameras use Content-Type: image/jpg instead of image/jpeg if (contentType.contains("image/jp")) { for (int i = 0; i < content.content().capacity(); i++) {