2026-01-15 09:31:57 +08:00
|
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
|
|
|
|
// 自动生成代码时的命名空间
|
|
|
|
|
|
option csharp_namespace = "SHH.Contracts.Grpc";
|
|
|
|
|
|
|
|
|
|
|
|
service GatewayProvider {
|
|
|
|
|
|
// 1. 身份注册 (CameraService -> AiVideo)
|
|
|
|
|
|
rpc RegisterInstance (RegisterRequest) returns (GenericResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 状态批量上报 (CameraService -> AiVideo)
|
|
|
|
|
|
rpc ReportStatusBatch (StatusBatchRequest) returns (GenericResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 视频流传输 (双向或客户端流)
|
|
|
|
|
|
rpc UploadVideoStream (stream VideoFrameRequest) returns (GenericResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// ★ 4. 指令推送通道 (Server Streaming)
|
|
|
|
|
|
// 客户端启动后调用此方法并保持连接,服务端通过此流下发 Sync_Camera 等指令
|
|
|
|
|
|
rpc OpenCommandChannel (CommandStreamRequest) returns (stream CommandPayloadProto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 11:04:38 +08:00
|
|
|
|
// --- 通用指令推送通道 ---
|
|
|
|
|
|
message CommandPayloadProto {
|
|
|
|
|
|
string protocol = 1; // 协议类型,默认 "COMMAND"
|
|
|
|
|
|
string cmd_code = 2; // 指令代码,如 "Sync_Camera"
|
|
|
|
|
|
string target_id = 3; // 目标对象 ID
|
|
|
|
|
|
string json_params = 4; // 业务参数 JSON
|
|
|
|
|
|
string request_id = 5; // 请求追踪 ID
|
|
|
|
|
|
int64 timestamp_ticks = 6; // 发送时间戳 (Ticks)
|
|
|
|
|
|
bool require_ack = 7; // 是否需要回执
|
|
|
|
|
|
int32 retry_count = 8; // 重试计数
|
|
|
|
|
|
int64 expire_time = 9; // 过期时间戳
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 09:31:57 +08:00
|
|
|
|
// --- 1. 注册相关 ---
|
|
|
|
|
|
message RegisterRequest {
|
2026-01-15 11:04:38 +08:00
|
|
|
|
int32 process_id = 1; // 进程 ID (用于区分同一台机器上的多个实例)
|
|
|
|
|
|
int32 invoke_process_id = 2; // 调用进程句柄
|
|
|
|
|
|
string instance_id = 3; // 实例唯一标识符 (例如 "Stream_1")
|
|
|
|
|
|
string version = 4; // 软件版本号
|
|
|
|
|
|
string server_ip = 5; // 软件所在的局域网 IP
|
|
|
|
|
|
int32 webapi_port = 6; // WebAPI 监听端口
|
|
|
|
|
|
int32 grpc_port = 7; // Grpc通讯端口
|
|
|
|
|
|
int64 start_time_ticks = 9; // 启动时间
|
|
|
|
|
|
string description = 10; // 描述信息
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- 2. 状态上报相关 ---
|
|
|
|
|
|
message StatusBatchRequest {
|
2026-01-15 11:04:38 +08:00
|
|
|
|
int64 timestamp = 1; // 上报时间戳
|
|
|
|
|
|
repeated StatusEventItem items = 2; // 状态事件列表
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 11:04:38 +08:00
|
|
|
|
// 设备状态变更通知包
|
2026-01-15 09:31:57 +08:00
|
|
|
|
message StatusEventItem {
|
2026-01-15 11:04:38 +08:00
|
|
|
|
string camera_id = 1; // 摄像头ID
|
|
|
|
|
|
bool is_online = 2; // 是否在线
|
|
|
|
|
|
string reason = 3; // 状态变更原因描述
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 11:04:38 +08:00
|
|
|
|
// --- 3. 视频流传输协议 ---
|
|
|
|
|
|
// 职责:承载高频传输的实时视频帧、算法处理图及相关的 AI 诊断元数据
|
2026-01-15 09:31:57 +08:00
|
|
|
|
message VideoFrameRequest {
|
2026-01-15 11:04:38 +08:00
|
|
|
|
|
|
|
|
|
|
string camera_id = 1; // 摄像头唯一物理标识符
|
|
|
|
|
|
int64 capture_timestamp = 2; // 图像在传感器端的原始采集时间戳 (Ticks/Unixms)
|
|
|
|
|
|
int64 dispatch_timestamp = 3; // 图像在分析节点端的分发/外传时间戳 (用于测量网络传输耗时)
|
|
|
|
|
|
int32 original_width = 4; // 原始采集图像的宽度
|
|
|
|
|
|
int32 original_height = 5; // 原始采集图像的高度
|
|
|
|
|
|
int32 target_width = 6; // 算法处理(如缩放或裁剪)后的目标图像宽度
|
|
|
|
|
|
int32 target_height = 7; // 算法处理后的目标图像高度
|
|
|
|
|
|
repeated string subscriber_ids = 8; // 订阅此帧的应用标识列表 (例如: "UI", "AI", "Record")
|
|
|
|
|
|
map<string, string> diagnostics = 9; // 诊断与扩展元数据 键值对存储:例如 {"fps": "25", "bitrate": "4Mbps", "algo_latency": "12ms"}
|
|
|
|
|
|
bool has_original_image = 10; // 状态标志:包内是否包含原始图像二进制数据
|
|
|
|
|
|
bool has_target_image = 11; // 状态标志:包内是否包含算法处理图(或带 OSD 渲染的图)
|
|
|
|
|
|
bytes original_image_bytes = 12; // 原始图像二进制数据 (通常为 JPG/NV12 格式)
|
|
|
|
|
|
bytes target_image_bytes = 13; // 算法处理图/标注图二进制数据
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- 4. 指令下发相关 (对应 C# CommandPayload) ---
|
|
|
|
|
|
message CommandStreamRequest {
|
2026-01-15 11:04:38 +08:00
|
|
|
|
string instance_id = 1; // 告知服务端我是哪个节点
|
|
|
|
|
|
int32 process_id = 2; // 告知服务端我是哪个进程
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message GenericResponse {
|
|
|
|
|
|
bool success = 1;
|
|
|
|
|
|
string message = 2;
|
2026-01-31 10:43:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AI 分析专用服务
|
|
|
|
|
|
service AiAnalysisProvider {
|
|
|
|
|
|
// 1. 注册 (AIServer -> AiVideo) - 使用 AI 专有的消息名
|
|
|
|
|
|
rpc RegisterAiInstance (AiRegisterRequest) returns (AiGenericResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 图像流交互 (AiVideo -> AIServer)
|
|
|
|
|
|
rpc GetRawVideoStream (AiCommandStreamRequest) returns (stream AiVideoFrameRequest);
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 图像流交互 (AIServer -> AiVideo)
|
|
|
|
|
|
rpc UploadAnalysisResult (stream AiVideoFrameRequest) returns (AiGenericResponse);
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 指令通道
|
|
|
|
|
|
rpc OpenAiCommandChannel (AiCommandStreamRequest) returns (stream AiCommandPayloadProto);
|
|
|
|
|
|
rpc SendAiCommand (AiCommandPayloadProto) returns (AiGenericResponse);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- 以下是 AI 专属的消息体定义,不再引用 gateway_service.proto ---
|
|
|
|
|
|
|
|
|
|
|
|
message AiGenericResponse {
|
|
|
|
|
|
bool success = 1;
|
|
|
|
|
|
string message = 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message AiRegisterRequest {
|
|
|
|
|
|
int32 process_id = 1;
|
|
|
|
|
|
string instance_id = 2;
|
|
|
|
|
|
string version = 3;
|
|
|
|
|
|
string description = 4;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message AiCommandStreamRequest {
|
|
|
|
|
|
string instance_id = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message AiVideoFrameRequest {
|
|
|
|
|
|
string camera_id = 1;
|
|
|
|
|
|
int64 capture_timestamp = 2;
|
|
|
|
|
|
map<string, string> diagnostics = 3;
|
|
|
|
|
|
bytes original_image_bytes = 4;
|
|
|
|
|
|
bytes target_image_bytes = 5;
|
|
|
|
|
|
bool has_target_image = 6;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message AiCommandPayloadProto {
|
|
|
|
|
|
string cmd_code = 1;
|
|
|
|
|
|
string json_params = 2;
|
|
|
|
|
|
string request_id = 3;
|
2026-01-15 09:31:57 +08:00
|
|
|
|
}
|