Merge branch 'master' into dev/录制计划

This commit is contained in:
648540858
2024-11-27 14:20:59 +08:00
15 changed files with 101 additions and 102 deletions

View File

@@ -175,15 +175,18 @@ public class SendRtpInfo {
return sendRtpItem;
}
public static SendRtpInfo getInstance(Integer localPort, MediaServer mediaServer, String ip, int port, String ssrc,
String deviceId, String platformId, Integer channelId, boolean isTcp, boolean rtcp,
public static SendRtpInfo getInstance(Integer localPort, MediaServer mediaServer, String ip, Integer port, String ssrc,
String deviceId, String platformId, Integer channelId, Boolean isTcp, Boolean rtcp,
String serverId) {
if (localPort == 0) {
return null;
}
SendRtpInfo sendRtpItem = new SendRtpInfo();
sendRtpItem.setIp(ip);
sendRtpItem.setPort(port);
if(port != null) {
sendRtpItem.setPort(port);
}
sendRtpItem.setSsrc(ssrc);
if (deviceId != null) {
sendRtpItem.setTargetId(deviceId);

View File

@@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.bean;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.Instant;
/**
* 摄像机同步状态
* @author lin
@@ -23,4 +25,7 @@ public class SyncStatus {
@Schema(description = "是否同步中")
private Boolean syncIng;
@Schema(description = "时间")
private Instant time;
}

View File

@@ -144,9 +144,21 @@ public class DeviceQuery {
Device device = deviceService.getDeviceByDeviceId(deviceId);
boolean status = deviceService.isSyncRunning(deviceId);
// 已存在则返回进度
if (status) {
if (deviceService.isSyncRunning(deviceId)) {
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
return WVPResult.success(channelSyncStatus);
WVPResult wvpResult = new WVPResult();
if (channelSyncStatus.getErrorMsg() != null) {
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(channelSyncStatus.getErrorMsg());
}else if (channelSyncStatus.getTotal() == null || channelSyncStatus.getTotal() == 0){
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg("等待通道信息...");
}else {
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus);
}
return wvpResult;
}
deviceService.sync(device);
@@ -413,18 +425,19 @@ public class DeviceQuery {
public WVPResult<SyncStatus> getSyncStatus(@PathVariable String deviceId) {
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
WVPResult<SyncStatus> wvpResult = new WVPResult<>();
if (channelSyncStatus == null || channelSyncStatus.getTotal() == null) {
wvpResult.setCode(0);
wvpResult.setMsg("同步尚未开始");
if (channelSyncStatus == null) {
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("同步不存在");
}else if (channelSyncStatus.getErrorMsg() != null) {
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(channelSyncStatus.getErrorMsg());
}else if (channelSyncStatus.getTotal() == null || channelSyncStatus.getTotal() == 0){
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg("等待通道信息...");
}else {
if (channelSyncStatus.getErrorMsg() == null) {
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus);
}else {
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(channelSyncStatus.getErrorMsg());
}
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus);
}
return wvpResult;
}

View File

@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.common.CommonCallback;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
@@ -322,7 +323,8 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public void sync(Device device) {
if (catalogResponseMessageHandler.isSyncRunning(device.getDeviceId())) {
log.info("开启同步时发现同步已经存在");
SyncStatus syncStatus = catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId());
log.info("[同步通道] 同步已存在, 设备: {}, 同步信息: {}", device.getDeviceId(), JSON.toJSON(syncStatus));
return;
}
int sn = (int)((Math.random()*9+1)*100000);

View File

@@ -517,7 +517,14 @@ public class PlayServiceImpl implements IPlayService {
}, userSetting.getPlayTimeout());
try {
mediaServerService.startSendRtpPassive(mediaServerItem, sendRtpInfo, userSetting.getPlayTimeout() * 1000);
Integer localPort = mediaServerService.startSendRtpPassive(mediaServerItem, sendRtpInfo, userSetting.getPlayTimeout() * 1000);
if (localPort == null || localPort <= 0) {
timeoutCallback.run();
mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpInfo.getSsrc());
sessionManager.removeByStream(sendRtpInfo.getStream());
return;
}
sendRtpInfo.setPort(localPort);
}catch (ControllerException e) {
mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpInfo.getSsrc());
log.info("[语音对讲]失败 deviceId: {}, channelId: {}", device.getDeviceId(), channel.getDeviceId());

View File

@@ -170,11 +170,16 @@ public class CatalogDataManager implements CommandLineRunner {
syncStatus.setCurrent(catalogData.getRedisKeysForChannel().size());
syncStatus.setTotal(catalogData.getTotal());
syncStatus.setErrorMsg(catalogData.getErrorMsg());
syncStatus.setTime(catalogData.getTime());
if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready) || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) {
syncStatus.setSyncIng(false);
}else {
syncStatus.setSyncIng(true);
}
if (catalogData.getErrorMsg() != null) {
// 失败的同步信息,返回一次后直接移除
dataMap.remove(key);
}
return syncStatus;
}
}
@@ -237,7 +242,8 @@ public class CatalogDataManager implements CommandLineRunner {
catalogData.setErrorMsg(errorMsg);
}
}
if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) && catalogData.getTime().isBefore(instantBefore30S)) { // 超过三十秒如果标记为end则删除
if ((catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready))
&& catalogData.getTime().isBefore(instantBefore30S)) { // 超过三十秒如果标记为end则删除
dataMap.remove(dataKey);
Set<String> redisKeysForChannel = catalogData.getRedisKeysForChannel();
if (redisKeysForChannel != null && !redisKeysForChannel.isEmpty()) {

View File

@@ -303,7 +303,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
Media media = mediaDescription.getMedia();
Vector mediaFormats = media.getMediaFormats(false);
if (mediaFormats.contains("96")) {
if (mediaFormats.contains("96") || mediaFormats.contains("8")) {
port = media.getMediaPort();
//String mediaType = media.getMediaType();
String protocol = media.getProtocol();