// stream_session.h — time-boxed MJPEG push (SPEC C9). // // WHAT IS BUILT // The full path: a `stream_start` command opens a chunked POST to the Pi, the // device pushes JPEGs at the configured rate and resolution, and the session // ends itself at the duration cap. Mode (watch / record / both) rides in a // header; what the Pi does with the bytes is the Pi's decision, so the device // never needs to change when you add recording or a public relay. // // WHAT IS NOT BUILT // Anything outward-facing. Per SPEC C3 the ESP32 never serves a stream and is // never reachable from outside the LAN; relaying to a browser or to a public // domain is the Pi's job (MediaMTX, or plain MJPEG passthrough). // // INTERACTION WITH DEEP SLEEP // A session holds INHIBIT_STREAM, so the device cannot sleep underneath it. // In SLEEP mode a stream_start command is only seen at the next wake; the // device then serves the session and sleeps once it ends. That latency is // inherent (SPEC C1), not a gap in the implementation. #pragma once #include bool streamActive(); // Start a session. `session_id` comes from the endpoint so both sides agree on // a name for it. Overrides are optional: 0 means "use the configured value". bool streamStart(const char* session_id, uint8_t mode_override = 0xFF, uint8_t framesize_override = 0, uint16_t duration_override = 0); // Pump one frame if it is time. Call from the main loop; cheap when idle. // Ends the session automatically at the duration cap. void streamTick(); void streamStop(const char* reason); uint32_t streamFramesSent(); uint32_t streamSecondsLeft();