libcamera: add frame timeout
This commit is contained in:
parent
f2ad561734
commit
27b93facc9
@ -143,6 +143,15 @@ int libcamera_buffer_list_dequeue(buffer_list_t *buf_list, buffer_t **bufp)
|
||||
|
||||
*bufp = buf_list->bufs[index];
|
||||
|
||||
std::optional<int64_t> sensor_timestamp((*bufp)->libcamera->request->metadata().
|
||||
get<int64_t>(libcamera::controls::SensorTimestamp));
|
||||
uint64_t sensor_timestamp_us = sensor_timestamp.value_or(0) / 1000;
|
||||
uint64_t boot_time_us = get_time_us(CLOCK_BOOTTIME, NULL, NULL, 0);
|
||||
|
||||
uint64_t now_us = get_monotonic_time_us(NULL, NULL);
|
||||
|
||||
(*bufp)->captured_time_us = now_us - (boot_time_us - sensor_timestamp_us);
|
||||
|
||||
if (index == 0) {
|
||||
libcamera_buffer_dump_metadata(*bufp);
|
||||
}
|
||||
|
@ -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++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user