fix(video): recover encoder capacity, pace RTP and isolate preview sessions

This commit is contained in:
DCCONSTRUCTIONS
2026-11-21 20:58:25 +03:00
parent 3d04fa45d3
commit bed1db3508
29 changed files with 1534 additions and 141 deletions
+12 -9
View File
@@ -25,14 +25,17 @@ def test_profile_rate_recovery_has_no_second_hold_and_profile_debounces():
b.update(allocation(4_000_000))
assert b.video() == (1280, 15)
b.update(allocation(100_000))
assert b.video() == (160, 2) and b.bps == 65000
assert b.video() == (1280, 15) and b.bps == 65000
now[0] = 101
b.update(allocation(100_000))
assert b.video() == (160, 2)
now[0] = 102
b.update(allocation(4_000_000))
assert b.bps == 2_600_000 and b.video() == (160, 2)
now[0] = 103
now[0] = 104
b.update(allocation(4_000_000))
assert b.video() == (1280, 15)
now[0] = 107
now[0] = 108
assert b.video() == (0, 0) and b.cloud()[0] == 0
with pytest.raises(ConnectionError):
b.update(allocation(True))
@@ -78,28 +81,28 @@ def test_real_encoder_honors_node_below_vendor_floor_and_receiver_remb(codec):
assert max(map(len,result.payloads)) <= 1100
assert encoder.codec.framerate == b.video()[1]
assert b.snapshot()["encoder_fps"] == b.video()[1]
assert b.snapshot()["encoder_rate_control"] == "paced-h264-vbv/v2"
assert b.snapshot()["encoder_rate_control"] == "coalesced-h264-vbv/v5"
assert b.encoder_frames == 1 and b.encoded_frame_bytes > 0
assert b.snapshot()["encode_timing"]["count"] == 1
assert sum(b.snapshot()["encode_timing"]["bins"]) == 1
assert encoder.codec.bit_rate == 52000
encoder.target_bitrate = 32000
assert encoder.target_bitrate == 52000
assert encoder.target_bitrate == 32000
b.update(allocation(30_000))
assert encoder.target_bitrate == 19500
# Quiet imagery is not proof of a smaller allocation. Retain the
# stock receiver floor, but allow Node's cap below it.
# Spatial quality follows allocation, but receiver congestion is
# also a ceiling on the encoder, including below the stock floor.
b.target = 2_600_000
b.profile = (1280, 15)
assert b.video() == (1280, 15)
assert encoder.target_bitrate >= 250000
assert encoder.target_bitrate == 32000
encoder.target_bitrate = 600000
assert encoder.target_bitrate == 600000 and b.video() == (1280, 15)
# Node75 observation: a recovered Node allocation is only a ceiling;
# receiver feedback can still keep the real encoder near its floor.
b.target = 3_250_000
encoder.target_bitrate = 307644
assert encoder.target_bitrate == (500000 if codec == "H264" else 307644)
assert encoder.target_bitrate == 307644
assert b.bps == 3_250_000 and b.video() == (1280, 15)
encoder.target_bitrate = 3_000_000
assert encoder.target_bitrate == (3_000_000 if codec == "H264" else 1_500_000)