新增 Mjpegplayer 用来播放 Web 流
This commit is contained in:
105
SHH.Contracts.Grpc/Dtos/CameraConfigDto.cs
Normal file
105
SHH.Contracts.Grpc/Dtos/CameraConfigDto.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SHH.Contracts
|
||||
{
|
||||
// ==============================================================================
|
||||
// 1. 物理与运行配置 DTO (对应 CRUD 操作)
|
||||
// 用于设备新增/全量配置查询,包含基础身份、连接信息、运行参数等全量字段
|
||||
// ==============================================================================
|
||||
public class CameraConfigDto
|
||||
{
|
||||
// --- 基础身份 (Identity) ---
|
||||
|
||||
/// <summary>设备唯一标识</summary>
|
||||
[Required(ErrorMessage = "设备ID不能为空")]
|
||||
[Range(1, long.MaxValue, ErrorMessage = "设备ID必须为正整数")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>设备友好名称</summary>
|
||||
[MaxLength(64, ErrorMessage = "设备名称长度不能超过64个字符")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>摄像头品牌类型 (0:HikVision, 1:Dahua, 2:RTSP...)</summary>
|
||||
[Range(0, 10, ErrorMessage = "品牌类型值必须在0-10范围内")]
|
||||
public int Brand { get; set; }
|
||||
|
||||
/// <summary>设备安装位置描述</summary>
|
||||
[MaxLength(128, ErrorMessage = "安装位置长度不能超过128个字符")]
|
||||
public string Location { get; set; } = string.Empty;
|
||||
|
||||
// --- 主板关联信息 (Metadata) ---
|
||||
|
||||
/// <summary>关联主板IP地址</summary>
|
||||
[RegularExpression(@"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)?$",
|
||||
ErrorMessage = "请输入合法的IPv4地址")]
|
||||
public string MainboardIp { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>关联主板端口</summary>
|
||||
[Range(0, 65535, ErrorMessage = "主板端口号必须在1-65535范围内")]
|
||||
public int MainboardPort { get; set; } = 0;
|
||||
|
||||
// --- 核心连接 (Connectivity) - 修改此类参数触发冷重启 ---
|
||||
|
||||
/// <summary>摄像头IP地址</summary>
|
||||
[Required(ErrorMessage = "IP地址不能为空")]
|
||||
[RegularExpression(@"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$",
|
||||
ErrorMessage = "请输入合法的IPv4地址")]
|
||||
public string IpAddress { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>登录用户名</summary>
|
||||
[MaxLength(32, ErrorMessage = "用户名长度不能超过32个字符")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>登录密码</summary>
|
||||
[MaxLength(64, ErrorMessage = "密码长度不能超过64个字符")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>SDK端口 (如海康默认8000)</summary>
|
||||
[Range(1, 65535, ErrorMessage = "端口号必须在1-65535范围内")]
|
||||
public ushort Port { get; set; }
|
||||
|
||||
/// <summary>通道号 (通常为1)</summary>
|
||||
[Range(0, 256, ErrorMessage = "通道号必须在0-256范围内")]
|
||||
public int ChannelIndex { get; set; }
|
||||
|
||||
/// <summary>码流类型 (0:主码流, 1:子码流)</summary>
|
||||
[Range(0, 1, ErrorMessage = "码流类型只能是0(主码流)或1(子码流)")]
|
||||
public int StreamType { get; set; }
|
||||
|
||||
/// <summary>渲染句柄 (通常下发时为0,由本地窗口绑定时再指定,或者此处仅作占位)</summary>
|
||||
public long RenderHandle { get; set; }
|
||||
|
||||
/// <summary>RTSP流路径 (备用或非SDK模式使用)</summary>
|
||||
[MaxLength(256, ErrorMessage = "RTSP地址长度不能超过256个字符")]
|
||||
public string RtspPath { get; set; } = string.Empty;
|
||||
|
||||
// --- 运行时参数 (Runtime Options) - 支持热更新 ---
|
||||
|
||||
/// <summary>是否使用灰度图 (用于AI分析场景加速)</summary>
|
||||
public bool UseGrayscale { get; set; } = false;
|
||||
|
||||
/// <summary>是否启用图像增强 (去噪/锐化等)</summary>
|
||||
public bool EnhanceImage { get; set; } = true;
|
||||
|
||||
// --- 画面变换 (Transform) - 支持热更新 ---
|
||||
|
||||
/// <summary>是否允许图像压缩 (降低带宽占用)</summary>
|
||||
public bool AllowCompress { get; set; } = true;
|
||||
|
||||
/// <summary>是否允许图像放大 (提升渲染质量)</summary>
|
||||
public bool AllowExpand { get; set; } = false;
|
||||
|
||||
/// <summary>目标分辨率 (格式如 1920x1080,空则保持原图)</summary>
|
||||
[RegularExpression(@"^\d+x\d+$", ErrorMessage = "分辨率格式必须为 宽度x高度 (如 1920x1080)")]
|
||||
public string TargetResolution { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>随配置一并下发的自动订阅请求</summary>
|
||||
public List<CameraConfigSubscribeDto> AutoSubscriptions { get; set; }
|
||||
= new List<CameraConfigSubscribeDto>();
|
||||
|
||||
/// <summary>是否立即执行</summary>
|
||||
[JsonProperty("ImmediateExecution")] // 确保 JSON 里的这个 key 能精准对应到这个属性
|
||||
public bool ImmediateExecution { get; set; }
|
||||
}
|
||||
}
|
||||
22
SHH.Contracts.Grpc/Dtos/CameraConfigSubscribeDto.cs
Normal file
22
SHH.Contracts.Grpc/Dtos/CameraConfigSubscribeDto.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace SHH.Contracts
|
||||
{
|
||||
/// <summary>订阅项</summary>
|
||||
public class CameraConfigSubscribeDto
|
||||
{
|
||||
/// <summary>订阅标识 例如: "UI_Display" (界面显示), "AI_Analysis" (算法分析)</summary>
|
||||
public string AppId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>订阅业务类型 对应枚举 SubscriptionType 的整型值</summary>
|
||||
public int Type { get; set; }
|
||||
|
||||
/// <summary>要求的传输帧率 要求的帧率:8 帧或 1 帧</summary>
|
||||
public int TargetFps { get; set; }
|
||||
|
||||
/// <summary>是否需要高清晰度流(主码流) true: 请求高分辨率主码流; false: 请求低分辨率子码流(默认)</summary>
|
||||
public string Memo { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>是否需要高清晰度</summary>
|
||||
public bool NeedHighDefinition { get; set; }
|
||||
= false;
|
||||
}
|
||||
}
|
||||
81
SHH.Contracts.Grpc/Dtos/CommandPayload.cs
Normal file
81
SHH.Contracts.Grpc/Dtos/CommandPayload.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
namespace SHH.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用指令请求载体 (Request)
|
||||
/// <para>用于 NetMQ 的 Request-Reply 或 Router-Dealer 模式</para>
|
||||
/// </summary>
|
||||
public class CommandPayload
|
||||
{
|
||||
#region --- 0. 协议自描述 ---
|
||||
|
||||
/// <summary>
|
||||
/// 协议类型标识
|
||||
/// <para>建议值: "COMMAND" 或 "指令包"</para>
|
||||
/// </summary>
|
||||
public string Protocol { get; set; } = "COMMAND";
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- 核心路由信息 ---
|
||||
|
||||
/// <summary>
|
||||
/// 指令代码 (路由键)
|
||||
/// <para>示例: "PTZ", "RECORD_START", "SERVER_REGISTER"</para>
|
||||
/// </summary>
|
||||
public string CmdCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 目标对象 ID
|
||||
/// <para>示例: 摄像头ID "101",或者系统级指令填 "SYSTEM"</para>
|
||||
/// </summary>
|
||||
public string TargetId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 业务参数 (JSON 字符串)
|
||||
/// <para>根据 CmdCode 的不同,反序列化为不同的 DTO (如 PtzControlDto)</para>
|
||||
/// </summary>
|
||||
public string JsonParams { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- 追踪与元数据 ---
|
||||
|
||||
/// <summary>
|
||||
/// 请求追踪 ID (UUID)
|
||||
/// <para>核心字段:用于实现异步等待 (await)。回执包必须携带此 ID。</para>
|
||||
/// </summary>
|
||||
public string RequestId { get; set; } = Guid.NewGuid().ToString("N");
|
||||
|
||||
/// <summary>
|
||||
/// 发送时间戳
|
||||
/// </summary>
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- 可靠性控制字段 (QoS) ---
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要回执 (ACK)
|
||||
/// <para>true: 发送端会 await 等待结果 (默认)</para>
|
||||
/// <para>false: 发后即忘 (Fire-and-Forget),服务端收到后不回发任何消息,减少带宽</para>
|
||||
/// </summary>
|
||||
public bool RequireAck { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 重试计数器
|
||||
/// <para>0: 首次发送</para>
|
||||
/// <para>1, 2...: 第N次重试</para>
|
||||
/// <para>服务端据此判断是否需要查重 (幂等性处理)</para>
|
||||
/// </summary>
|
||||
public int RetryCount { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 消息过期时间 (Unix时间戳)
|
||||
/// <para>如果接收端收到时已经超过此时间,直接丢弃,不处理也不回复</para>
|
||||
/// </summary>
|
||||
public long ExpireTime { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user