From aac3b819f2228192d918c419488a1dbc315443cc Mon Sep 17 00:00:00 2001 From: Administrator <1144154118@qq.com> Date: 星期三, 16 八月 2023 14:26:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- 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