Files
daedalus-v4l2/daemon/src/chardev_client.h
T

66 lines
1.9 KiB
C

/* SPDX-License-Identifier: BSD-2-Clause */
/*
* chardev_client.h — kernel-bridge client for the daedalus-v4l2 daemon.
*
* Opens /dev/daedalus-v4l2, runs a blocking read() / write() loop,
* and invokes the daemon's REQ_* handlers. Phase 8.4 understands
* REQ_DECODE; future phases extend the dispatch table.
*/
#ifndef DAEDALUS_V4L2_CHARDEV_CLIENT_H
#define DAEDALUS_V4L2_CHARDEV_CLIENT_H
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include "daedalus_v4l2_proto.h"
struct ffmpeg_loader;
struct daedalus_decoder;
/**
* struct chardev_client - daemon-side chardev state
* @fd: open /dev/daedalus-v4l2 descriptor (-1 if not open)
* @loader: dlopen'd FFmpeg loader (borrowed; not owned)
* @decoder: per-codec AVCodecContext cache (owned)
* @stop_flag: set non-zero from a signal handler to break the loop
*/
struct chardev_client {
int fd;
struct ffmpeg_loader *loader;
struct daedalus_decoder *decoder;
volatile sig_atomic_t *stop_flag;
};
/**
* chardev_client_open - open /dev/daedalus-v4l2 O_RDWR
*
* @cli: caller-allocated; cleared on entry
* @loader: borrowed FFmpeg loader (must outlive the client)
* @stop_flag: pointer the signal handler sets to ask the loop to stop
*
* Return: 0 on success; negative errno on failure.
*/
int chardev_client_open(struct chardev_client *cli,
struct ffmpeg_loader *loader,
volatile sig_atomic_t *stop_flag);
/**
* chardev_client_run - blocking event loop
*
* Reads one message at a time, dispatches to the matching
* handler, writes the corresponding response. Returns when
* *@stop_flag is set, on chardev EOF, or on an unrecoverable
* error.
*
* Return: 0 on clean shutdown; negative errno on a fatal error.
*/
int chardev_client_run(struct chardev_client *cli);
/**
* chardev_client_close - close the chardev and free decoder state
*/
void chardev_client_close(struct chardev_client *cli);
#endif /* DAEDALUS_V4L2_CHARDEV_CLIENT_H */