修正帧数统计错误,流量统计错误的问题
确认显示帧数策略有效
This commit is contained in:
@@ -122,56 +122,16 @@ namespace SHH.CameraSdk
|
||||
|
||||
if (manager.GetDevice(101) is HikVideoSource hikCamera)
|
||||
{
|
||||
// 2. 注册需求 (告诉控制器我要什么)
|
||||
// ----------------------------------------------------
|
||||
hikCamera.Controller.Register("WPF_Display_Main", 8); // UI 要 8 帧
|
||||
hikCamera.Controller.Register("AI_Behavior_Engine", 2); // AI 要 2 帧
|
||||
|
||||
// 1. 注册差异化需求 (给每个消费者唯一的 AppId)
|
||||
// ----------------------------------------------------
|
||||
// 模拟:A 进程(如远程预览)带宽有限,只要 3fps
|
||||
hikCamera.Controller.Register("Process_A_Remote", 20);
|
||||
// 1. 注册需求时,手动加上 _Display 后缀
|
||||
hikCamera.Controller.Register("Process_A_Remote_Display", 20);
|
||||
|
||||
// 模拟:B 进程(如本地大屏)性能强劲,要 8fps
|
||||
hikCamera.Controller.Register("Process_B_Local", 8);
|
||||
|
||||
// 模拟:AI 引擎
|
||||
hikCamera.Controller.Register("AI_Engine_Core", 2);
|
||||
|
||||
// [已移除] 这里的 using var remoteRenderer = ... 已被移除
|
||||
// 改为使用传入的 renderer 参数,确保其生命周期受控于 Main
|
||||
|
||||
// 2. 精准订阅 (Subscribe 替代了 +=)
|
||||
// ----------------------------------------------------
|
||||
|
||||
// [消费者 A] - 绝对只会收到 3fps
|
||||
GlobalStreamDispatcher.Subscribe("Process_A_Remote", 101, frame =>
|
||||
// 2. 订阅时,也改用带后缀的名称
|
||||
GlobalStreamDispatcher.Subscribe("Process_A_Remote_Display", 101, frame =>
|
||||
{
|
||||
// 关键:增加引用计数,防止在投递过程中被 Pipeline 回收
|
||||
frame.AddRef();
|
||||
|
||||
// 投递到渲染线程 (FrameConsumer)
|
||||
renderer.Enqueue(frame);
|
||||
|
||||
//Console.WriteLine("Frame Enqueued");
|
||||
});
|
||||
|
||||
// [消费者 B] - 绝对只会收到 8fps
|
||||
GlobalStreamDispatcher.Subscribe("Process_B_Local", (deviceId, frame) =>
|
||||
{
|
||||
//if (deviceId == 101)
|
||||
//{
|
||||
// Console.WriteLine($"[Process B] 本地渲染一帧 (8fps节奏)");
|
||||
//}
|
||||
});
|
||||
|
||||
// [消费者 AI]
|
||||
GlobalStreamDispatcher.Subscribe("AI_Engine_Core", (deviceId, frame) =>
|
||||
{
|
||||
//if (deviceId == 101)
|
||||
//{
|
||||
// Console.WriteLine($" >>> [AI] 分析一帧...");
|
||||
//}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user