fix: 配置摄像头必须初始化

This commit is contained in:
SikongJueluo 2025-07-10 16:29:10 +08:00
parent 558a139593
commit 540f5c788d
No known key found for this signature in database
1 changed files with 29 additions and 39 deletions

View File

@ -165,18 +165,9 @@ public class HttpVideoStreamService : BackgroundService
} }
try try
{
await Task.Run(async () =>
{ {
lock (_cameraLock) lock (_cameraLock)
{ {
// 如果地址和端口没有变化,直接返回成功
if (_cameraAddress == address && _cameraPort == port && _camera != null)
{
logger.Info("摄像头配置未变化,保持当前连接");
return;
}
// 关闭现有连接 // 关闭现有连接
if (_camera != null) if (_camera != null)
{ {
@ -210,7 +201,6 @@ public class HttpVideoStreamService : BackgroundService
throw new Exception($"Camera Init Failed!"); throw new Exception($"Camera Init Failed!");
} }
} }
});
return true; return true;
} }
catch (Exception ex) catch (Exception ex)