| | |
| | | package com.ruoyi.media.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.media.domain.*; |
| | | import com.ruoyi.media.service.IMediaService; |
| | | import com.ruoyi.utils.forest.MediaClient; |
| | | import com.ruoyi.utils.tools.ArdTool; |
| | | import io.minio.messages.Item; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Items> paths() { |
| | | public List<StreamInfo> paths() { |
| | | String apiUrl = "http://" + mediamtxHost + ":9997/v2"; |
| | | String list = mediaClient.paths(apiUrl); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | return jsonsRoot.getItems(); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | List<StreamInfo> pathInfoList = new ArrayList<>(); |
| | | for (Items item : items) { |
| | | StreamInfo info = new StreamInfo(); |
| | | //ID |
| | | String name = item.getName(); |
| | | info.setName(name); |
| | | String runoninit=""; |
| | | String runondemand = item.getConf().getRunondemand(); |
| | | if (StringUtils.isNotEmpty(runondemand)) |
| | | { |
| | | runoninit= item.getConf().getRunondemand(); |
| | | } |
| | | else |
| | | { |
| | | runoninit = item.getConf().getRunoninit(); |
| | | } |
| | | //RTSP源地址 |
| | | runoninit = item.getConf().getRunondemand(); |
| | | String regex = "rtsp://[^\\s\"]+"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Matcher matcher = pattern.matcher(runoninit); |
| | | if (matcher.find()) { |
| | | info.setRtspSource(matcher.group()); |
| | | } |
| | | //传输协议 |
| | | regex = "-rtsp_transport\\s+(\\w+)"; |
| | | pattern = Pattern.compile(regex); |
| | | matcher = pattern.matcher(runoninit); |
| | | if (matcher.find()) { |
| | | info.setProtocol(matcher.group(1)); |
| | | } |
| | | |
| | | pathInfoList.add(info); |
| | | } |
| | | return pathInfoList; |
| | | } |
| | | |
| | | @Override |