libcamera: add frame timeout

This commit is contained in:
Kamil Trzcinski
2023-02-24 19:59:54 +01:00
parent f2ad561734
commit 27b93facc9
2 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,9 @@
#include "util/opts/log.h"
#include "util/opts/fourcc.h"
#include <inttypes.h>
#define CAPTURE_TIMEOUT_US (1000*1000)
#define N_FDS 50
#define QUEUE_ON_CAPTURE // seems to provide better latency
// #define LIMIT_CAPTURE_BUFFERS
@ -148,6 +151,13 @@ static int links_enqueue_from_capture_list(buffer_list_t *capture_list, link_t *
LOG_ERROR(capture_list, "No buffer dequeued from capture_list?");
}
uint64_t now_us = get_monotonic_time_us(NULL, NULL);
if ((now_us - buf->captured_time_us) > CAPTURE_TIMEOUT_US) {
LOG_INFO(buf, "Capture image is outdated. Skipped. Now: %" PRIu64 ", vs %" PRIu64 ".",
now_us, buf->captured_time_us);
return 0;
}
bool dropped = false;
for (int j = 0; j < link->n_output_lists; j++) {