fix(video): recover encoder capacity, pace RTP and isolate preview sessions
This commit is contained in:
@@ -90,6 +90,16 @@ class Source:
|
||||
with self.lock:
|
||||
return self.sequence, self.frame, self.observed
|
||||
|
||||
def frame_state(self):
|
||||
# Read only the decoder slot already used by the preview. No SDK call.
|
||||
with self.lock:
|
||||
now = time.monotonic()
|
||||
if self.sequence and now - self.observed < 2:
|
||||
return "online"
|
||||
if now - self.started >= 2:
|
||||
return "lost"
|
||||
return None
|
||||
|
||||
def health(self):
|
||||
"""Bounded in-memory counters; no encoded media or monitoring history."""
|
||||
with self.lock:
|
||||
@@ -435,6 +445,12 @@ class Engine:
|
||||
self.thread = threading.Thread(target=self.loop.run_forever, daemon=True)
|
||||
self.thread.start()
|
||||
|
||||
def frame_state(self, key):
|
||||
# Sources are installed/removed atomically on the engine thread. Hold a
|
||||
# reference during the read; a fresh session always has a different key.
|
||||
source = self.peers.sources.get(key)
|
||||
return source.frame_state() if source is not None else None
|
||||
|
||||
def capture(self, key, path, start):
|
||||
work = self.peers.prime(key, path) if start else self.peers.release(key)
|
||||
future = asyncio.run_coroutine_threadsafe(work, self.loop)
|
||||
|
||||
Reference in New Issue
Block a user