16#include <freertos/FreeRTOS.h>
17#include <freertos/semphr.h>
18#include <freertos/task.h>
23 uint32_t published = 0;
24 uint32_t dropped_no_slot = 0;
25 uint32_t dropped_oversize = 0;
26 uint32_t dropped_corrupt = 0;
32 static constexpr size_t kSlotBytes = 32 * 1024;
38 std::optional<size_t> begin_write();
39 uint8_t* write_buffer(
size_t slot) {
return buffers_[slot]; }
41 void abort_write(
size_t slot, frames::AbortReason reason);
44 std::optional<frames::FrameLease> acquire_latest();
45 const uint8_t* data(
const frames::FrameLease& lease)
const {
return buffers_[lease.slot()]; }
67 UBaseType_t priority, BaseType_t core,
void* arg);
72 bool ready()
const {
return ready_; }
74 void release_slot(
size_t slot)
override;
78 std::array<uint8_t*, frames::kSlotCount> buffers_{};
79 SemaphoreHandle_t mutex_ =
nullptr;
Definition frame_store.h:30
static constexpr size_t kMaxSubscribers
Maximum number of tasks woken on each publish (stream task + detection task).
Definition frame_store.h:48
void remove_subscriber(TaskHandle_t task)
Unregister a task. Unknown or null handles are ignored. Remove before deleting the task.
Definition frame_store.cpp:101
bool ready() const
True only after a fully successful begin(). Every other call is a safe no-op before that.
Definition frame_store.h:72
bool add_subscriber(TaskHandle_t task)
Register a task to wake (xTaskNotifyGive) on every publish.
Definition frame_store.cpp:77
TaskHandle_t start_subscriber_task(TaskFunction_t entry, const char *name, uint32_t stack_bytes, UBaseType_t priority, BaseType_t core, void *arg)
Creates a task pinned to core and registers it as a subscriber, so it is woken on every publish.
Definition frame_store.cpp:144
bool begin()
Create the mutex and allocate all slot buffers in PSRAM. False if any allocation fails.
Definition frame_store.cpp:11
Move-only handle on a published frame. Releases its slot exactly once, on release() or destruction.
Definition frame_slots.h:47
Definition frame_slots.h:93
Whatever a FrameLease must notify when it is released (FrameSlots natively, FrameStore on device).
Definition frame_slots.h:37
Slot bookkeeping for camera frames: who may write which slot, and RAII leases for readers.
Definition frame_store.h:22