From e94cb6da040c03cbb33d96c0fb438c76bc20c6ac Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期一, 14 八月 2023 17:11:45 +0800
Subject: [PATCH] 优化拉流列表和协议
---
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java | 48 +++++++++++++++++++++++++++---------------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
index e493271..9852e1d 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
+++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
@@ -22,6 +22,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -106,7 +108,7 @@
} else {
mediaInfo.setSource(rtspPath);
}
-
+ mediaInfo.setSourceprotocol("udp");
mediaClient.addPath(name, mediaInfo);
return rtspUrl;
}
@@ -305,12 +307,13 @@
info.setRtspSource(item.getConf().getSource());
}
//浼犺緭鍗忚
- regex = "-rtsp_transport\\s+(\\w+)";
- pattern = Pattern.compile(regex);
- matcher = pattern.matcher(runoninit);
- if (matcher.find()) {
- info.setProtocol(matcher.group(1));
- }
+// regex = "-rtsp_transport\\s+(\\w+)";
+// pattern = Pattern.compile(regex);
+// matcher = pattern.matcher(runoninit);
+// if (matcher.find()) {
+// info.setProtocol(matcher.group(1));
+// }
+ info.setProtocol(item.getConf().getSourceprotocol());
//鎷夋祦鏁伴噺
List<Readers> readers = item.getReaders();
info.setNum(readers.size());
@@ -328,15 +331,15 @@
JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class);
List<Items> items = jsonsRoot.getItems();
for (Items item : items) {
- StreamInfo info = new StreamInfo();
- //ID
- String name = item.getName();
- info.setName(name);
- //RTSP鎾斁鍦板潃
- String rtspUrl = "rtsp://" + mediamtxHost + ":8554/" + name;
- info.setRtspUrl(rtspUrl);
List<Readers> readers = item.getReaders();
for (Readers reader : readers) {
+ StreamInfo info = new StreamInfo();
+ //ID
+ String name = item.getName();
+ info.setName(name);
+ //RTSP鎾斁鍦板潃
+ String rtspUrl = "rtsp://" + mediamtxHost + ":8554/" + name;
+ info.setRtspUrl(rtspUrl);
RtspSession rtspSession = getRtspSessionById(reader.getId());
//浼氳瘽ID
info.setId(rtspSession.getId());
@@ -352,18 +355,21 @@
info.setDownTraffic(formatSentSize);
//浼犺緭鍗忚
- String runoninit = item.getConf().getRunondemand();
- String regex = "-rtsp_transport\\s+(\\w+)";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(runoninit);
- if (matcher.find()) {
- info.setProtocol(matcher.group(1));
- }
+// String runoninit = item.getConf().getRunondemand();
+// String regex = "-rtsp_transport\\s+(\\w+)";
+// Pattern pattern = Pattern.compile(regex);
+// Matcher matcher = pattern.matcher(runoninit);
+// if (matcher.find()) {
+// info.setProtocol(matcher.group(1));
+// }
+ info.setProtocol(item.getConf().getSourceprotocol());
//鎷夋祦鏈嶅姟鍣�
info.setRemoteAddr(rtspSession.getRemoteAddr());
PullStreamInfoList.add(info);
}
}
+ Comparator<StreamInfo> comparator = Comparator.comparing(streamInfo ->streamInfo.getBeginTime() ); // 浣跨敤Collections.sort鏂规硶杩涜鎺掑簭 Collections.sort(personList, comparator);
+ Collections.sort(PullStreamInfoList, comparator.reversed());
return PullStreamInfoList;
}
--
Gitblit v1.9.3