zhaowenyu
2025-11-12 0f5b969ddd52ca43ef003867b5a6749d74b7d71d
ard-vtdu/src/main/java/com/ard/vtdu/service/impl/ArdArdMediaServiceImpl.java
@@ -196,6 +196,8 @@
            String name = item.getName();
            info.setName(name);
            Conf conf = mediaClient.getPathConfig(name);
            //源
            info.setRtspSource(conf.getSource());
            //RTMP播放地址
            String rtmpUrl = "rtmp://" + mediamtxConfig.getPlayHost() + ":1935/" + name;
            info.setRtmpUrl(rtmpUrl);
@@ -206,51 +208,21 @@
            String protocol = mediamtxConfig.isHttps() ? "https://" : "http://";
            String webrtcUrl = protocol + mediamtxConfig.getPlayHost() + ":8889/" + name;
            info.setWebrtcUrl(webrtcUrl);
            Source source = item.getSource();
            if (source == null || source.getId().equals("")) {
                //会话ID
                info.setId("0");
                //下行流量
                long bytesReceived = item.getBytesReceived();
                String formatReceivedSize = ArdTool.formatFileSize(bytesReceived);
                info.setDownTraffic(formatReceivedSize);
                //上行流量
                long bytesSent = item.getBytesSent();
                String formatSentdSize = ArdTool.formatFileSize(bytesSent);
                info.setUpTraffic(formatSentdSize);
                info.setBeginTime(item.getReadyTime());
            } else {
                RtspSession rtspSession = getRtspSessionById(source.getId());
                //会话ID
                info.setId(rtspSession.getId());
                //开始推流时间
                info.setBeginTime(rtspSession.getCreated());
                //上行流量
                long bytesReceived = rtspSession.getBytesReceived();
                String formatReceivedSize = ArdTool.formatFileSize(bytesReceived);
                info.setUpTraffic(formatReceivedSize);
                //下行流量
                long bytesSent = rtspSession.getBytesSent();
                String formatSentSize = ArdTool.formatFileSize(bytesSent);
                info.setDownTraffic(formatSentSize);
                //推流服务器
                info.setRemoteAddr(rtspSession.getRemoteAddr());
            }
            //RTSP源地址
            String runOn = "";
            if (StringUtils.isNotEmpty(conf.getRunOnDemand())) {
                runOn = conf.getRunOnDemand();
            }
            Matcher matcher = Pattern.compile("rtsp://[^\\s\"]+").matcher(runOn);
            if (matcher.find()) {
                info.setRtspSource(matcher.group());
            } else {
                info.setRtspSource(conf.getSource());
            }
            //上行流量
            long bytesReceived = item.getBytesReceived();
            String formatReceivedSize = ArdTool.formatFileSize(bytesReceived);
            info.setUpTraffic(formatReceivedSize);
            //下行流量
            long bytesSent = item.getBytesSent();
            String formatSentSize = ArdTool.formatFileSize(bytesSent);
            info.setDownTraffic(formatSentSize);
            //传输协议
            info.setProtocol(conf.getSourceProtocol());
            //拉流数量
            List<Readers> readers = item.getReaders();
            //开始时间
            info.setBeginTime(item.getReadyTime());
            info.setNum(readers.size());
            PushStreamInfoList.add(info);