This commit is contained in:
cxh 2025-10-17 16:03:26 +08:00
parent b599ef6903
commit 5ee6245d1b

View File

@ -150,13 +150,25 @@ void RTMPManager::stream_loop(Camera cam, StreamContext *ctx)
// 检查帧超时3 秒内没有检测到帧 // 检查帧超时3 秒内没有检测到帧
auto elapsed = auto elapsed =
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - start_time).count(); std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - start_time).count();
if (!got_frame && elapsed > 3) if (!got_frame && elapsed > 5)
{ {
ctx->status.running = false; GstState state;
ctx->status.last_error = "No frames detected (no video signal)"; gst_element_get_state(pipeline, &state, nullptr, 0);
LOG_ERROR("[RTMP] " + key + " - " + ctx->status.last_error); if (state != GST_STATE_PLAYING)
need_restart = true; {
break; ctx->status.running = false;
ctx->status.last_error = "Pipeline failed to reach PLAYING (maybe no device signal)";
LOG_ERROR("[RTMP] " + key + " - " + ctx->status.last_error);
need_restart = true;
break;
}
else
{
ctx->status.running = true;
ctx->status.last_error.clear();
LOG_INFO("[RTMP] " + key + " reached PLAYING but no frames yet, assuming OK");
got_frame = true;
}
} }
if (!msg) continue; if (!msg) continue;