Bound video send debt and test decoder acceptance and rejection
This commit is contained in:
1 parent
634ef222a4
commit
005d891fb4
2 files changed
+30
-2
No files matched your search
@@ -81,6 +81,14 @@ static uint64_t media_bytes(uint64_t bytes, uint64_t packets) {
|
||||
uint64_t headers = packets * CALL_VIDEO_HEADER_BYTES;
|
||||
return bytes >= headers ? bytes - headers : 0;
|
||||
}
|
||||
/* Ограничиваем накопление полусекундой целевого потока плюс базовый RTT.
|
||||
* 64 KiB оставляем для всплеска IDR; абсолютный предел — защита памяти. */
|
||||
static uint64_t debt_limit(const struct call_video_transport *v, uint32_t rtt_us) {
|
||||
uint64_t rtt = rtt_us < 2000000 ? rtt_us : 2000000;
|
||||
uint64_t limit = (uint64_t)(v->applied_bps ? v->applied_bps : 1000000) * (rtt + 500000) / 8000000;
|
||||
if (limit < 65536) limit = 65536;
|
||||
return limit < CALL_VIDEO_MAX_FRAME ? limit : CALL_VIDEO_MAX_FRAME;
|
||||
}
|
||||
static void update_rate(struct call_video_transport *v) {
|
||||
if (!v->rate_format.generation || !v->applied_bps) return;
|
||||
struct call_session *s = v->session;
|
||||
@@ -128,7 +136,7 @@ static void update_rate(struct call_video_transport *v) {
|
||||
sample.applied_bps = v->applied_bps; sample.minimum_bps = minimum; sample.maximum_bps = maximum;
|
||||
sample.baseline_rtt_us = net.baseline_rtt_us; sample.rtt_us = net.rtt_us;
|
||||
sample.frame_interval_us = v->tx.format.fps ? 1000000 / v->tx.format.fps : 33333;
|
||||
sample.debt_limit_bytes = CALL_VIDEO_MAX_FRAME;
|
||||
sample.debt_limit_bytes = debt_limit(v, net.baseline_rtt_us);
|
||||
sample.valid = found && net.window.valid && produced.valid && net.window.end_us == produced.end_us;
|
||||
// Первый KEY должен создать логический канал; до этого нет транспортных измерений.
|
||||
sample.ready = found ? net.ready : 1;
|
||||
@@ -158,6 +166,10 @@ static void flush(struct call_video_transport *v) {
|
||||
uint8_t wire[CALL_VIDEO_HEADER_BYTES + CALL_VIDEO_FRAGMENT_BYTES];
|
||||
// Ограниченный burst одного вызова; повторяется по audio send и таймеру 50мс.
|
||||
for (unsigned budget = 0; v->data && budget < 16; budget++) {
|
||||
struct ETCP_ROUTER_TX_STATS net;
|
||||
if (!etcp_router_tx_stats(s->ctx->inst, s->group_id, s->peer_node_id, ETCP_RT_ID_CALL_VIDEO, get_time_us(), &net)
|
||||
&& media_bytes(net.queued_bytes + net.inflight_bytes, (uint64_t)net.queued_packets + net.inflight_packets)
|
||||
>= debt_limit(v, net.baseline_rtt_us)) return;
|
||||
if (!etcp_router_send_q_has_room(s->ctx->inst, s->group_id, s->peer_node_id, ETCP_RT_ID_CALL_VIDEO)
|
||||
|| queue_entry_count(conn->send_q) >= ROUTER_MAX_SEND_Q_PACKETS) return;
|
||||
uint32_t remaining = v->tx.size - v->tx.offset;
|
||||
|
||||
Reference in new issue
Block a user