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
This commit is contained in:
2026-10-08 14:12:48 +03:30
parent 00278119b6
commit 72a2d714ab
13 changed files with 1398 additions and 175 deletions
+1 -80
View File
@@ -1,82 +1,3 @@
// #include "sdkconfig.h"
// #include <esp_log.h>
// #include <esp_system.h>
// #include "esp_http_server.h"
// #include <nvs_flash.h>
// #include <sys/param.h>
// #include <string.h>
// #include "freertos/FreeRTOS.h"
// #include "freertos/task.h"
// #include "esp_wifi.h"
// #include "nvs_flash.h"
// #include "esp_netif.h"
// #include "esp_http_server.h"
// #include "lwip/sockets.h"
// #include <netinet/tcp.h>
// #include "board.h"
// static const char *TAG = "WIFI:";
// static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
// if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
// esp_wifi_connect();
// } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
// ESP_LOGW(TAG, "Wi-Fi disconnected. Retrying...");
// esp_wifi_connect();
// } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
// ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
// ESP_LOGI(TAG, "SUCCESS! Got IP: " IPSTR, IP2STR(&event->ip_info.ip));
// }
// }
// void start_wifi_and_server(void) {
// esp_err_t ret = nvs_flash_init();
// if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// nvs_flash_erase();
// nvs_flash_init();
// }
// esp_netif_init();
// esp_event_loop_create_default();
// esp_netif_create_default_wifi_sta();
// wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
// esp_wifi_init(&cfg);
// wifi_config_t wifi_config = {
// .sta = {
// .ssid = "viratak-lte",
// .password = "mydlinkviratak",
// },
// };
// esp_wifi_set_mode(WIFI_MODE_STA);
// esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
// esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL);
// esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, NULL);
// esp_wifi_start();
// esp_wifi_set_ps(WIFI_PS_NONE);
// esp_wifi_connect();
// httpd_config_t config = HTTPD_DEFAULT_CONFIG();
// httpd_handle_t server = NULL;
// if (httpd_start(&server, &config) == ESP_OK) {
// httpd_uri_t uri_capture = {
// .uri = "/pic",
// .method = HTTP_GET,
// .handler = capture_handler,
// .user_ctx = NULL
// };
// httpd_register_uri_handler(server, &uri_capture);
// httpd_uri_t uri_stream = {
// .uri = "/stream",
// .method = HTTP_GET,
// .handler = stream_handler,
// .user_ctx = NULL
// };
// httpd_register_uri_handler(server, &uri_stream);
// }
// }
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -301,7 +222,7 @@ static void start_portal_webserver(void)
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.server_port = 80;
config.stack_size = 8192;
config.lru_purge_enable = true; /* phones open many short connections */
config.lru_purge_enable = true;
if (httpd_start(&s_portal_server, &config) != ESP_OK) {
ESP_LOGE(TAG, "Portal HTTP server failed to start");