Browse Source

优化单端口下的ssrc修复

pull/484/head
648540858 3 years ago
parent
commit
d202291aa8
  1. 27
      src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

27
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@ -90,6 +90,9 @@ public class PlayServiceImpl implements IPlayService {
@Autowired @Autowired
private DynamicTask dynamicTask; private DynamicTask dynamicTask;
@Autowired
private ZLMHttpHookSubscribe subscribe;
@ -259,6 +262,7 @@ public class PlayServiceImpl implements IPlayService {
} }
}, userSetting.getPlayTimeout()*1000); }, userSetting.getPlayTimeout()*1000);
final String ssrc = ssrcInfo.getSsrc(); final String ssrc = ssrcInfo.getSsrc();
final String stream = ssrcInfo.getStream();
cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
logger.info("收到订阅消息: " + response.toJSONString()); logger.info("收到订阅消息: " + response.toJSONString());
dynamicTask.stop(timeOutTaskKey); dynamicTask.stop(timeOutTaskKey);
@ -278,6 +282,7 @@ public class PlayServiceImpl implements IPlayService {
if (ssrc.equals(ssrcInResponse)) { if (ssrc.equals(ssrcInResponse)) {
return; return;
} }
logger.info("[SIP 消息] 收到invite 200, 发现下级自定义了ssrc 开启修正");
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) { if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) {
// ssrc 不可用 // ssrc 不可用
@ -289,10 +294,32 @@ public class PlayServiceImpl implements IPlayService {
errorEvent.response(event); errorEvent.response(event);
return; return;
} }
// 单端口模式streamId也有变化,需要重新设置监听
if (!mediaServerItem.isRtpEnable()) {
// 添加订阅
JSONObject subscribeKey = new JSONObject();
subscribeKey.put("app", "rtp");
subscribeKey.put("stream", stream);
subscribeKey.put("regist", true);
subscribeKey.put("schema", "rtmp");
subscribeKey.put("mediaServerId", mediaServerItem.getId());
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed,subscribeKey);
subscribeKey.put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase());
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
(MediaServerItem mediaServerItemInUse, JSONObject response)->{
logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString());
dynamicTask.stop(timeOutTaskKey);
// hook响应
onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid);
hookEvent.response(mediaServerItemInUse, response);
});
}
// 关闭rtp server // 关闭rtp server
mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
// 重新开启ssrc server // 重新开启ssrc server
mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false); mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false);
} }
} }
}, (event) -> { }, (event) -> {

Loading…
Cancel
Save