增加RPC录像回放和录像下载

This commit is contained in:
648540858
2024-12-12 17:46:51 +08:00
parent 4f6e6b8e8e
commit 93afd46d0f
8 changed files with 167 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ import lombok.Data;
// 从INVITE消息中解析需要的信息
@Data
public class InviteInfo {
public class InviteMessageInfo {
private String requesterId;
private String targetChannelId;
private String sourceChannelId;

View File

@@ -3,13 +3,13 @@ package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.InviteInfo;
import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
public interface IGbChannelPlayService {
void start(CommonGBChannel channel, InviteInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback);
void start(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback);
void stopPlay(InviteSessionType type, CommonGBChannel channel, String stream);

View File

@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.InviteInfo;
import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.PlayException;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
@@ -33,7 +33,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
@Override
public void start(CommonGBChannel channel, InviteInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback) {
public void start(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback) {
if (channel == null || inviteInfo == null || callback == null) {
log.warn("[通用通道点播] 参数异常, channel: {}, inviteInfo: {}, callback: {}", channel != null, inviteInfo != null, callback != null);
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");

View File

@@ -295,14 +295,14 @@ public class PlayServiceImpl implements IPlayService {
// 判断设备是否属于当前平台, 如果不属于则发起自动调用
if (!userSetting.getServerId().equals(device.getServerId())) {
redisRpcPlayService.play(device.getServerId(), channel.getId(), callback);
}else {
MediaServer mediaServerItem = getNewMediaServerItem(device);
if (mediaServerItem == null) {
log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
}
play(mediaServerItem, device, channel, null, callback);
return;
}
MediaServer mediaServerItem = getNewMediaServerItem(device);
if (mediaServerItem == null) {
log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
}
play(mediaServerItem, device, channel, null, callback);
}
@Override
@@ -746,6 +746,11 @@ public class PlayServiceImpl implements IPlayService {
if (channel == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道不存在");
}
if (!userSetting.getServerId().equals(device.getServerId())) {
redisRpcPlayService.playback(device.getServerId(), channel.getId(), startTime, endTime, callback);
return;
}
MediaServer newMediaServerItem = getNewMediaServerItem(device);
if (newMediaServerItem == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的节点");
@@ -954,6 +959,11 @@ public class PlayServiceImpl implements IPlayService {
@Override
public void download(Device device, DeviceChannel channel, String startTime, String endTime, int downloadSpeed, ErrorCallback<StreamInfo> callback) {
if (!userSetting.getServerId().equals(device.getServerId())) {
redisRpcPlayService.download(device.getServerId(), channel.getId(), startTime, endTime, downloadSpeed, callback);
return;
}
MediaServer newMediaServerItem = this.getNewMediaServerItem(device);
if (newMediaServerItem == null) {
callback.run(InviteErrorCode.ERROR_FOR_ASSIST_NOT_READY.getCode(),

View File

@@ -121,7 +121,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
SIPRequest request = (SIPRequest)evt.getRequest();
try {
InviteInfo inviteInfo = decode(evt);
InviteMessageInfo inviteInfo = decode(evt);
// 查询请求是否来自上级平台\设备
Platform platform = platformService.queryPlatformByServerGBId(inviteInfo.getRequesterId());
@@ -247,9 +247,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}
}
private InviteInfo decode(RequestEvent evt) throws SdpException {
private InviteMessageInfo decode(RequestEvent evt) throws SdpException {
InviteInfo inviteInfo = new InviteInfo();
InviteMessageInfo inviteInfo = new InviteMessageInfo();
SIPRequest request = (SIPRequest)evt.getRequest();
String[] channelIdArrayFromSub = SipUtils.getChannelIdFromRequest(request);
@@ -349,7 +349,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}
private String createSendSdp(SendRtpInfo sendRtpItem, InviteInfo inviteInfo, String sdpIp) {
private String createSendSdp(SendRtpInfo sendRtpItem, InviteMessageInfo inviteInfo, String sdpIp) {
StringBuilder content = new StringBuilder(200);
content.append("v=0\r\n");
content.append("o=" + inviteInfo.getTargetChannelId() + " 0 0 IN IP4 " + sdpIp + "\r\n");
@@ -393,7 +393,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}
}
public void inviteFromDeviceHandle(SIPRequest request, InviteInfo inviteInfo) {
public void inviteFromDeviceHandle(SIPRequest request, InviteMessageInfo inviteInfo) {
if (inviteInfo.getSourceChannelId() == null) {
log.warn("来自设备的Invite请求无法从请求信息中确定请求来自的通道已忽略requesterId {}", inviteInfo.getRequesterId());