支持通过网页增加、删除、修改摄像头配置信息
支持摄像头配置信息中句柄的设置,并实测有效
This commit is contained in:
@@ -34,6 +34,30 @@ public class FrameController
|
||||
_accumulators.TryRemove(appId, out _);
|
||||
}
|
||||
|
||||
// 修改 Register 方法,接收整个 Requirement 对象或多个参数
|
||||
public void Register(FrameRequirement req)
|
||||
{
|
||||
_requirements.AddOrUpdate(req.AppId,
|
||||
_ => req, // 如果不存在,直接添加整个对象
|
||||
(_, old) =>
|
||||
{
|
||||
// 如果已存在,更新关键业务字段,同时保留统计状态
|
||||
old.TargetFps = req.TargetFps;
|
||||
old.Memo = req.Memo;
|
||||
old.Handle = req.Handle;
|
||||
old.Type = req.Type;
|
||||
old.SavePath = req.SavePath;
|
||||
// 注意:不要覆盖 old.RealFps,保留之前的统计值
|
||||
return old;
|
||||
});
|
||||
|
||||
// 如果是降频(<=20),确保积分器存在
|
||||
if (req.TargetFps <= 20)
|
||||
{
|
||||
_accumulators.GetOrAdd(req.AppId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unregister(string appId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(appId)) return;
|
||||
@@ -100,6 +124,9 @@ public class FrameController
|
||||
// 扣除成本,保留余数 (余数是精度的关键)
|
||||
acc -= LOGICAL_BASE_FPS;
|
||||
|
||||
// 【核心修复】在此处触发统计,RealFps 才会开始跳动
|
||||
req.UpdateRealFps();
|
||||
|
||||
req.LastCaptureTick = currentTick;
|
||||
}
|
||||
|
||||
@@ -120,6 +147,6 @@ public class FrameController
|
||||
// ---------------------------------------------------------
|
||||
public List<dynamic> GetCurrentRequirements()
|
||||
{
|
||||
return _requirements.Values.Select(r => new { r.AppId, r.TargetFps, LastActive = r.LastCaptureTick }).ToList<dynamic>();
|
||||
return _requirements.Values.Select(r => new { r.AppId, r.TargetFps, r.RealFps, LastActive = r.LastCaptureTick, r.Memo, r.SavePath, r.Handle, r.TargetIp, r.TargetPort, r.Protocol, r.Type }).ToList<dynamic>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user