#pragma once #include #include #include #include "esp_err.h" #ifdef __cplusplus extern "C" { #endif /* ---------- Shared JPEG feed ---------- * One task captures + converts to JPEG, only while at least one viewer exists. */ esp_err_t cam_feed_start(void); /* call after esp_camera_init() */ void cam_feed_viewer_add(uint32_t *seq); /* register a viewer, *seq = "last seen" marker */ void cam_feed_viewer_remove(void); /* Copies the newest frame (newer than *seq) into *buf (realloc'd, size in *cap). * Returns JPEG length, or 0 on timeout. Caller frees *buf when done. */ size_t cam_feed_wait(uint8_t **buf, size_t *cap, uint32_t *seq, uint32_t timeout_ms); /* ---------- Audio feed for RTSP ---------- * The mic task calls cam_audio_push() with every block of mono 16 kHz / 16-bit PCM, * but only needs to do the work while cam_audio_wanted() is true. */ bool cam_audio_wanted(void); void cam_audio_push(const int16_t *pcm, size_t samples); /* ---------- Back channel (client -> speaker) ---------- * Register a function that plays mono 16 kHz / 16-bit PCM on the speaker. * Call before rtsp_server_start(). Without it the back channel is not offered. */ typedef void (*cam_speaker_sink_t)(const int16_t *pcm16k_mono, size_t samples); void rtsp_set_speaker_sink(cam_speaker_sink_t fn); /* ---------- RTSP server (port 554, TCP-interleaved) ---------- * Video: RTP/JPEG (MJPEG). Audio: G.711 / L16, see RTSP_AUDIO_FORMAT in cam_stream.c */ esp_err_t rtsp_server_start(void); #ifdef __cplusplus } #endif