支持设置abl配置信息
parent
999192fa8a
commit
3e02e496f6
|
@ -141,7 +141,6 @@ public class ABLMediaServerStatusManger {
|
|||
if (data == null || data.isEmpty()) {
|
||||
logger.info("[ABL-尝试连接]失败, ID:{}, 地址: {}:{}", mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
}else {
|
||||
// ablServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), AblServerConfig.class);
|
||||
ablServerConfig = AblServerConfig.getInstance(data);
|
||||
initPort(mediaServerItem, ablServerConfig);
|
||||
online(mediaServerItem, ablServerConfig);
|
||||
|
@ -166,7 +165,6 @@ public class ABLMediaServerStatusManger {
|
|||
logger.info("[ABL-尝试连接]失败, ID:{}, 地址: {}:{}", mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
offlineAblTimeMap.put(mediaServerItem.getId(), System.currentTimeMillis());
|
||||
}else {
|
||||
// ablServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
|
||||
ablServerConfig = AblServerConfig.getInstance(data);
|
||||
initPort(mediaServerItem, ablServerConfig);
|
||||
online(mediaServerItem, ablServerConfig);
|
||||
|
@ -189,13 +187,12 @@ public class ABLMediaServerStatusManger {
|
|||
JSONObject responseJSON = ablResTfulUtils.getServerConfig(mediaServerItem);
|
||||
JSONArray data = responseJSON.getJSONArray("params");
|
||||
if (data != null && !data.isEmpty()) {
|
||||
// config = JSON.parseObject(JSON.toJSONString(data.get(0)), AblServerConfig.class);
|
||||
config = AblServerConfig.getInstance(data);
|
||||
}
|
||||
}
|
||||
if (config != null) {
|
||||
initPort(mediaServerItem, config);
|
||||
setAblConfig(mediaServerItem, false);
|
||||
setAblConfig(mediaServerItem, false, config);
|
||||
}
|
||||
}
|
||||
mediaServerService.update(mediaServerItem);
|
||||
|
@ -234,69 +231,73 @@ public class ABLMediaServerStatusManger {
|
|||
mediaServerItem.setHookAliveInterval(10F);
|
||||
}
|
||||
|
||||
public void setAblConfig(MediaServer mediaServerItem, boolean restart) {
|
||||
// logger.info("[媒体服务节点] 正在设置 :{} -> {}:{}",
|
||||
// mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
// String protocol = sslEnabled ? "https" : "http";
|
||||
// String hookPrefix = String.format("%s://%s:%s/index/hook", protocol, mediaServerItem.getHookIp(), serverPort);
|
||||
//
|
||||
// Map<String, Object> param = new HashMap<>();
|
||||
// param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
|
||||
// if (mediaServerItem.getRtspPort() != 0) {
|
||||
// param.put("ffmpeg.snap", "%s -rtsp_transport tcp -i %s -y -f mjpeg -frames:v 1 %s");
|
||||
// }
|
||||
// param.put("hook.enable","1");
|
||||
// param.put("hook.on_flow_report","");
|
||||
// param.put("hook.on_play",String.format("%s/on_play", hookPrefix));
|
||||
// param.put("hook.on_http_access","");
|
||||
// param.put("hook.on_publish", String.format("%s/on_publish", hookPrefix));
|
||||
// param.put("hook.on_record_ts","");
|
||||
// param.put("hook.on_rtsp_auth","");
|
||||
// param.put("hook.on_rtsp_realm","");
|
||||
// param.put("hook.on_server_started",String.format("%s/on_server_started", hookPrefix));
|
||||
// param.put("hook.on_shell_login","");
|
||||
// param.put("hook.on_stream_changed",String.format("%s/on_stream_changed", hookPrefix));
|
||||
// param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrefix));
|
||||
// param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrefix));
|
||||
// param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrefix));
|
||||
// param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrefix));
|
||||
// param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrefix));
|
||||
// param.put("hook.on_record_mp4",String.format("%s/on_record_mp4", hookPrefix));
|
||||
// param.put("hook.timeoutSec","30");
|
||||
// param.put("hook.alive_interval", mediaServerItem.getHookAliveInterval());
|
||||
// // 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。
|
||||
// // 置0关闭此特性(推流断开会导致立即断开播放器)
|
||||
// // 此参数不应大于播放器超时时间
|
||||
// // 优化此消息以更快的收到流注销事件
|
||||
// param.put("protocol.continue_push_ms", "3000" );
|
||||
// // 最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流,
|
||||
// // 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项
|
||||
// if (mediaServerItem.isRtpEnable() && !ObjectUtils.isEmpty(mediaServerItem.getRtpPortRange())) {
|
||||
// param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-"));
|
||||
// }
|
||||
//
|
||||
// if (!ObjectUtils.isEmpty(mediaServerItem.getRecordPath())) {
|
||||
// File recordPathFile = new File(mediaServerItem.getRecordPath());
|
||||
// param.put("protocol.mp4_save_path", recordPathFile.getParentFile().getPath());
|
||||
// param.put("protocol.downloadRoot", recordPathFile.getParentFile().getPath());
|
||||
// param.put("record.appName", recordPathFile.getName());
|
||||
// }
|
||||
//
|
||||
// JSONObject responseJSON = ablResTfulUtils.setServerConfig(mediaServerItem, param);
|
||||
//
|
||||
// if (responseJSON != null && responseJSON.getInteger("code") == 0) {
|
||||
// if (restart) {
|
||||
// logger.info("[媒体服务节点] 设置成功,开始重启以保证配置生效 {} -> {}:{}",
|
||||
// mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
// ablResTfulUtils.restartServer(mediaServerItem);
|
||||
// }else {
|
||||
// logger.info("[媒体服务节点] 设置成功 {} -> {}:{}",
|
||||
// mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
// }
|
||||
// }else {
|
||||
// logger.info("[媒体服务节点] 设置媒体服务节点失败 {} -> {}:{}",
|
||||
// mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
// }
|
||||
public void setAblConfig(MediaServer mediaServerItem, boolean restart, AblServerConfig config) {
|
||||
if (config.getHookEnable() == 0) {
|
||||
logger.info("[媒体服务节点-ABL] 开启HOOK功能 :{}", mediaServerItem.getId());
|
||||
JSONObject responseJSON = ablResTfulUtils.setConfigParamValue(mediaServerItem, "hook_enable", "1");
|
||||
}
|
||||
logger.info("[媒体服务节点] 正在设置 :{} -> {}:{}",
|
||||
mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
String protocol = sslEnabled ? "https" : "http";
|
||||
String hookPrefix = String.format("%s://%s:%s/index/hook/abl", protocol, mediaServerItem.getHookIp(), serverPort);
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
|
||||
if (mediaServerItem.getRtspPort() != 0) {
|
||||
param.put("ffmpeg.snap", "%s -rtsp_transport tcp -i %s -y -f mjpeg -frames:v 1 %s");
|
||||
}
|
||||
param.put("hook.enable","1");
|
||||
param.put("hook.on_flow_report","");
|
||||
param.put("hook.on_play",String.format("%s/on_play", hookPrefix));
|
||||
param.put("hook.on_http_access","");
|
||||
param.put("hook.on_publish", String.format("%s/on_publish", hookPrefix));
|
||||
param.put("hook.on_record_ts","");
|
||||
param.put("hook.on_rtsp_auth","");
|
||||
param.put("hook.on_rtsp_realm","");
|
||||
param.put("hook.on_server_started",String.format("%s/on_server_started", hookPrefix));
|
||||
param.put("hook.on_shell_login","");
|
||||
param.put("hook.on_stream_changed",String.format("%s/on_stream_changed", hookPrefix));
|
||||
param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrefix));
|
||||
param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrefix));
|
||||
param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrefix));
|
||||
param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrefix));
|
||||
param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrefix));
|
||||
param.put("hook.on_record_mp4",String.format("%s/on_record_mp4", hookPrefix));
|
||||
param.put("hook.timeoutSec","30");
|
||||
param.put("hook.alive_interval", mediaServerItem.getHookAliveInterval());
|
||||
// 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。
|
||||
// 置0关闭此特性(推流断开会导致立即断开播放器)
|
||||
// 此参数不应大于播放器超时时间
|
||||
// 优化此消息以更快的收到流注销事件
|
||||
param.put("protocol.continue_push_ms", "3000" );
|
||||
// 最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流,
|
||||
// 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项
|
||||
if (mediaServerItem.isRtpEnable() && !ObjectUtils.isEmpty(mediaServerItem.getRtpPortRange())) {
|
||||
param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-"));
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(mediaServerItem.getRecordPath())) {
|
||||
File recordPathFile = new File(mediaServerItem.getRecordPath());
|
||||
param.put("protocol.mp4_save_path", recordPathFile.getParentFile().getPath());
|
||||
param.put("protocol.downloadRoot", recordPathFile.getParentFile().getPath());
|
||||
param.put("record.appName", recordPathFile.getName());
|
||||
}
|
||||
|
||||
JSONObject responseJSON = ablResTfulUtils.setConfigParamValue(mediaServerItem, param);
|
||||
|
||||
if (responseJSON != null && responseJSON.getInteger("code") == 0) {
|
||||
if (restart) {
|
||||
logger.info("[媒体服务节点] 设置成功,开始重启以保证配置生效 {} -> {}:{}",
|
||||
mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
ablResTfulUtils.restartServer(mediaServerItem);
|
||||
}else {
|
||||
logger.info("[媒体服务节点] 设置成功 {} -> {}:{}",
|
||||
mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
}
|
||||
}else {
|
||||
logger.info("[媒体服务节点] 设置媒体服务节点失败 {} -> {}:{}",
|
||||
mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -285,8 +285,8 @@ public class ABLRESTfulUtils {
|
|||
return sendPost(mediaServerItem, "getServerConfig",null, null);
|
||||
}
|
||||
|
||||
public JSONObject setServerConfig(MediaServer mediaServerItem, Map<String, Object> param){
|
||||
return sendPost(mediaServerItem,"setServerConfig",param, null);
|
||||
public JSONObject setConfigParamValue(MediaServer mediaServerItem, String key, Object value){
|
||||
return sendPost(mediaServerItem,"setConfigParamValue", param, null);
|
||||
}
|
||||
|
||||
public JSONObject openRtpServer(MediaServer mediaServerItem, Map<String, Object> param){
|
||||
|
|
|
@ -126,6 +126,9 @@ public class AblServerConfig {
|
|||
@ConfigKeyId("on_stream_disconnect")
|
||||
private String onStreamDisconnect;
|
||||
|
||||
@ConfigKeyId("on_record_mp4")
|
||||
private String onRecordMp4;
|
||||
|
||||
@ConfigKeyId("on_delete_record_mp4")
|
||||
private String onDeleteRecordMp4;
|
||||
|
||||
|
@ -144,6 +147,9 @@ public class AblServerConfig {
|
|||
@ConfigKeyId("captureReplayType")
|
||||
private Integer captureReplayType;
|
||||
|
||||
@ConfigKeyId("pictureMaxCount")
|
||||
private Integer pictureMaxCount;
|
||||
|
||||
@ConfigKeyId("videoFileFormat")
|
||||
private Integer videoFileFormat;
|
||||
|
||||
|
@ -776,4 +782,20 @@ public class AblServerConfig {
|
|||
public void setRtcMaxPort(Integer rtcMaxPort) {
|
||||
this.rtcMaxPort = rtcMaxPort;
|
||||
}
|
||||
|
||||
public String getOnRecordMp4() {
|
||||
return onRecordMp4;
|
||||
}
|
||||
|
||||
public void setOnRecordMp4(String onRecordMp4) {
|
||||
this.onRecordMp4 = onRecordMp4;
|
||||
}
|
||||
|
||||
public Integer getPictureMaxCount() {
|
||||
return pictureMaxCount;
|
||||
}
|
||||
|
||||
public void setPictureMaxCount(Integer pictureMaxCount) {
|
||||
this.pictureMaxCount = pictureMaxCount;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue