feat(video): 可配置 RTSP 打开超时并提高默认时长
- Settings 增加 video_open_timeout_sec(VIDEO_OPEN_TIMEOUT_SEC),默认 45s - SessionManager 全部就绪等待为该值 + 5s;StreamWorker 传入单路超时 - baked pipeline 回退默认值与配置对齐;.env.example 补充说明 - or_site_config.sample.json 扩展穿透摄像头与术间绑定示例 - 同步 uv.lock
This commit is contained in:
@@ -183,7 +183,7 @@ class CameraSessionManager:
|
||||
stop_event = asyncio.Event()
|
||||
readies = [asyncio.Event() for _ in camera_ids]
|
||||
tasks: list[asyncio.Task[None]] = []
|
||||
open_timeout = bp.VIDEO_OPEN_TIMEOUT_SEC + 5.0
|
||||
open_timeout = float(self._s.video_open_timeout_sec) + 5.0
|
||||
|
||||
for cam_id, ready in zip(camera_ids, readies, strict=True):
|
||||
tasks.append(
|
||||
@@ -438,6 +438,7 @@ class CameraSessionManager:
|
||||
surgery_id=surgery_id,
|
||||
camera_id=camera_id,
|
||||
url=url,
|
||||
open_timeout_sec=self._s.video_open_timeout_sec,
|
||||
)
|
||||
try:
|
||||
await w_tear.run(
|
||||
@@ -518,6 +519,7 @@ class CameraSessionManager:
|
||||
surgery_id=surgery_id,
|
||||
camera_id=camera_id,
|
||||
url=url,
|
||||
open_timeout_sec=self._s.video_open_timeout_sec,
|
||||
)
|
||||
await worker.run(
|
||||
stream_ready=stream_ready,
|
||||
|
||||
@@ -41,10 +41,14 @@ class CameraStreamWorker:
|
||||
surgery_id: str,
|
||||
camera_id: str,
|
||||
url: str,
|
||||
open_timeout_sec: float | None = None,
|
||||
) -> None:
|
||||
self._surgery_id = surgery_id
|
||||
self._camera_id = camera_id
|
||||
self._url = url
|
||||
self._open_timeout_sec = (
|
||||
float(open_timeout_sec) if open_timeout_sec is not None else bp.VIDEO_OPEN_TIMEOUT_SEC
|
||||
)
|
||||
|
||||
async def run(
|
||||
self,
|
||||
@@ -63,7 +67,7 @@ class CameraStreamWorker:
|
||||
if cap is None:
|
||||
try:
|
||||
cap = RtspCapture(
|
||||
self._url, open_timeout_sec=bp.VIDEO_OPEN_TIMEOUT_SEC
|
||||
self._url, open_timeout_sec=self._open_timeout_sec
|
||||
)
|
||||
await asyncio.to_thread(cap.open)
|
||||
consecutive_failures = 0
|
||||
|
||||
Reference in New Issue
Block a user