优化对讲逻辑

This commit is contained in:
648540858
2022-07-03 16:23:31 +08:00
parent e78c402a24
commit 7609d7836c
4 changed files with 16 additions and 10 deletions

View File

@@ -830,7 +830,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
subscribeKey.put("app", app);
subscribeKey.put("stream", stream);
subscribeKey.put("regist", true);
subscribeKey.put("schema", "rtmp");
subscribeKey.put("schema", "rtsp");
subscribeKey.put("mediaServerId", mediaServerItem.getId());
String finalSsrc = ssrc;
// 流已经存在时直接推流

View File

@@ -339,9 +339,7 @@ public class ZLMHttpHookListener {
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ]on_stream_changed API调用参数" + JSONObject.toJSONString(item));
}
logger.info("[ ZLM HOOK ]on_stream_changed API调用参数" + JSONObject.toJSONString(item));
String mediaServerId = item.getMediaServerId();
JSONObject json = (JSONObject) JSON.toJSON(item);
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json);

View File

@@ -689,6 +689,9 @@ public class PlayServiceImpl implements IPlayService {
logger.warn("语音广播已经开启: {}", channelId);
event.call("语音广播已经开启");
return;
}else {
audioBroadcastManager.del(deviceChannel.getDeviceId(),channelId);
redisCatchStorage.deleteSendRTPServer(device.getDeviceId(), channelId, sendRtpItem.getCallId(), sendRtpItem.getStreamId());
}
}
}
@@ -710,7 +713,7 @@ public class PlayServiceImpl implements IPlayService {
public void stopAudioBroadcast(String deviceId, String channelId){
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
if (audioBroadcastCatch != null) {
audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId());
try {
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
if (sendRtpItem != null) {
@@ -722,11 +725,12 @@ public class PlayServiceImpl implements IPlayService {
param.put("stream", sendRtpItem.getStreamId());
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
// 立刻结束设备的推流,等待自行结束太慢
// zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
}
if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null);
}
audioBroadcastManager.del(deviceId, channelId);
} catch (SipException e) {
throw new RuntimeException(e);