[ipcamera] Handle empty snapshotUrls and XML encoded characters (#15707)
* [ipcamera] Handle empty snapshotUrls and XML encoded characters * use unescape method from StringUtils --------- Signed-off-by: Kai Kreuzer <kai@openhab.org>pull/15780/head
parent
b92f1a241a
commit
9a85fca6cb
|
@ -40,6 +40,7 @@ import org.openhab.binding.ipcamera.internal.handler.IpCameraHandler;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.types.StateOption;
|
import org.openhab.core.types.StateOption;
|
||||||
|
import org.openhab.core.util.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ import io.netty.handler.timeout.IdleStateHandler;
|
||||||
* The {@link OnvifConnection} This is a basic Netty implementation for connecting and communicating to ONVIF cameras.
|
* The {@link OnvifConnection} This is a basic Netty implementation for connecting and communicating to ONVIF cameras.
|
||||||
*
|
*
|
||||||
* @author Matthew Skinner - Initial contribution
|
* @author Matthew Skinner - Initial contribution
|
||||||
|
* @author Kai Kreuzer - Improve handling for certain cameras
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
|
@ -358,17 +360,23 @@ public class OnvifConnection {
|
||||||
} else if (message.contains("GetDeviceInformationResponse")) {
|
} else if (message.contains("GetDeviceInformationResponse")) {
|
||||||
logger.debug("GetDeviceInformationResponse received");
|
logger.debug("GetDeviceInformationResponse received");
|
||||||
} else if (message.contains("GetSnapshotUriResponse")) {
|
} else if (message.contains("GetSnapshotUriResponse")) {
|
||||||
snapshotUri = removeIPfromUrl(Helper.fetchXML(message, ":MediaUri", ":Uri"));
|
String url = Helper.fetchXML(message, ":MediaUri", ":Uri");
|
||||||
logger.debug("GetSnapshotUri:{}", snapshotUri);
|
if (!url.isBlank()) {
|
||||||
if (ipCameraHandler.snapshotUri.isEmpty()
|
snapshotUri = removeIPfromUrl(url);
|
||||||
&& !"ffmpeg".equals(ipCameraHandler.cameraConfig.getSnapshotUrl())) {
|
logger.debug("GetSnapshotUri: {}", snapshotUri);
|
||||||
ipCameraHandler.snapshotUri = snapshotUri;
|
if (ipCameraHandler.snapshotUri.isEmpty()
|
||||||
|
&& !"ffmpeg".equals(ipCameraHandler.cameraConfig.getSnapshotUrl())) {
|
||||||
|
ipCameraHandler.snapshotUri = snapshotUri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (message.contains("GetStreamUriResponse")) {
|
} else if (message.contains("GetStreamUriResponse")) {
|
||||||
rtspUri = Helper.fetchXML(message, ":MediaUri", ":Uri>");
|
String xml = StringUtils.unEscapeXml(Helper.fetchXML(message, ":MediaUri", ":Uri>"));
|
||||||
logger.debug("GetStreamUri:{}", rtspUri);
|
if (xml != null) {
|
||||||
if (ipCameraHandler.cameraConfig.getFfmpegInput().isEmpty()) {
|
rtspUri = xml;
|
||||||
ipCameraHandler.rtspUri = rtspUri;
|
logger.debug("GetStreamUri: {}", rtspUri);
|
||||||
|
if (ipCameraHandler.cameraConfig.getFfmpegInput().isEmpty()) {
|
||||||
|
ipCameraHandler.rtspUri = rtspUri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,7 +572,6 @@ public class OnvifConnection {
|
||||||
}
|
}
|
||||||
if (!mainEventLoopGroup.isShuttingDown()) {
|
if (!mainEventLoopGroup.isShuttingDown()) {
|
||||||
localBootstap.connect(new InetSocketAddress(ipAddress, onvifPort)).addListener(new ChannelFutureListener() {
|
localBootstap.connect(new InetSocketAddress(ipAddress, onvifPort)).addListener(new ChannelFutureListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(@Nullable ChannelFuture future) {
|
public void operationComplete(@Nullable ChannelFuture future) {
|
||||||
if (future == null) {
|
if (future == null) {
|
||||||
|
|
Loading…
Reference in New Issue