| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | return jsonsRoot.getItems(); |
| | | } |
| | | |
| | | @Override |
| | | public RtspSession getRtspSessionById(String sessionId) { |
| | | String apiUrl="http://"+mediamtxHost+":9997/v2"; |
| | | String list = mediaClient.getRtspsessionById(apiUrl,sessionId); |
| | | RtspSession rtspSession = JSONObject.parseObject(list, RtspSession.class); |
| | | return rtspSession; |
| | | } |
| | | |
| | | @Override |
| | | public List<RtspSession> getPushStreams() { |
| | | List<RtspSession> rtspSessions=new ArrayList<>(); |
| | | String apiUrl="http://"+mediamtxHost+":9997/v2"; |
| | | String list = mediaClient.paths(apiUrl); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | for(Items item:items) |
| | | { |
| | | Source source = item.getSource(); |
| | | RtspSession rtspSession = getRtspSessionById(source.getId()); |
| | | rtspSession.setCameraId(item.getName()); |
| | | rtspSessions.add(rtspSession); |
| | | } |
| | | return rtspSessions; |
| | | } |
| | | |
| | | @Override |
| | | public List<RtspSession> getPullStreams() { |
| | | List<RtspSession> rtspSessions=new ArrayList<>(); |
| | | String apiUrl="http://"+mediamtxHost+":9997/v2"; |
| | | String list = mediaClient.paths(apiUrl); |
| | | JsonsRoot jsonsRoot = JSONObject.parseObject(list, JsonsRoot.class); |
| | | List<Items> items = jsonsRoot.getItems(); |
| | | for(Items item:items) |
| | | { |
| | | List<Readers> readers = item.getReaders(); |
| | | for(Readers reader:readers) { |
| | | RtspSession rtspSession = getRtspSessionById(reader.getId()); |
| | | rtspSession.setCameraId(item.getName()); |
| | | rtspSessions.add(rtspSession); |
| | | } |
| | | } |
| | | return rtspSessions; |
| | | } |
| | | } |