视频SDK新协议签入
This commit is contained in:
94
SHH.Contracts.Grpc/Protos/gateway_service.proto
Normal file
94
SHH.Contracts.Grpc/Protos/gateway_service.proto
Normal file
@@ -0,0 +1,94 @@
|
||||
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);
|
||||
}
|
||||
|
||||
// --- 1. 注册相关 ---
|
||||
message RegisterRequest {
|
||||
// 进程 ID (用于区分同一台机器上的多个实例)
|
||||
int32 process_id = 1;
|
||||
// 调用进程句柄
|
||||
int32 invoke_process_id = 2;
|
||||
// 实例唯一标识符 (例如 "Stream_1")
|
||||
string instance_id = 3;
|
||||
// 软件版本号
|
||||
string version = 4;
|
||||
// 软件所在的局域网 IP
|
||||
string server_ip = 5;
|
||||
// WebAPI 监听端口
|
||||
int32 webapi_port = 6;
|
||||
// Grpc通讯端口
|
||||
int32 grpc_port = 7;
|
||||
// 启动时间
|
||||
int64 start_time_ticks = 9;
|
||||
// 描述信息
|
||||
string description = 10;
|
||||
}
|
||||
|
||||
// --- 2. 状态上报相关 ---
|
||||
message StatusBatchRequest {
|
||||
string protocol = 1;
|
||||
int64 timestamp = 2;
|
||||
repeated StatusEventItem items = 3;
|
||||
}
|
||||
|
||||
message StatusEventItem {
|
||||
string camera_id = 1;
|
||||
bool is_online = 2;
|
||||
string reason = 3;
|
||||
int64 timestamp = 4;
|
||||
}
|
||||
|
||||
// --- 3. 视频流相关 ---
|
||||
message VideoFrameRequest {
|
||||
string camera_id = 1;
|
||||
int64 capture_timestamp = 2;
|
||||
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;
|
||||
map<string, string> diagnostics = 9;
|
||||
bool has_original_image = 10;
|
||||
bool has_target_image = 11;
|
||||
bytes original_image_bytes = 12;
|
||||
bytes target_image_bytes = 13;
|
||||
}
|
||||
|
||||
// --- 4. 指令下发相关 (对应 C# CommandPayload) ---
|
||||
message CommandStreamRequest {
|
||||
string instance_id = 1; // 告知服务端我是哪个节点
|
||||
}
|
||||
|
||||
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; // 过期时间戳
|
||||
}
|
||||
|
||||
message GenericResponse {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
}
|
||||
28
SHH.Contracts.Grpc/SHH.Contracts.Grpc.csproj
Normal file
28
SHH.Contracts.Grpc/SHH.Contracts.Grpc.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Protos\gateway_service.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="Protos\gateway_service.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.33.4" />
|
||||
<PackageReference Include="Grpc.Core" Version="2.46.6" />
|
||||
<PackageReference Include="Grpc.Core.Api" Version="2.76.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user