Record codec and telemetry validation with precise decoder diagnostics

This commit is contained in:
evgeny committed 2026-10-14 02:11:59 +02:00
1 parent 49ca49fa1e
commit 643420b644
3 files changed
+59 -6

No files matched your search

+14 -5
View File
@@ -17,6 +17,7 @@
#include <chrono>
#include <algorithm>
#include <cstring>
#include <cerrno>
extern "C" {
#include "../../../lib/debug_config.h"
@@ -319,7 +320,12 @@ void StreamPlayerWindow::decode() {
std::memcpy(decoder->extradata, configuration, configurationSize); decoder->extradata_size = (int)configurationSize;
}
}
if (!decoder || avcodec_open2(decoder, codec, nullptr) < 0) { fail(text("Stream video decoder failed")); break; }
int openResult = !codec ? AVERROR_DECODER_NOT_FOUND : !decoder ? AVERROR(ENOMEM) : avcodec_open2(decoder, codec, nullptr);
if (openResult < 0) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop decoder open failed codec=%u name=%s config=%zu result=%d",
record.format.video_codec, codec ? codec->name : "unavailable", configurationSize, openResult);
fail(text("Stream video decoder failed")); break;
}
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop decoder codec=%u name=%s config=%zu", record.format.video_codec, codec->name, configurationSize);
decoder->pkt_timebase = AVRational{1, 1000000}; waitKey = false;
}
@@ -328,13 +334,16 @@ void StreamPlayerWindow::decode() {
std::memcpy(packet->data, data, size);
packet->pts = packet->dts = (int64_t)record.pts;
int sent = avcodec_send_packet(decoder, packet);
if (sent < 0) { DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop H264 packet rejected result=%d", sent); reset(true); continue; }
if (sent < 0) {
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop video packet rejected codec=%u bytes=%zu result=%d", record.format.video_codec, size, sent);
reset(true); continue;
}
int received;
while ((received = avcodec_receive_frame(decoder, frame)) == 0) {
decoded++;
if (frame->width <= 0 || frame->width > 4096 || frame->height <= 0 || frame->height > 4096) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop H264 dimensions invalid id=%llu size=%dx%d",
(unsigned long long)p.id, frame->width, frame->height);
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop video dimensions invalid id=%llu codec=%u size=%dx%d",
(unsigned long long)p.id, record.format.video_codec, frame->width, frame->height);
fail(text("Invalid stream video dimensions")); p.running = false; break;
}
int64_t pts = frame->best_effort_timestamp == AV_NOPTS_VALUE ? (int64_t)record.pts : frame->best_effort_timestamp;
@@ -358,7 +367,7 @@ void StreamPlayerWindow::decode() {
p.videoBytes += (size_t)image.sizeInBytes(); p.videos.push_back({std::move(image), pts});
}
if (received != AVERROR(EAGAIN) && received != AVERROR_EOF && p.running) {
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop H264 decode rejected result=%d", received); reset(true);
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop video decode rejected codec=%u result=%d", record.format.video_codec, received); reset(true);
}
if (nowUs() - report >= 1000000) {
int64_t now = nowUs(); double seconds = (now - report) / 1000000.0; report = now;