Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
ai_cam_pipe.c
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 * @file ai_cam_pipe.c
20 * @brief Supervise the selected system or native AI-camera owner and publish captured JPEGs.
21 * @details Persistent capture uses private session filenames and an inotify
22 * completion event so an incomplete exposure is never visible under its final
23 * name. One-shot capture is allowed only when persistent mode proves no trigger
24 * was sent; ambiguous post-trigger failures are never replayed.
25 */
26#include "ai_cam_pipe.h"
27#include "camera_backend.h"
28#include "imx500_pipe.h"
29#include "path_utils.h"
30
31#include <errno.h>
32#include <limits.h>
33#include <poll.h>
34#include <signal.h>
35#include <spawn.h>
36#include <stdbool.h>
37#include <stdint.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41#include <sys/inotify.h>
42#include <sys/stat.h>
43#include <sys/wait.h>
44#include <time.h>
45#include <unistd.h>
46
47#ifndef USHER_AI_CAM_COMMAND
48#define USHER_AI_CAM_COMMAND "rpicam-still"
49#endif
50#ifndef USHER_AI_CAM_NATIVE_COMMAND
51#define USHER_AI_CAM_NATIVE_COMMAND "./bin/aicam"
52#endif
53#ifndef USHER_AI_CAM_PHOTO_DIR
54#define USHER_AI_CAM_PHOTO_DIR "~/Pictures/sensoraia"
55#endif
56#ifndef USHER_AI_CAM_WIDTH
57#define USHER_AI_CAM_WIDTH "2028"
58#endif
59#ifndef USHER_AI_CAM_HEIGHT
60#define USHER_AI_CAM_HEIGHT "1520"
61#endif
62#ifndef USHER_AI_CAM_PERSISTENT
63#define USHER_AI_CAM_PERSISTENT 1
64#endif
65#ifndef USHER_AI_CAM_STARTUP_MS
66#define USHER_AI_CAM_STARTUP_MS 3000
67#endif
68#ifndef USHER_AI_CAM_SIGNAL_TIMEOUT_MS
69#define USHER_AI_CAM_SIGNAL_TIMEOUT_MS 4000
70#endif
71#ifndef USHER_AI_CAM_TIMEOUT_SECONDS
72#define USHER_AI_CAM_TIMEOUT_SECONDS 30
73#endif
74#ifndef USHER_AI_CAM_RETRY_MS
75#define USHER_AI_CAM_RETRY_MS 30000
76#endif
77
83
84extern char **environ;
86static pid_t child_pid = -1;
87static int watch_fd = -1;
88static unsigned session_number;
89static int64_t ready_ms;
90static int64_t retry_ms;
91static unsigned failures;
92static bool signal_zsl;
93static bool zsl_failed;
94static bool timing_enabled;
95static bool native_enabled;
98static char signal_prefix[80];
99
100/** @brief Read the child supervision clock.
101 * @return Monotonic milliseconds, or zero on clock failure.
102 * @details Use elapsed time rather than calendar time for startup and shutdown. */
103static int64_t monotonic_ms(void)
104{
105 struct timespec now;
106 if (clock_gettime(CLOCK_MONOTONIC, &now) != 0) return 0;
107 return (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000;
108}
109
110/** @brief Wait until a short polling interval elapses.
111 * @param milliseconds Requested wait in milliseconds.
112 * @details After interruption, recompute the remaining budget instead of
113 * restarting the full delay. */
114static void wait_ms(int milliseconds)
115{
116 const int64_t deadline = monotonic_ms() + milliseconds;
117 int64_t remaining;
118 while ((remaining = deadline - monotonic_ms()) > 0) {
119 if (poll(NULL, 0, remaining > INT_MAX ? INT_MAX : (int)remaining) >= 0 || errno != EINTR) break;
120 }
121}
122
123/** @brief Poll the owned child and reap it if it exited.
124 * @param[out] status Optional wait status; use only when waitpid reports exit.
125 * @return True while the child remains owned.
126 * @details Clear the PID only after reaping or ECHILD. Other wait errors
127 * leave ownership intact rather than allowing a second camera process. */
128static bool child_alive(int *status)
129{
130 if (child_pid <= 0) return false;
131 pid_t result;
132 do {
133 result = waitpid(child_pid, status, WNOHANG);
134 } while (result < 0 && errno == EINTR);
135 if (result == 0 || (result < 0 && errno != ECHILD)) return true;
136 child_pid = -1;
137 return false;
138}
139
140/** @brief Give the owned child a bounded interval to exit.
141 * @param milliseconds Supervision budget in milliseconds.
142 * @return True once no child is owned; false on timeout.
143 * @details Poll so a driver that does not return cannot block a waitpid call. */
144static bool wait_child(int milliseconds)
145{
146 const int64_t deadline = monotonic_ms() + milliseconds;
147 while (child_alive(NULL)) {
148 if (monotonic_ms() >= deadline) return false;
149 wait_ms(10);
150 }
151 return true;
152}
153
154/** @brief Request shutdown and escalate if the camera child does not exit.
155 * @return True when no child remains owned.
156 * @details Use the persistent application's signal protocol when its
157 * watch is active. Retain the PID if even forced termination cannot be reaped. */
158static bool stop_child(void)
159{
160 if (!child_alive(NULL)) return true;
161 kill(child_pid, watch_fd >= 0 ? SIGUSR2 : SIGTERM);
162 if (wait_child(1000)) return true;
163 kill(child_pid, SIGKILL);
164 if (wait_child(1000)) return true;
165 fprintf(stderr, "AI_CAM_PIPE:\tchild %ld has not exited; camera remains owned\n", (long)child_pid);
166 return false;
167}
168
169/** @brief Retire the subprocess and its directory watch.
170 * @return True if subprocess ownership was released.
171 * @details Close the watch even after a timeout; subsequent starts must
172 * still resolve the retained child PID before opening the camera. */
173static bool persistent_stop(void)
174{
175 const bool stopped = stop_child();
176 if (watch_fd >= 0) close(watch_fd);
177 watch_fd = -1;
178 return stopped;
179}
180
181/** @brief Resolve the default persistent capture policy against the one-shot override.
182 * @return True if the build enables persistence and the environment does not opt out.
183 * @details An unset, empty, or zero one-shot override retains persistent mode. */
184static bool persistent_enabled(void)
185{
186 const char *oneshot = getenv("USHER_AI_CAM_ONESHOT");
187 return USHER_AI_CAM_PERSISTENT && (!oneshot || !*oneshot || !strcmp(oneshot, "0"));
188}
189
190/** @brief Check whether the next persistent child may use zero shutter lag.
191 * @return True unless configuration or a previous ZSL failure disabled it.
192 * @details Retain the failure latch across child restarts so recovery need
193 * not repeat the same launch mode. */
194static bool zsl_enabled(void)
195{
196 const char *configured = getenv("USHER_AI_CAM_ZSL");
197 return !zsl_failed && (!configured || strcmp(configured, "0"));
198}
199
200/** @brief Reserve a private filename prefix for a camera child.
201 * @param directory Existing output directory.
202 * @return True if both path components fit and the counter did not wrap.
203 * @details Include both process ID and session counter so a late event from
204 * an earlier child is not accepted as a current capture. */
205static bool new_session(const char *directory)
206{
207 if (session_number == UINT_MAX) return false;
209 const int directory_length = snprintf(signal_directory, sizeof(signal_directory), "%s", directory);
210 const int prefix_length = snprintf(signal_prefix, sizeof(signal_prefix), ".aicam_%ld_%u_",
211 (long)getpid(), session_number);
212 return directory_length > 0 && (size_t)directory_length < sizeof(signal_directory)
213 && prefix_length > 0 && (size_t)prefix_length < sizeof(signal_prefix);
214}
215
216/** @brief Launch the configured camera application and record ownership.
217 * @param arguments Null-terminated argument vector, including argv[0].
218 * @return Zero on launch, or -1 on spawn failure.
219 * @details Pass arguments directly rather than interpreting paths as shell input.
220 * A successful spawn does not prove that the camera is ready. */
221static int spawn_camera(char *const arguments[])
222{
223 const int result = posix_spawnp(&child_pid, USHER_AI_CAM_COMMAND, NULL, NULL, arguments, environ);
224 if (result) {
225 child_pid = -1;
226 fprintf(stderr, "AI_CAM_PIPE:\tcannot start %s: %s\n", USHER_AI_CAM_COMMAND, strerror(result));
227 return -1;
228 }
229 return 0;
230}
231
232/** @brief Start the signal-triggered camera application.
233 * @param directory Existing output directory to watch and write.
234 * @return Zero after launch, or -1 on ownership, watch, path, or spawn failure.
235 * @details Attach the watch before launch to avoid missing completion events.
236 * Record a warmup deadline; the first trigger waits for it outside startup. */
237static int persistent_start(const char *directory)
238{
239 if (!persistent_stop() || !new_session(directory)) return -1;
240 watch_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
241 if (watch_fd < 0 || inotify_add_watch(watch_fd, directory, IN_CLOSE_WRITE | IN_MOVED_TO) < 0) {
243 return -1;
244 }
245 char pattern[PATH_MAX];
246 const int length = snprintf(pattern, sizeof(pattern), "%s/%s%%06d.jpg", directory, signal_prefix);
247 if (length < 0 || (size_t)length >= sizeof(pattern)) {
249 return -1;
250 }
251 char *arguments[20] = {
252 (char *)USHER_AI_CAM_COMMAND, (char *)"-n", (char *)"-t", (char *)"0",
253 (char *)"--signal", (char *)"-o", pattern,
254 (char *)"--width", (char *)USHER_AI_CAM_WIDTH,
255 (char *)"--height", (char *)USHER_AI_CAM_HEIGHT
256 };
257 size_t count = 11;
259 if (signal_zsl) {
260 arguments[count++] = (char *)"--zsl";
261 arguments[count++] = (char *)"--buffer-count";
262 arguments[count++] = (char *)"2";
263 arguments[count++] = (char *)"--viewfinder-width";
264 arguments[count++] = (char *)"640";
265 arguments[count++] = (char *)"--viewfinder-height";
266 arguments[count++] = (char *)"480";
267 }
268 arguments[count] = NULL;
269 if (spawn_camera(arguments)) {
271 return -1;
272 }
274 return 0;
275}
276
277/** @brief Publish a completed private JPEG at the caller's staging path.
278 * @param source Private camera output, required to be nonempty and regular.
279 * @param destination New sibling path; existing files are not replaced.
280 * @return Zero if linked, even if private-name cleanup failed, or -1 if not linked.
281 * @details A hard link makes the complete file visible without copying pixels
282 * or reopening the JPEG for writing. */
283static int publish_image(const char *source, const char *destination)
284{
285 struct stat image;
286 /* Linking the completed private file publishes atomically and refuses overwrite. */
287 if (lstat(source, &image) || !S_ISREG(image.st_mode) || image.st_size <= 0
288 || link(source, destination)) return -1;
289 if (unlink(source)) fprintf(stderr, "AI_CAM_PIPE:\tprivate image retained: %s\n", source);
290 return 0;
291}
292
293/** @brief Request and collect one persistent-child capture.
294 * @param destination New staging path for the completed JPEG.
295 * @return Saved, not triggered, or failed after a trigger may have been delivered.
296 * @details Drain old notifications before signaling. Require a completed event
297 * with the current child's private prefix. Once signaled, an ambiguous outcome
298 * is terminal; replay could duplicate an exposure. */
299static enum capture_result persistent_shoot(const char *destination)
300{
301 if (watch_fd < 0 || !child_alive(NULL)) return CAPTURE_NOT_TRIGGERED;
302 const int64_t remaining = ready_ms - monotonic_ms();
303 if (remaining > 0) wait_ms((int)remaining);
304 if (!child_alive(NULL)) return CAPTURE_NOT_TRIGGERED;
305 _Alignas(struct inotify_event) char buffer[4096];
306 while (read(watch_fd, buffer, sizeof(buffer)) > 0) {}
307 if (kill(child_pid, SIGUSR1)) return CAPTURE_NOT_TRIGGERED;
308 const int64_t deadline = monotonic_ms() + USHER_AI_CAM_SIGNAL_TIMEOUT_MS;
309 while (monotonic_ms() < deadline) {
310 struct pollfd watch = {.fd = watch_fd, .events = POLLIN};
311 const int result = poll(&watch, 1, 20);
312 if (result < 0 && errno != EINTR) break;
313 if (result > 0 && (watch.revents & POLLIN)) {
314 const ssize_t length = read(watch_fd, buffer, sizeof(buffer));
315 size_t offset = 0;
316 while (length > 0 && offset + sizeof(struct inotify_event) <= (size_t)length) {
317 const struct inotify_event *event = (const struct inotify_event *)(buffer + offset);
318 const size_t event_size = sizeof(*event) + event->len;
319 if (event_size > (size_t)length - offset) break;
320 offset += event_size;
321 const size_t prefix_length = strlen(signal_prefix);
322 if (!event->len || !memchr(event->name, '\0', event->len)
323 || !(event->mask & (IN_CLOSE_WRITE | IN_MOVED_TO))
324 || strncmp(event->name, signal_prefix, prefix_length)) continue;
325 const char *sequence = event->name + prefix_length;
326 const size_t digits = strspn(sequence, "0123456789");
327 if (!digits || strcmp(sequence + digits, ".jpg")) continue;
328 char source[PATH_MAX];
329 const int source_length = snprintf(source, sizeof(source), "%s/%s", signal_directory, event->name);
330 if (source_length < 0 || (size_t)source_length >= sizeof(source)) return CAPTURE_FAILED;
331 return publish_image(source, destination) ? CAPTURE_FAILED : CAPTURE_SAVED;
332 }
333 }
334 if (!child_alive(NULL)) break;
335 }
336 fprintf(stderr, "AI_CAM_PIPE:\tshot completion ambiguous; no replay, private prefix %s/%s\n",
338 return CAPTURE_FAILED;
339}
340
341/** @brief Capture using a fresh camera subprocess.
342 * @param directory Existing directory for private output.
343 * @param destination New staging path for the completed JPEG.
344 * @return Zero after successful child exit and publication, or -1 on failure.
345 * @details Do not launch until the previous child is reaped. Use an unused
346 * private path and publish only after the child exits successfully. */
347static int oneshot_shoot(const char *directory, const char *destination)
348{
349 if (!persistent_stop() || !new_session(directory)) return -1;
350 char source[PATH_MAX];
351 const int length = snprintf(source, sizeof(source), "%s/%s000000.jpg", directory, signal_prefix);
352 if (length < 0 || (size_t)length >= sizeof(source)) return -1;
353 struct stat existing;
354 if (!lstat(source, &existing) || errno != ENOENT) return -1;
355 char *arguments[] = {
356 (char *)USHER_AI_CAM_COMMAND, (char *)"-o", source,
357 (char *)"--width", (char *)USHER_AI_CAM_WIDTH,
358 (char *)"--height", (char *)USHER_AI_CAM_HEIGHT,
359 (char *)"-t", (char *)"200", (char *)"-n", NULL
360 };
361 if (spawn_camera(arguments)) return -1;
362 const int64_t deadline = monotonic_ms() + (int64_t)USHER_AI_CAM_TIMEOUT_SECONDS * 1000;
363 int status = -1;
364 while (child_alive(&status)) {
365 if (monotonic_ms() >= deadline) {
366 stop_child();
367 fprintf(stderr, "AI_CAM_PIPE:\tone-shot timed out; private image retained if present: %s\n", source);
368 return -1;
369 }
370 wait_ms(20);
371 }
372 if (status < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) return -1;
373 return publish_image(source, destination);
374}
375
376void ai_cam_pipe_set_photo_directory(const char *directory)
377{
378 photo_directory = directory ? directory : USHER_AI_CAM_PHOTO_DIR;
379}
380
382{
383 if (child_pid > 0 || native_capture.pid > 0) return -1;
385 return 0;
386}
387
389{
390 return native_enabled;
391}
392
394{
395 native_capture.running = host ? host->running : NULL;
396}
397
398int ai_cam_pipe_init(const char *unused)
399{
400 (void)unused;
401 if (!persistent_stop()) return -1;
402 failures = 0;
403 retry_ms = 0;
404 zsl_failed = false;
405 const char *timing = getenv("USHER_AI_CAM_TIMING");
406 timing_enabled = timing && !strcmp(timing, "1");
407 char resolved[PATH_MAX];
408 const char *directory = usher_resolve_path(photo_directory, resolved, sizeof(resolved));
409 struct stat storage;
410 if (usher_ensure_directory(directory) || stat(directory, &storage) || !S_ISDIR(storage.st_mode)
411 || access(directory, W_OK)) return -1;
412 if (native_enabled) {
414 native_capture.model = NULL;
415 native_capture.settings = NULL;
416 native_capture.analyze = false;
417 native_capture.photo_only = true;
419 native_capture.prefix = 'a';
420 printf("AI_CAM_PIPE:\tnative command %s, JPEG %sx%s, directory %s\n",
423 }
424 printf("AI_CAM_PIPE:\tsystem command %s, JPEG %sx%s, directory %s\n",
426 if (persistent_enabled()) persistent_start(directory);
427 return 0;
428}
429
430int ai_cam_pipe_shoot(char *filename, size_t filename_size, int image_number)
431{
432 if (native_enabled) return imx500_pipe_shoot(&native_capture, filename, filename_size, image_number);
433 if (!filename || !filename_size) return -1;
434 filename[0] = '\0';
435 if (image_number < 0) return -1;
436 char resolved[PATH_MAX];
437 const char *directory = usher_resolve_path(photo_directory, resolved, sizeof(resolved));
438 const int length = snprintf(filename, filename_size, "%s/a%06d.jpg", directory, image_number);
439 if (length < 0 || (size_t)length >= filename_size || usher_prepare_photo(filename, filename_size) != 0) {
440 filename[0] = '\0';
441 return -1;
442 }
443 const int64_t started = monotonic_ms();
445 const bool persistent = persistent_enabled();
446 if (persistent && started >= retry_ms) {
447 if (child_pid <= 0) persistent_start(directory);
448 result = persistent_shoot(filename);
449 if (result != CAPTURE_SAVED) {
450 if (signal_zsl) zsl_failed = true;
451 if (failures < 2) ++failures;
454 } else {
455 failures = 0;
456 retry_ms = 0;
457 }
458 }
459 /* Only a proven pre-trigger failure permits the one-shot fallback. */
461 result = oneshot_shoot(directory, filename) ? CAPTURE_FAILED : CAPTURE_SAVED;
462 if (persistent && monotonic_ms() >= retry_ms && child_pid <= 0) persistent_start(directory);
463 }
464 if (timing_enabled) fprintf(stderr, "AI_CAM_PIPE TIMING:\tshot=%d capture_total_ms=%lld result=%d\n",
465 image_number, (long long)(monotonic_ms() - started), result);
466 if (result != CAPTURE_SAVED) filename[0] = '\0';
467 return result == CAPTURE_SAVED ? 0 : -1;
468}
469
#define USHER_AI_CAM_HEIGHT
Definition ai_cam_pipe.c:60
static bool zsl_enabled(void)
Check whether the next persistent child may use zero shutter lag.
int ai_cam_pipe_init(const char *unused)
Validate storage and start the selected camera owner.
static const char * photo_directory
Definition ai_cam_pipe.c:85
static bool stop_child(void)
Request shutdown and escalate if the camera child does not exit.
static bool persistent_stop(void)
Retire the subprocess and its directory watch.
static char signal_directory[PATH_MAX]
Definition ai_cam_pipe.c:97
static bool native_enabled
Definition ai_cam_pipe.c:95
int ai_cam_pipe_shoot(char *filename, size_t filename_size, int image_number)
Capture one ordinary JPEG into private staging for metadata completion.
#define USHER_AI_CAM_PHOTO_DIR
Definition ai_cam_pipe.c:54
static bool child_alive(int *status)
Poll the owned child and reap it if it exited.
static bool new_session(const char *directory)
Reserve a private filename prefix for a camera child.
void ai_cam_pipe_configure(const struct camera_backend_host *host)
Pass the shutdown flag to native worker supervision.
#define USHER_AI_CAM_PERSISTENT
Definition ai_cam_pipe.c:63
static void wait_ms(int milliseconds)
Wait until a short polling interval elapses.
static int64_t ready_ms
Definition ai_cam_pipe.c:89
static bool timing_enabled
Definition ai_cam_pipe.c:94
static bool zsl_failed
Definition ai_cam_pipe.c:93
static int persistent_start(const char *directory)
Start the signal-triggered camera application.
void ai_cam_pipe_deinit(void)
Stop the native and system-camera subprocesses.
static int64_t retry_ms
Definition ai_cam_pipe.c:90
static int oneshot_shoot(const char *directory, const char *destination)
Capture using a fresh camera subprocess.
#define USHER_AI_CAM_RETRY_MS
Definition ai_cam_pipe.c:75
#define USHER_AI_CAM_STARTUP_MS
Definition ai_cam_pipe.c:66
bool ai_cam_pipe_native(void)
Report whether the selected AIcam mode uses native photo-only capture.
char ** environ
static unsigned failures
Definition ai_cam_pipe.c:91
static bool signal_zsl
Definition ai_cam_pipe.c:92
static struct imx500_pipe native_capture
Definition ai_cam_pipe.c:96
static bool persistent_enabled(void)
Resolve the default persistent capture policy against the one-shot override.
capture_result
Definition ai_cam_pipe.c:78
@ CAPTURE_SAVED
Definition ai_cam_pipe.c:80
@ CAPTURE_NOT_TRIGGERED
Definition ai_cam_pipe.c:81
@ CAPTURE_FAILED
Definition ai_cam_pipe.c:79
#define USHER_AI_CAM_COMMAND
Definition ai_cam_pipe.c:48
void ai_cam_pipe_set_photo_directory(const char *directory)
Select a borrowed directory before initialization.
int ai_cam_pipe_set_native(bool enabled)
Select native or system-camera capture before startup.
#define USHER_AI_CAM_WIDTH
Definition ai_cam_pipe.c:57
static char signal_prefix[80]
Definition ai_cam_pipe.c:98
static int spawn_camera(char *const arguments[])
Launch the configured camera application and record ownership.
static int64_t monotonic_ms(void)
Read the child supervision clock.
static unsigned session_number
Definition ai_cam_pipe.c:88
static enum capture_result persistent_shoot(const char *destination)
Request and collect one persistent-child capture.
#define USHER_AI_CAM_TIMEOUT_SECONDS
Definition ai_cam_pipe.c:72
static int watch_fd
Definition ai_cam_pipe.c:87
static bool wait_child(int milliseconds)
Give the owned child a bounded interval to exit.
#define USHER_AI_CAM_SIGNAL_TIMEOUT_MS
Definition ai_cam_pipe.c:69
static int publish_image(const char *source, const char *destination)
Publish a completed private JPEG at the caller's staging path.
#define USHER_AI_CAM_NATIVE_COMMAND
Definition ai_cam_pipe.c:51
static pid_t child_pid
Definition ai_cam_pipe.c:86
Parent-side contract for stock and native Raspberry Pi camera capture.
Shared capability and lifecycle contract for USHER camera backends.
void(* close)(struct usbfs_handle *)
Definition chdkbridge.c:57
static uint64_t milliseconds(void)
Read elapsed-time evidence unaffected by changes to civil time.
static bool enabled(void)
Report explicit opt-in independently of process or model readiness.
static bool started
void imx500_pipe_stop(struct imx500_pipe *pipe)
Close the channel, allow an exit grace period, then kill/reap if needed.
int imx500_pipe_shoot(struct imx500_pipe *pipe, char *filename, size_t capacity, int number)
Request one saved photograph and qualify its acknowledgement/file.
int imx500_pipe_start(struct imx500_pipe *pipe)
Replace any owned worker and require its exact READY response.
READY/SHOT/OK process ownership without model-analysis semantics.
#define IMX500_PIPE_INITIALIZER
Safe empty lifecycle state: descriptor zero must never mean uninitialized.
Definition imx500_pipe.h:49
Small path and writable-directory helpers shared by USHER backends.
static int usher_prepare_photo(char *filename, size_t capacity)
Redirect an intended public photo into its same-filesystem private staging directory.
Definition path_utils.h:143
static const char * usher_resolve_path(const char *path, char *buffer, size_t buffer_size)
Expand a leading home-directory shorthand without allocating memory.
Definition path_utils.h:74
#define PATH_MAX
Definition path_utils.h:39
static int usher_ensure_directory(const char *path)
Create missing directory components and verify the final directory is writable.
Definition path_utils.h:97
static size_t count
Definition pose_log.c:79
const volatile sig_atomic_t * running
Borrowed shutdown flag; backend workers must stop when it clears.
One caller-serialized native worker and its borrowed configuration.
Definition imx500_pipe.h:35
struct usher_control_result result
Definition usher.c:377
struct captured_image image
Definition usher.c:371