优化播放中zlm离线判断

This commit is contained in:
648540858 2022-06-15 15:06:22 +08:00
parent 3bf7ee18e0
commit 642407505b
2 changed files with 4 additions and 5 deletions

View File

@ -283,10 +283,10 @@ public class ZLMRTPServerFactory {
*/
public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) {
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId);
Integer code = mediaInfo.getInteger("code");
if (mediaInfo == null) {
return 0;
}
Integer code = mediaInfo.getInteger("code");
if ( code < 0) {
logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg"));
return -1;

View File

@ -61,13 +61,12 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
// 发起http请求验证zlm是否确实无法连接如果确实无法连接则发送离线事件否则不作处理
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
if (mediaServerConfig == null || mediaServerConfig.getInteger("code") == -2) {
publisher.zlmOfflineEventPublish(mediaServerId);
}else {
if (mediaServerConfig != null && mediaServerConfig.getInteger("code") == 0) {
logger.info("[zlm心跳到期]{}验证后zlm仍在线恢复心跳信息", mediaServerId);
// 添加zlm信息
mediaServerService.updateMediaServerKeepalive(mediaServerId, mediaServerConfig);
}
}else {
publisher.zlmOfflineEventPublish(mediaServerId);
}
}
}