优化ssrc释放逻辑,优化级联点播速度,去除等待流格式的配置项

This commit is contained in:
648540858
2022-03-07 01:17:45 +08:00
parent 9d37b411ec
commit b2c953fc76
37 changed files with 555 additions and 207 deletions

View File

@@ -489,7 +489,7 @@ public class ZLMHttpHookListener {
}
String mediaServerId = json.getString("mediaServerId");
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (userSetup.isAutoApplyPlay() && mediaInfo != null) {
if (userSetup.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) {
String app = json.getString("app");
String streamId = json.getString("stream");
if ("rtp".equals(app)) {
@@ -499,28 +499,16 @@ public class ZLMHttpHookListener {
String channelId = s[1];
Device device = redisCatchStorage.getDevice(deviceId);
if (device != null) {
UUID uuid = UUID.randomUUID();
SSRCInfo ssrcInfo;
String streamId2 = null;
if (mediaInfo.isRtpEnable()) {
streamId2 = String.format("%s_%s", device.getDeviceId(), channelId);
}
ssrcInfo = mediaServerService.openRTPServer(mediaInfo, streamId2);
cmder.playStreamCmd(mediaInfo, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
logger.info("收到订阅消息: " + response.toJSONString());
playService.onPublishHandlerForPlay(mediaServerItemInuse, response, deviceId, channelId, uuid.toString());
}, null);
playService.play(mediaInfo,deviceId, channelId, null, null, null);
}
}
}
}
JSONObject ret = new JSONObject();
ret.put("code", 0);
ret.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
}
/**

View File

@@ -205,7 +205,7 @@ public class ZLMRTPServerFactory {
/**
* 调用zlm RESTful API —— startSendRtp
*/
public Boolean startSendRtpStream(MediaServerItem mediaServerItem, Map<String, Object>param) {
public JSONObject startSendRtpStream(MediaServerItem mediaServerItem, Map<String, Object>param) {
Boolean result = false;
JSONObject jsonObject = zlmresTfulUtils.startSendRtp(mediaServerItem, param);
if (jsonObject == null) {
@@ -216,7 +216,7 @@ public class ZLMRTPServerFactory {
} else {
logger.error("RTP推流失败: " + jsonObject.getString("msg"));
}
return result;
return jsonObject;
}
/**

View File

@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.media.zlm.event;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import org.slf4j.Logger;
@@ -34,6 +35,9 @@ public class ZLMStatusEventListener {
@Autowired
private IMediaServerService mediaServerService;
@Autowired
private IPlayService playService;
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Async
@@ -55,6 +59,6 @@ public class ZLMStatusEventListener {
mediaServerService.zlmServerOffline(event.getMediaServerId());
streamProxyService.zlmServerOffline(event.getMediaServerId());
streamPushService.zlmServerOffline(event.getMediaServerId());
// TODO 处理对国标的影响
playService.zlmServerOffline(event.getMediaServerId());
}
}