摄像头播放后,增加分辨率的显示

This commit is contained in:
2025-12-26 18:55:04 +08:00
parent e98059fd30
commit 108c97924f
7 changed files with 232 additions and 93 deletions

View File

@@ -295,6 +295,17 @@ public class HikVideoSource : BaseVideoSource
private void SafeOnDecodingCallBack(int nPort, IntPtr pBuf, int nSize, ref HikPlayMethods.FRAME_INFO pFrameInfo, int nReserved1, int nReserved2)
{
// [优化] 维持心跳,防止被哨兵误杀
MarkFrameReceived(0);
// [新增] 捕获并更新分辨率
// 只有当分辨率发生变化时才写入,减少属性赋值开销
if (Width != pFrameInfo.nWidth || Height != pFrameInfo.nHeight)
{
Width = pFrameInfo.nWidth;
Height = pFrameInfo.nHeight;
}
// 1. [核心流控] 询问基类控制器:这帧要不要?
// 之前失效是因为操作的是子类被遮蔽的 Controller现在复用基类 Controller逻辑就通了。
// 传入真实的输入帧率作为参考基准
@@ -303,9 +314,6 @@ public class HikVideoSource : BaseVideoSource
// 如果没人要,直接丢弃,不进行 Mat 转换,节省 CPU
if (!decision.IsCaptured) return;
// [优化] 维持心跳,防止被哨兵误杀
MarkFrameReceived(0);
int width = pFrameInfo.nWidth;
int height = pFrameInfo.nHeight;
@@ -348,7 +356,8 @@ public class HikVideoSource : BaseVideoSource
}
finally
{
smartFrame.Dispose();
if (smartFrame != null)
smartFrame.Dispose();
}
}