增加RPC录像列表查询

This commit is contained in:
648540858
2024-12-13 14:35:44 +08:00
parent 152a4954aa
commit 3e78af64de
25 changed files with 409 additions and 204 deletions

View File

@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service.redisMsg;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
public interface IRedisRpcPlayService {
@@ -13,5 +14,8 @@ public interface IRedisRpcPlayService {
void playback(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<StreamInfo> callback);
void download(String serverId, Integer id, String startTime, String endTime, int downloadSpeed, ErrorCallback<StreamInfo> callback);
void download(String serverId, Integer channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<StreamInfo> callback);
void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<RecordInfo> callback);
}

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.InviteInfo;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
@@ -17,6 +18,7 @@ import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -60,14 +62,14 @@ public class RedisRpcChannelPlayController extends RpcController {
RedisRpcResponse response = request.getResponse();
if (channelId <= 0) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
// 获取对应的设备和通道信息
CommonGBChannel channel = channelService.getOne(channelId);
if (channel == null) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
@@ -76,7 +78,7 @@ public class RedisRpcChannelPlayController extends RpcController {
inviteInfo.setSessionName("Play");
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
if (code == InviteErrorCode.SUCCESS.getCode()) {
response.setStatusCode(Response.OK);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
response.setBody(data);
}else {
response.setStatusCode(code);
@@ -88,6 +90,50 @@ public class RedisRpcChannelPlayController extends RpcController {
}
/**
* 点播国标设备
*/
@RedisRpcMapping("queryRecordInfo")
public RedisRpcResponse queryRecordInfo(RedisRpcRequest request) {
JSONObject paramJson = JSONObject.parseObject(request.getParam().toString());
int channelId = paramJson.getIntValue("channelId");
String startTime = paramJson.getString("startTime");
String endTime = paramJson.getString("endTime");
RedisRpcResponse response = request.getResponse();
if (channelId <= 0) {
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
// 获取对应的设备和通道信息
CommonGBChannel channel = channelService.getOne(channelId);
if (channel == null) {
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
try {
channelService.queryRecordInfo(channel, startTime, endTime, (code, msg, data) ->{
if (code == InviteErrorCode.SUCCESS.getCode()) {
response.setStatusCode(ErrorCode.SUCCESS.getCode());
response.setBody(data);
}else {
response.setStatusCode(code);
}
// 手动发送结果
sendResponse(response);
});
}catch (ControllerException e) {
response.setStatusCode(ErrorCode.ERROR100.getCode());
response.setBody(e.getMessage());
}
return null;
}
/**
* 停止点播国标设备
*/
@@ -99,7 +145,7 @@ public class RedisRpcChannelPlayController extends RpcController {
Integer channelId = jsonObject.getIntValue("channelId");
if (channelId == null || channelId <= 0) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
@@ -110,13 +156,13 @@ public class RedisRpcChannelPlayController extends RpcController {
// 获取对应的设备和通道信息
CommonGBChannel channel = channelService.getOne(channelId);
if (channel == null) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
try {
channelPlayService.stopPlay(type, channel, stream);
response.setStatusCode(Response.OK);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
}catch (Exception e){
response.setStatusCode(Response.SERVER_INTERNAL_ERROR);
response.setBody(e.getMessage());
@@ -136,14 +182,14 @@ public class RedisRpcChannelPlayController extends RpcController {
RedisRpcResponse response = request.getResponse();
if (channelId <= 0) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
// 获取对应的设备和通道信息
CommonGBChannel channel = channelService.getOne(channelId);
if (channel == null) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
@@ -154,7 +200,7 @@ public class RedisRpcChannelPlayController extends RpcController {
inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime));
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
if (code == InviteErrorCode.SUCCESS.getCode()) {
response.setStatusCode(Response.OK);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
response.setBody(data);
}else {
response.setStatusCode(code);
@@ -178,14 +224,14 @@ public class RedisRpcChannelPlayController extends RpcController {
RedisRpcResponse response = request.getResponse();
if (channelId <= 0) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
// 获取对应的设备和通道信息
CommonGBChannel channel = channelService.getOne(channelId);
if (channel == null) {
response.setStatusCode(Response.BAD_REQUEST);
response.setStatusCode(ErrorCode.ERROR400.getCode());
response.setBody("param error");
return response;
}
@@ -197,7 +243,7 @@ public class RedisRpcChannelPlayController extends RpcController {
inviteInfo.setDownloadSpeed(downloadSpeed + "");
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
if (code == InviteErrorCode.SUCCESS.getCode()) {
response.setStatusCode(Response.OK);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
response.setBody(data);
}else {
response.setStatusCode(code);

View File

@@ -49,7 +49,7 @@ public class RedisRpcSendRtpController extends RpcController {
if (sendRtpItem == null) {
log.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息 callId{}", callId);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
return response;
}
log.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort());
@@ -57,14 +57,14 @@ public class RedisRpcSendRtpController extends RpcController {
MediaServer mediaServerItem = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream());
if (mediaServerItem == null) {
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
}
// 自平台内容
int localPort = sendRtpServerService.getNextPort(mediaServerItem);
if (localPort == 0) {
log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" );
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
}
// 写入redis 超时时回复
sendRtpItem.setStatus(1);
@@ -77,7 +77,7 @@ public class RedisRpcSendRtpController extends RpcController {
}
sendRtpServerService.update(sendRtpItem);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
response.setBody(callId);
return response;
}
@@ -90,7 +90,7 @@ public class RedisRpcSendRtpController extends RpcController {
String callId = request.getParam().toString();
SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
if (sendRtpItem == null) {
log.info("[redis-rpc] 开始发流, 未找到redis中的发流信息 callId{}", callId);
WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息");
@@ -134,7 +134,7 @@ public class RedisRpcSendRtpController extends RpcController {
String callId = request.getParam().toString();
SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(Response.OK);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
if (sendRtpItem == null) {
log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息 key{}", callId);
WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息");

View File

@@ -18,6 +18,7 @@ import com.genersoft.iot.vmp.service.ISendRtpServerService;
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@@ -79,7 +80,7 @@ public class RedisRpcStreamPushController extends RpcController {
sendRtpServerService.update(sendRtpItem);
RedisRpcResponse response = request.getResponse();
response.setBody(sendRtpItem.getChannelId());
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
}
// 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者
Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null);
@@ -98,7 +99,7 @@ public class RedisRpcStreamPushController extends RpcController {
redisTemplate.opsForValue().set(sendRtpItem.getChannelId(), sendRtpItem);
RedisRpcResponse response = request.getResponse();
response.setBody(sendRtpItem.getChannelId());
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
// 手动发送结果
sendResponse(response);
hookSubscribe.removeSubscribe(hook);
@@ -120,7 +121,7 @@ public class RedisRpcStreamPushController extends RpcController {
log.info("[redis-rpc] 监听流上线时发现流已存在直接返回: {}/{}", streamInfo.getApp(), streamInfo.getStream());
RedisRpcResponse response = request.getResponse();
response.setBody(JSONObject.toJSONString(streamInfoInServer));
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
return response;
}
// 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者
@@ -133,7 +134,7 @@ public class RedisRpcStreamPushController extends RpcController {
streamInfo.getApp(), streamInfo.getStream(), hookData.getMediaInfo(),
hookData.getMediaInfo() != null ? hookData.getMediaInfo().getCallId() : null);
response.setBody(JSONObject.toJSONString(streamInfoByAppAndStream));
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
// 手动发送结果
sendResponse(response);
hookSubscribe.removeSubscribe(hook);
@@ -152,7 +153,7 @@ public class RedisRpcStreamPushController extends RpcController {
Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null);
hookSubscribe.removeSubscribe(hook);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
return response;
}
@@ -167,7 +168,7 @@ public class RedisRpcStreamPushController extends RpcController {
Hook hook = Hook.getInstance(HookType.on_media_arrival, streamInfo.getApp(), streamInfo.getStream(), null);
hookSubscribe.removeSubscribe(hook);
RedisRpcResponse response = request.getResponse();
response.setStatusCode(200);
response.setStatusCode(ErrorCode.SUCCESS.getCode());
return response;
}

View File

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService;
@@ -48,7 +49,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
if (response == null) {
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
}else {
if (response.getStatusCode() == Response.OK) {
if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class);
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
}else {
@@ -69,12 +70,33 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
if (response == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg());
}else {
if (response.getStatusCode() != Response.OK) {
if (response.getStatusCode() != ErrorCode.SUCCESS.getCode()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg());
}
}
}
@Override
public void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<RecordInfo> callback) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("channelId", channelId);
jsonObject.put("startTime", startTime);
jsonObject.put("endTime", endTime);
RedisRpcRequest request = buildRequest("channel/queryRecordInfo", jsonObject);
request.setToId(serverId);
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getRecordInfoTimeout(), TimeUnit.MILLISECONDS);
if (response == null) {
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
}else {
if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
RecordInfo recordInfo = JSON.parseObject(response.getBody().toString(), RecordInfo.class);
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), recordInfo);
}else {
callback.run(response.getStatusCode(), response.getBody().toString(), null);
}
}
}
@Override
public void playback(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<StreamInfo> callback) {
@@ -88,7 +110,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
if (response == null) {
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
}else {
if (response.getStatusCode() == Response.OK) {
if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class);
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
}else {
@@ -111,7 +133,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
if (response == null) {
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
}else {
if (response.getStatusCode() == Response.OK) {
if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class);
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
}else {