查询流地址时mediaServerId改为可选

pull/243/head
648540858 2021-11-22 17:29:16 +08:00
parent 692348c395
commit 0199676a6d
5 changed files with 21 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -44,11 +44,11 @@ public class MediaController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class), @ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流id", 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") @GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody @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); StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
WVPResult<StreamInfo> result = new WVPResult<>(); WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfoByAppAndStreamWithCheck != null){ if (streamInfoByAppAndStreamWithCheck != null){