Publish and subscribe over wss://livekit.uni-wh.de:7800 and refuse cleartext ws://. Conference room is uwh-telhai. Includes the uncommitted encoded H.264 publish path, Rally hairpin, and KMS wall overlay.
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
"""VideoSource in-flight cap + VAAPI stale-frame drop (encoder behind)."""
|
||
from latency import (
|
||
should_drop_encoder_queue_depth,
|
||
should_drop_stale_vaapi_frame,
|
||
video_capture_gate_acquire,
|
||
video_capture_gate_release,
|
||
)
|
||
|
||
|
||
def test_vaapi_keeps_fresh_delta_frame():
|
||
# 30 fps, 33 ms old — still inside the 3-frame budget.
|
||
assert should_drop_stale_vaapi_frame(
|
||
now_us=1_000_000, capture_us=967_000, fps=30, max_frames_behind=3,
|
||
is_keyframe=False,
|
||
) is False
|
||
|
||
|
||
def test_vaapi_drops_delta_older_than_three_frame_periods():
|
||
# 30 fps × 3 = 100 ms. 150 ms on EncoderQueue → drop before ToI420.
|
||
assert should_drop_stale_vaapi_frame(
|
||
now_us=1_000_000, capture_us=850_000, fps=30, max_frames_behind=3,
|
||
is_keyframe=False,
|
||
) is True
|
||
|
||
|
||
def test_vaapi_never_drops_keyframe():
|
||
assert should_drop_stale_vaapi_frame(
|
||
now_us=1_000_000, capture_us=1, fps=30, max_frames_behind=3,
|
||
is_keyframe=True,
|
||
) is False
|
||
|
||
|
||
def test_vaapi_missing_timestamp_is_not_dropped():
|
||
assert should_drop_stale_vaapi_frame(
|
||
now_us=1_000_000, capture_us=0, fps=30, max_frames_behind=3,
|
||
is_keyframe=False,
|
||
) is False
|
||
|
||
|
||
def test_gate_admits_until_max_in_flight():
|
||
gate = {"in_flight": 0, "dropped": 0, "max_in_flight": 3}
|
||
assert video_capture_gate_acquire(gate) is True
|
||
assert video_capture_gate_acquire(gate) is True
|
||
assert video_capture_gate_acquire(gate) is True
|
||
assert gate["in_flight"] == 3
|
||
assert video_capture_gate_acquire(gate) is False
|
||
assert gate["dropped"] == 1
|
||
assert gate["in_flight"] == 3
|
||
|
||
|
||
def test_gate_release_allows_another_capture():
|
||
gate = {"in_flight": 3, "dropped": 0, "max_in_flight": 3}
|
||
video_capture_gate_release(gate)
|
||
assert gate["in_flight"] == 2
|
||
assert video_capture_gate_acquire(gate) is True
|
||
assert gate["in_flight"] == 3
|
||
|
||
|
||
def test_queue_depth_keeps_slot_when_empty():
|
||
assert should_drop_encoder_queue_depth(queued=0, max_queued=1) is False
|
||
|
||
|
||
def test_queue_depth_drops_when_at_max():
|
||
# Latest-frame cap: one in-flight OnFrame/Encode, overwrite don't push.
|
||
assert should_drop_encoder_queue_depth(queued=1, max_queued=1) is True
|
||
|
||
|
||
def test_queue_depth_drops_when_over_max():
|
||
assert should_drop_encoder_queue_depth(queued=3, max_queued=1) is True
|