将检测任务迁移python
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 媒体服务,支持全局网络超时、读写超时、无人拉流持续时长自动关闭流等配置
|
||||
@@ -25,6 +26,16 @@ public class MediaService {
|
||||
* 缓存流转换线程
|
||||
*/
|
||||
public static ConcurrentHashMap<String, MediaTransfer> cameras = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 客户端类型映射
|
||||
*/
|
||||
public static ConcurrentHashMap<String, ClientType> clients = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 客户端连接映射
|
||||
*/
|
||||
public static ConcurrentHashMap<String, Map<String, ChannelHandlerContext>> clientConnections = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* http-flv播放
|
||||
@@ -253,4 +264,34 @@ public class MediaService {
|
||||
}
|
||||
cameras.remove(mediaKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备对应的媒体传输器
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @return 媒体传输器实例,如果不存在则返回null
|
||||
*/
|
||||
public MediaTransferFlvByJavacv getMediaTransfer(Long deviceId) {
|
||||
if (deviceId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 遍历所有已注册的相机
|
||||
for (Map.Entry<String, MediaTransfer> entry : cameras.entrySet()) {
|
||||
String mediaKey = entry.getKey();
|
||||
if (mediaKey.startsWith("device_" + deviceId + "_")) {
|
||||
// 找到匹配设备ID的mediaKey
|
||||
MediaTransfer mediaTransfer = entry.getValue();
|
||||
if (mediaTransfer instanceof MediaTransferFlvByJavacv) {
|
||||
MediaTransferFlvByJavacv transfer = (MediaTransferFlvByJavacv) mediaTransfer;
|
||||
if (transfer.getCameraDto() != null &&
|
||||
mediaKey.equals(transfer.getCameraDto().getMediaKey())) {
|
||||
return transfer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user