From 6a2ff9951584cb014a8e07703678e0f4d748746d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 17 十月 2022 12:47:02 +0800
Subject: [PATCH] 合并主线

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 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 5194a9a..1298e1f 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -553,7 +553,6 @@
 									if (sendRtpItem == null) {
 										// TODO 鍙兘鏁版嵁閿欒锛岄噸鏂板紑鍚闊抽�氶亾
 									}else {
-										String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
 										MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
 										logger.info("rtp/{}寮�濮嬪悜涓婄骇鎺ㄦ祦, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
 										Map<String, Object> param = new HashMap<>(12);
@@ -570,7 +569,7 @@
 										if (sendRtpItem.isTcpActive()) {
 											jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
 										} else {
-											param.put("is_udp", is_Udp);
+											param.put("is_udp", sendRtpItem.isTcp() ? "0" : "1");
 											param.put("dst_url", sendRtpItem.getIp());
 											param.put("dst_port", sendRtpItem.getPort());
 											jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
@@ -581,8 +580,8 @@
 									}
 								}else {
 									// 寮�鍚闊冲璁查�氶亾
-									MediaServerItem mediaServerForMinimumLoad = mediaServerService.getMediaServerForMinimumLoad();
-									playService.talk(mediaServerForMinimumLoad, device, channelId, (mediaServerItem, jsonObject)->{
+									MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
+									playService.talk(mediaServerItem, device, channelId, (mediaServer, jsonObject)->{
 										System.out.println("寮�濮嬫帹娴�");
 									}, eventResult -> {
 										System.out.println(eventResult.msg);
@@ -644,7 +643,7 @@
 					}
 				}
 			}
-			if (!regist) {
+			if (!regist ) {
 				List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(stream);
 				if (sendRtpItems.size() > 0) {
 					for (SendRtpItem sendRtpItem : sendRtpItems) {
@@ -657,7 +656,7 @@
 								if (platform != null) {
 									commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
 								}else {
-									if (sendRtpItem.isOnlyAudio()) {
+									if ("talk".equals(app) && sendRtpItem.isOnlyAudio()) {
 										AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
 										if (device != null && audioBroadcastCatch != null) {
 //											cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null);
@@ -730,19 +729,24 @@
 				storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
 			}else{
 				StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
-				if (streamInfoForPlayBackCatch != null) {
-					Device device = deviceService.queryDevice(streamInfoForPlayCatch.getDeviceID());
-					if (device != null) {
-						try {
-							cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
-									streamInfoForPlayBackCatch.getStream(), null);
-						} catch (InvalidArgumentException | ParseException | SipException |
-								 SsrcTransactionNotFoundException e) {
-							logger.error("[鏃犱汉瑙傜湅]鍥炴斁锛� 鍙戦�丅YE澶辫触 {}", e.getMessage());
+				if (streamInfoForPlayBackCatch != null ) {
+					if (streamInfoForPlayBackCatch.isPause()) {
+						ret.put("close", false);
+					}else {
+						Device device = deviceService.queryDevice(streamInfoForPlayBackCatch.getDeviceID());
+						if (device != null) {
+							try {
+								cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
+										streamInfoForPlayBackCatch.getStream(), null);
+							} catch (InvalidArgumentException | ParseException | SipException |
+									 SsrcTransactionNotFoundException e) {
+								logger.error("[鏃犱汉瑙傜湅]鍥炴斁锛� 鍙戦�丅YE澶辫触 {}", e.getMessage());
+							}
 						}
+						redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
+								streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
 					}
-					redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
-							streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
+
 				}else {
 					StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
 					// 杩涜褰曞儚涓嬭浇鏃舵棤浜鸿鐪嬩笉鏂祦

--
Gitblit v1.8.0