From 964d55431f4b2d064c756b4e6a5c845d3539dc3f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期一, 18 十二月 2023 14:43:04 +0800 Subject: [PATCH] 修复推流无声音的问题 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index ab2d338..55ab609 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -244,6 +244,7 @@ HookResultForOnPublish result = HookResultForOnPublish.SUCCESS(); + result.setEnable_audio(true); taskExecutor.execute(() -> { ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); if (subscribe != null) { @@ -263,14 +264,18 @@ } // 鍥芥爣娴� - if ("rtp".equals(param.getApp())) { - String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16)); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc); + if ("rtp".equals(param.getApp()) ) { + + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); // 鍗曠鍙fā寮忎笅淇敼娴� ID - if (!mediaInfo.isRtpEnable() && inviteInfo != null) { - result.setStream_replace(inviteInfo.getStream()); - logger.info("[ZLM HOOK]鎺ㄦ祦閴存潈 stream: {} 鏇挎崲涓� {}", param.getStream(), inviteInfo.getStream()); + if (!mediaInfo.isRtpEnable() && inviteInfo == null) { + String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16)); + inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc); + if (inviteInfo != null) { + result.setStream_replace(inviteInfo.getStream()); + logger.info("[ZLM HOOK]鎺ㄦ祦閴存潈 stream: {} 鏇挎崲涓� {}", param.getStream(), inviteInfo.getStream()); + } } // 璁剧疆闊抽淇℃伅鍙婂綍鍒朵俊鎭� @@ -530,11 +535,15 @@ if (info != null) { cmder.streamByeCmd(device, inviteInfo.getChannelId(), inviteInfo.getStream(), null); + }else { + logger.info("[鏃犱汉瑙傜湅] 鏈壘鍒拌澶囩殑鐐规挱淇℃伅锛� {}锛� 娴侊細{}", inviteInfo.getDeviceId(), param.getStream()); } } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { logger.error("[鏃犱汉瑙傜湅]鐐规挱锛� 鍙戦�丅YE澶辫触 {}", e.getMessage()); } + }else { + logger.info("[鏃犱汉瑙傜湅] 鏈壘鍒拌澶囷細 {}锛屾祦锛歿}", inviteInfo.getDeviceId(), param.getStream()); } inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), @@ -599,7 +608,7 @@ String deviceId = s[0]; String channelId = s[1]; Device device = redisCatchStorage.getDevice(deviceId); - if (device == null) { + if (device == null || !device.isOnLine()) { defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg())); return defaultResult; } -- Gitblit v1.8.0