| | |
| | | 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; |
| | |
| | | } else { |
| | | mediaInfo.setSource(rtspPath); |
| | | } |
| | | |
| | | mediaInfo.setSourceprotocol("udp"); |
| | | mediaClient.addPath(name, mediaInfo); |
| | | return rtspUrl; |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | 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; |
| | | } |
| | | |