Browse Source

查询流地址时mediaServerId改为可选

pull/243/head
648540858 3 years ago
parent
commit
0199676a6d
  1. 2
      src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
  2. 5
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
  3. 10
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
  4. 3
      src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java
  5. 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java

2
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java

@ -61,4 +61,6 @@ public interface IMediaServerService {
boolean checkMediaRecordServer(String ip, int port);
void delete(String id);
MediaServerItem getDefaultMediaServer();
}

5
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@ -241,6 +241,11 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
return mediaServerMapper.queryOneByHostAndPort(host, port);
}
@Override
public MediaServerItem getDefaultMediaServer() {
return mediaServerMapper.queryDefault();
}
@Override
public void clearMediaServerForOnline() {
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX;

10
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java

@ -38,7 +38,13 @@ public class MediaServiceImpl implements IMediaService {
@Override
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, String addr) {
StreamInfo streamInfo = null;
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
MediaServerItem mediaInfo;
if (mediaServerId == null) {
mediaInfo = mediaServerService.getDefaultMediaServer();
}else {
mediaInfo = mediaServerService.getOne(mediaServerId);
}
if (mediaInfo == null) {
return streamInfo;
}
@ -55,6 +61,8 @@ public class MediaServiceImpl implements IMediaService {
return streamInfo;
}
@Override
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId) {
return getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, null);

3
src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java

@ -105,4 +105,7 @@ public interface MediaServerMapper {
@Select("SELECT * FROM media_server WHERE ip='${host}' and httpPort=${port}")
MediaServerItem queryOneByHostAndPort(String host, int port);
@Select("SELECT * FROM media_server WHERE defaultServer=1")
MediaServerItem queryDefault();
}

4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java

@ -44,11 +44,11 @@ public class MediaController {
@ApiImplicitParams({
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class),
@ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class),
@ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class, required = false),
})
@GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam String mediaServerId){
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam(required = false) String mediaServerId){
StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfoByAppAndStreamWithCheck != null){

Loading…
Cancel
Save