liusuyi
2025-11-08 66e30a35e50ab9cff023b57a0d06924c200b7cc2
ard-vtdu/src/main/java/com/ard/vtdu/service/impl/ArdArdMediaServiceImpl.java
@@ -63,11 +63,11 @@
            conf.setMaxReaders(100);
            conf.setSourceProtocol("tcp");
            if (!checkNameExist(ardVtdu.getName())) {
                mediaClient.addPath(ardVtdu.getName(), conf);
            } else {
                mediaClient.editPath(ardVtdu.getName(), conf);
            if (checkNameExist(ardVtdu.getName())) {
                mediaClient.removePath(ardVtdu.getName());
            }
            mediaClient.addPath(ardVtdu.getName(), conf);
            ardVtdu.setCameraId(ardVtdu.getName().split("_")[0]);
            ardVtdu.setRtspUrl(rtspUrl);
            ardVtdu.setRtmpUrl(rtmpUrl);
@@ -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);
@@ -393,7 +365,7 @@
                nameList.add(item.getName());
            }
        } catch (Exception ex) {
            log.error("获取流媒体name列表异常:" + ex.getMessage());
            log.error("获取流媒体name列表异常:{}", ex.getMessage());
        }
        return nameList;
    }