优化登录体验。修复因为流地址导致的录像服务无法识别

This commit is contained in:
648540858
2021-08-31 09:44:19 +08:00
parent 792c93694d
commit 3578c1c040
9 changed files with 38 additions and 9 deletions

View File

@@ -30,6 +30,9 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", "-1");
jsonObject.put("msg", "请登录后重新请求");
if (request.getRequestURI().contains("api/user/login")){
jsonObject.put("msg", e.getMessage());
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
try {
response.getWriter().print(jsonObject.toJSONString());

View File

@@ -376,7 +376,7 @@ public class ZLMHttpHookListener {
String app = json.getString("app");
String streamId = json.getString("stream");
if ("rtp".equals(app)) {
String[] s = streamId.split("/");
String[] s = streamId.split("_");
if (s.length == 2) {
String deviceId = s[0];
String channelId = s[1];
@@ -386,7 +386,7 @@ public class ZLMHttpHookListener {
SSRCInfo ssrcInfo;
String streamId2 = null;
if (mediaInfo.isRtpEnable()) {
streamId2 = String.format("%s/%s", device.getDeviceId(), channelId);
streamId2 = String.format("%s_%s", device.getDeviceId(), channelId);
}
ssrcInfo = mediaServerService.openRTPServer(mediaInfo, streamId2);
cmder.playStreamCmd(mediaInfo, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {

View File

@@ -122,7 +122,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
String mediaServerId = streamSession.getMediaServerId(device.getDeviceId(), channelId);
MediaServerItem mediaServerItem = this.getOne(mediaServerId);
if (mediaServerItem != null) {
String streamId = String.format("%s/%s", device.getDeviceId(), channelId);
String streamId = String.format("%s_%s", device.getDeviceId(), channelId);
zlmrtpServerFactory.closeRTPServer(mediaServerItem, streamId);
releaseSsrc(mediaServerItem, streamSession.getSSRC(device.getDeviceId(), channelId));
}

View File

@@ -155,7 +155,7 @@ public class PlayServiceImpl implements IPlayService {
SSRCInfo ssrcInfo;
String streamId = null;
if (mediaServerItem.isRtpEnable()) {
streamId = String.format("%s/%s", device.getDeviceId(), channelId);
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
}
ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId);
@@ -220,7 +220,7 @@ public class PlayServiceImpl implements IPlayService {
SSRCInfo ssrcInfo;
String streamId2 = null;
if (mediaServerItem.isRtpEnable()) {
streamId2 = String.format("%s/%s", device.getDeviceId(), channelId);
streamId2 = String.format("%s_%s", device.getDeviceId(), channelId);
}
ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId2);

View File

@@ -101,7 +101,7 @@ public class PlayController {
@GetMapping("/stop/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String deviceId, @PathVariable String channelId) {
logger.debug(String.format("设备预览/回放停止API调用streamId%s/%s", deviceId, channelId ));
logger.debug(String.format("设备预览/回放停止API调用streamId%s_%s", deviceId, channelId ));
UUID uuid = UUID.randomUUID();
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>();
@@ -147,7 +147,7 @@ public class PlayController {
// 超时处理
result.onTimeout(()->{
logger.warn(String.format("设备预览/回放停止超时deviceId/channelId%s/%s ", deviceId, channelId));
logger.warn(String.format("设备预览/回放停止超时deviceId/channelId%s_%s ", deviceId, channelId));
RequestMessage msg = new RequestMessage();
msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid);
msg.setData("Timeout");

View File

@@ -130,7 +130,7 @@ public class DownloadController {
cmder.streamByeCmd(deviceId, channelId);
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备历史媒体下载停止 API调用deviceId/channelId%s/%s", deviceId, channelId));
logger.debug(String.format("设备历史媒体下载停止 API调用deviceId/channelId%s_%s", deviceId, channelId));
}
if (deviceId != null && channelId != null) {