优化sip消息,去除自动dialog创建
This commit is contained in:
@@ -103,7 +103,7 @@ public class ZLMHttpHookListener {
|
||||
@PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
||||
public JSONObject onServerKeepalive(@RequestBody JSONObject json){
|
||||
|
||||
logger.info("[ ZLM HOOK ] on_server_keepalive API调用,参数:" + json.toString());
|
||||
logger.info("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString());
|
||||
String mediaServerId = json.getString("mediaServerId");
|
||||
List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
|
||||
if (subscribes != null && subscribes.size() > 0) {
|
||||
@@ -453,6 +453,7 @@ public class ZLMHttpHookListener {
|
||||
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
||||
// 如果正在给上级推送,则发送bye
|
||||
|
||||
|
||||
}else{
|
||||
streamInfo = redisCatchStorage.queryPlayback(null, null, stream, null);
|
||||
if (streamInfo != null) {
|
||||
@@ -509,6 +510,19 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!regist) {
|
||||
List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(stream);
|
||||
if (sendRtpItems.size() > 0) {
|
||||
for (SendRtpItem sendRtpItem : sendRtpItems) {
|
||||
if (sendRtpItem.getApp().equals(app)) {
|
||||
String platformId = sendRtpItem.getPlatformId();
|
||||
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
|
||||
|
||||
commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject ret = new JSONObject();
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -83,7 +84,11 @@ public class ZLMMediaListManager {
|
||||
}
|
||||
if (transform != null) {
|
||||
if (getChannelOnlineEventLister(transform.getApp(), transform.getStream()) != null) {
|
||||
getChannelOnlineEventLister(transform.getApp(), transform.getStream()).run(transform.getApp(), transform.getStream(), transform.getServerId());
|
||||
try {
|
||||
getChannelOnlineEventLister(transform.getApp(), transform.getStream()).run(transform.getApp(), transform.getStream(), transform.getServerId());
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
removedChannelOnlineEventLister(transform.getApp(), transform.getStream());
|
||||
}
|
||||
}
|
||||
@@ -95,7 +100,11 @@ public class ZLMMediaListManager {
|
||||
// 查看推流状态
|
||||
if (zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream)) {
|
||||
if (getChannelOnlineEventLister(app, stream) != null) {
|
||||
getChannelOnlineEventLister(app, stream).run(app, stream, mediaServerId);
|
||||
try {
|
||||
getChannelOnlineEventLister(app, stream).run(app, stream, mediaServerId);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
removedChannelOnlineEventLister(app, stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,12 +330,12 @@ public class ZLMRTPServerFactory {
|
||||
Boolean result = false;
|
||||
JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaServerItem, param);
|
||||
if (jsonObject == null) {
|
||||
logger.error("停止RTP推流失败: 请检查ZLM服务");
|
||||
logger.error("[停止RTP推流] 失败: 请检查ZLM服务");
|
||||
} else if (jsonObject.getInteger("code") == 0) {
|
||||
result= true;
|
||||
logger.info("停止RTP推流成功");
|
||||
logger.info("[停止RTP推流] 成功");
|
||||
} else {
|
||||
logger.error("停止RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param));
|
||||
logger.error("[停止RTP推流] 失败: {}, 参数:{}->\r\n{}",jsonObject.getString("msg"),JSONObject.toJSON(param), jsonObject);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -137,8 +137,6 @@ public class ZlmHttpHookSubscribe {
|
||||
@Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次
|
||||
public void execute(){
|
||||
|
||||
logger.info("[hook订阅] 清理");
|
||||
|
||||
Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5));
|
||||
int total = 0;
|
||||
for (HookType hookType : allSubscribes.keySet()) {
|
||||
@@ -153,6 +151,5 @@ public class ZlmHttpHookSubscribe {
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("[hook订阅] 清理结束,共清理{}条过期数据", total);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
*/
|
||||
public interface ChannelOnlineEvent {
|
||||
|
||||
void run(String app, String stream, String serverId);
|
||||
void run(String app, String stream, String serverId) throws ParseException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user