From eb43876bb62bf69b4b95782798fd0c71d123f8f2 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 15 Oct 2026 15:57:05 +0200 Subject: [PATCH] Timestamp video availability before receive worker scheduling --- src/call/call_video.h | 1 + src/call/call_video_port.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/call/call_video.h b/src/call/call_video.h index 44bc61f6..742ce168 100644 --- a/src/call/call_video.h +++ b/src/call/call_video.h @@ -50,6 +50,7 @@ struct call_video_frame { uint32_t size, offset, length; uint8_t flags; const uint8_t *data; + int64_t received_us; // Только локальная RX port метка MONOTONIC; по сети не передаётся. }; int call_video_caps_valid(const struct call_video_caps *caps); diff --git a/src/call/call_video_port.c b/src/call/call_video_port.c index 2ca77439..f43f1503 100644 --- a/src/call/call_video_port.c +++ b/src/call/call_video_port.c @@ -1,4 +1,5 @@ #include "call_video_port.h" +#include "call_video_playout.h" #include "call_video_transport.h" #include "call_priv.h" #include "../chat/chat_setting.h" @@ -53,11 +54,13 @@ static int ready(void *arg, uint32_t bytes) { pthread_mutex_unlock(&lock); return result; } static void frame(void *arg, const struct call_video_frame *f) { + int64_t received = call_video_playout_now_us(); pthread_mutex_lock(&lock); if (port.id == (uint64_t)(uintptr_t)arg && port.count < 8 && f->size <= 4u * 1024u * 1024u - port.bytes) { uint8_t *data = u_malloc(f->size); if (data) { - memcpy(data, f->data, f->size); port.rx[port.count] = *f; port.rx[port.count++].data = data; port.bytes += f->size; + memcpy(data, f->data, f->size); port.rx[port.count] = *f; + port.rx[port.count].received_us = received; port.rx[port.count++].data = data; port.bytes += f->size; } else { DEBUG_ERROR(DEBUG_CATEGORY_CALL, "video port RX allocation failed bytes=%u", f->size); port.key = 1; schedule(); } } else { DEBUG_WARN(DEBUG_CATEGORY_CALL, "video port RX changed during delivery"); port.key = 1; schedule(); } pthread_mutex_unlock(&lock);