[ipcamera] Fix for Instar and HLS. (#9766)
Signed-off-by: Matthew Skinner <matt@pcmus.com>pull/9819/head
parent
0a9c5a0b2c
commit
ec1a91c6d7
|
@ -51,7 +51,6 @@ public class Ffmpeg {
|
|||
private List<String> commandArrayList = new ArrayList<String>();
|
||||
private IpCameraFfmpegThread ipCameraFfmpegThread = new IpCameraFfmpegThread();
|
||||
private int keepAlive = 8;
|
||||
private boolean running = false;
|
||||
private String password;
|
||||
|
||||
public Ffmpeg(IpCameraHandler handle, FFmpegFormat format, String ffmpegLocation, String inputArguments,
|
||||
|
@ -85,10 +84,14 @@ public class Ffmpeg {
|
|||
}
|
||||
|
||||
public void checkKeepAlive() {
|
||||
if (keepAlive <= -1) {
|
||||
return;
|
||||
} else if (--keepAlive == 0) {
|
||||
if (keepAlive == 1) {
|
||||
stopConverting();
|
||||
} else if (keepAlive <= -1 && !getIsAlive()) {
|
||||
logger.warn("HLS stream was not running, restarting it now.");
|
||||
startConverting();
|
||||
}
|
||||
if (keepAlive > 0) {
|
||||
keepAlive--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +175,6 @@ public class Ffmpeg {
|
|||
ipCameraFfmpegThread = new IpCameraFfmpegThread();
|
||||
logger.debug("Starting ffmpeg with this command now:{}", ffmpegCommand.replaceAll(password, "********"));
|
||||
ipCameraFfmpegThread.start();
|
||||
running = true;
|
||||
if (format.equals(FFmpegFormat.HLS)) {
|
||||
ipCameraHandler.setChannelState(CHANNEL_START_STREAM, OnOffType.ON);
|
||||
}
|
||||
|
@ -183,7 +185,11 @@ public class Ffmpeg {
|
|||
}
|
||||
|
||||
public boolean getIsAlive() {
|
||||
return running;
|
||||
Process localProcess = process;
|
||||
if (localProcess != null) {
|
||||
return localProcess.isAlive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void stopConverting() {
|
||||
|
@ -192,18 +198,10 @@ public class Ffmpeg {
|
|||
Process localProcess = process;
|
||||
if (localProcess != null) {
|
||||
localProcess.destroyForcibly();
|
||||
running = false;
|
||||
}
|
||||
if (format.equals(FFmpegFormat.HLS)) {
|
||||
if (keepAlive == -1) {
|
||||
logger.warn("HLS stopped when Stream should be running non stop, restarting HLS now.");
|
||||
startConverting();
|
||||
return;
|
||||
} else {
|
||||
ipCameraHandler.setChannelState(CHANNEL_START_STREAM, OnOffType.OFF);
|
||||
}
|
||||
ipCameraHandler.setChannelState(CHANNEL_START_STREAM, OnOffType.OFF);
|
||||
}
|
||||
keepAlive = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,18 +123,6 @@ public class InstarHandler extends ChannelDuplexHandler {
|
|||
// This handles the commands that come from the Openhab event bus.
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
if (command instanceof RefreshType) {
|
||||
switch (channelUID.getId()) {
|
||||
case CHANNEL_MOTION_ALARM:
|
||||
if (ipCameraHandler.cameraConfig.getServerPort() > 0) {
|
||||
ipCameraHandler.logger.info("Setting up the Alarm Server settings in the camera now");
|
||||
ipCameraHandler.sendHttpGET(
|
||||
"/param.cgi?cmd=setmdalarm&-aname=server2&-switch=on&-interval=1&cmd=setalarmserverattr&-as_index=3&-as_server="
|
||||
+ ipCameraHandler.hostIp + "&-as_port="
|
||||
+ ipCameraHandler.cameraConfig.getServerPort()
|
||||
+ "&-as_path=/instar&-as_queryattr1=&-as_queryval1=&-as_queryattr2=&-as_queryval2=&-as_queryattr3=&-as_queryval3=&-as_activequery=1&-as_auth=0&-as_query1=0&-as_query2=0&-as_query3=0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} // end of "REFRESH"
|
||||
switch (channelUID.getId()) {
|
||||
|
|
|
@ -692,6 +692,13 @@ public class IpCameraHandler extends BaseThingHandler {
|
|||
} catch (Exception e) {
|
||||
cameraConfigError("Exception when starting server. Try changing the Server Port to another number.");
|
||||
}
|
||||
if (thing.getThingTypeUID().getId().equals(INSTAR_THING)) {
|
||||
logger.debug("Setting up the Alarm Server settings in the camera now");
|
||||
sendHttpGET(
|
||||
"/param.cgi?cmd=setmdalarm&-aname=server2&-switch=on&-interval=1&cmd=setalarmserverattr&-as_index=3&-as_server="
|
||||
+ hostIp + "&-as_port=" + cameraConfig.getServerPort()
|
||||
+ "&-as_path=/instar&-as_queryattr1=&-as_queryval1=&-as_queryattr2=&-as_queryval2=&-as_queryattr3=&-as_queryval3=&-as_activequery=1&-as_auth=0&-as_query1=0&-as_query2=0&-as_query3=0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue