Files
Hodor/main/cam_stream.h
T
Aida_Lashkari 72a2d714ab Add : RTSP audio/video with back channel, and auth
- cam_stream: shared JPEG feed for /pic, /stream and RTSP; RTSP server
  (port 554, TCP) with MJPEG video, G.711 mic audio and an ONVIF-style
  back channel to the speaker
- cam_auth: RTSP Digest login and HTTP Basic / ?key= check on all endpoints
- Mic task feeds HTTP and RTSP with a sticky channel choice
2026-10-08 14:12:48 +03:30

41 lines
1.6 KiB
C

#pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#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