From 33fba05a381db591a7f5874eb242f90065e3458d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 26 十二月 2023 09:52:03 +0800
Subject: [PATCH] Merge pull request #1219 from xiaoQQya/develop
---
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 70 +++++++++++++++++++++++-----------
1 files changed, 47 insertions(+), 23 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 880152f..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
@@ -199,6 +199,13 @@
}
// 鎺ㄦ祦閴存潈鐨勫鐞�
if (!"rtp".equals(param.getApp())) {
+ StreamProxyItem stream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
+ if (stream != null) {
+ HookResultForOnPublish result = HookResultForOnPublish.SUCCESS();
+ result.setEnable_audio(stream.isEnableAudio());
+ result.setEnable_mp4(stream.isEnableMp4());
+ return result;
+ }
if (userSetting.getPushAuthority()) {
// 鎺ㄦ祦閴存潈
if (param.getParams() == null) {
@@ -255,29 +262,40 @@
} else {
result.setEnable_mp4(userSetting.isRecordPushLive());
}
- // 鏇挎崲娴佸湴鍧�
- if ("rtp".equals(param.getApp()) && !mediaInfo.isRtpEnable()) {
- String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));;
- InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
- if (inviteInfo != null) {
- result.setStream_replace(inviteInfo.getStream());
- logger.info("[ZLM HOOK]鎺ㄦ祦閴存潈 stream: {} 鏇挎崲涓� {}", param.getStream(), inviteInfo.getStream());
+
+ // 鍥芥爣娴�
+ if ("rtp".equals(param.getApp()) ) {
+
+ InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream());
+
+ // 鍗曠鍙fā寮忎笅淇敼娴� ID
+ 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());
+ }
+ }
+
+ // 璁剧疆闊抽淇℃伅鍙婂綍鍒朵俊鎭�
+ List<SsrcTransaction> ssrcTransactionForAll = (inviteInfo == null ? null :
+ sessionManager.getSsrcTransactionForAll(inviteInfo.getDeviceId(), inviteInfo.getChannelId(), null, null));
+ if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
+ String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
+ String channelId = ssrcTransactionForAll.get(0).getChannelId();
+ DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
+ if (deviceChannel != null) {
+ result.setEnable_audio(deviceChannel.isHasAudio());
+ }
+ // 濡傛灉鏄綍鍍忎笅杞藉氨璁剧疆瑙嗛闂撮殧鍗佺
+ if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
+ result.setMp4_max_second(10);
+ result.setEnable_mp4(true);
+ }
}
}
- List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, param.getStream());
- if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
- String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
- String channelId = ssrcTransactionForAll.get(0).getChannelId();
- DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
- if (deviceChannel != null) {
- result.setEnable_audio(deviceChannel.isHasAudio());
- }
- // 濡傛灉鏄綍鍍忎笅杞藉氨璁剧疆瑙嗛闂撮殧鍗佺
- if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
- result.setMp4_max_second(10);
- result.setEnable_mp4(true);
- }
- }
+
if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) {
logger.info("鎺ㄦ祦鏃跺彂鐜板皻鏈缃綍鍍忚矾寰勶紝浠巃ssist鏈嶅姟涓鍙�");
JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null);
@@ -517,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(),
@@ -586,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;
}
@@ -609,7 +631,9 @@
result.onTimeout(() -> {
logger.info("[ZLM HOOK] 棰勮娴佽嚜鍔ㄧ偣鎾�, 绛夊緟瓒呮椂");
msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "鐐规挱瓒呮椂"));
- resultHolder.invokeResult(msg);
+ resultHolder.invokeAllResult(msg);
+ inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
+ storager.stopPlay(deviceId, channelId);
});
resultHolder.put(key, uuid, result);
--
Gitblit v1.8.0