修复zlm上线时过期任务设置错误
This commit is contained in:
parent
508b3aa44f
commit
5f2d4393c3
@ -282,7 +282,7 @@ public class ZLMHttpHookListener {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
||||||
public HookResult onStreamChanged(@RequestBody OnStreamChangedHookParam param) {
|
public HookResult onStreamChanged(@RequestBody OnStreamChangedHookParam param) {
|
||||||
|
System.out.println(JSON.toJSONString(param));
|
||||||
if (param.isRegist()) {
|
if (param.isRegist()) {
|
||||||
logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||||
} else {
|
} else {
|
||||||
@ -304,13 +304,11 @@ public class ZLMHttpHookListener {
|
|||||||
|
|
||||||
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
||||||
// TODO 重构此处逻辑
|
// TODO 重构此处逻辑
|
||||||
boolean isPush = false;
|
|
||||||
if (param.isRegist()) {
|
if (param.isRegist()) {
|
||||||
// 处理流注册的鉴权信息
|
// 处理流注册的鉴权信息
|
||||||
if (param.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
if (param.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
||||||
|| param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
|| param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
||||||
|| param.getOriginType() == OriginType.RTC_PUSH.ordinal()) {
|
|| param.getOriginType() == OriginType.RTC_PUSH.ordinal()) {
|
||||||
isPush = true;
|
|
||||||
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
|
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
|
||||||
if (streamAuthorityInfo == null) {
|
if (streamAuthorityInfo == null) {
|
||||||
streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
|
streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
|
||||||
@ -324,7 +322,7 @@ public class ZLMHttpHookListener {
|
|||||||
redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream());
|
redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("rtsp".equals(param.getSchema())) {
|
if ("rtmp".equals(param.getSchema())) {
|
||||||
// 更新流媒体负载信息
|
// 更新流媒体负载信息
|
||||||
if (param.isRegist()) {
|
if (param.isRegist()) {
|
||||||
mediaServerService.addCount(param.getMediaServerId());
|
mediaServerService.addCount(param.getMediaServerId());
|
||||||
@ -363,6 +361,8 @@ public class ZLMHttpHookListener {
|
|||||||
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
||||||
param.getApp(), param.getStream(), tracks, callId);
|
param.getApp(), param.getStream(), tracks, callId);
|
||||||
param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
||||||
|
// 如果是拉流代理产生的,不需要写入推流
|
||||||
|
|
||||||
redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
||||||
if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
||||||
|| param.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
|| param.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
||||||
|
@ -409,7 +409,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|||||||
}
|
}
|
||||||
final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId();
|
final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId();
|
||||||
dynamicTask.stop(zlmKeepaliveKey);
|
dynamicTask.stop(zlmKeepaliveKey);
|
||||||
dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (Math.getExponent(serverItem.getHookAliveInterval()) + 5) * 1000);
|
dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (serverItem.getHookAliveInterval().intValue() + 5) * 1000);
|
||||||
publisher.zlmOnlineEventPublish(serverItem.getId());
|
publisher.zlmOnlineEventPublish(serverItem.getId());
|
||||||
|
|
||||||
logger.info("[ZLM] 连接成功 {} - {}:{} ",
|
logger.info("[ZLM] 连接成功 {} - {}:{} ",
|
||||||
|
Loading…
Reference in New Issue
Block a user