mirror of
https://github.com/arkhipenko/esp32-mjpeg-multiclient-espcam-drivers.git
synced 2025-01-08 17:11:22 +01:00
Code cleanup
This commit is contained in:
parent
3b0ee3a704
commit
ea7a76a216
5 changed files with 10 additions and 41 deletions
|
@ -2,6 +2,9 @@
|
||||||
// ==== includes =================================
|
// ==== includes =================================
|
||||||
#include "references.h"
|
#include "references.h"
|
||||||
|
|
||||||
|
#define MILLIS_FUNCTION xTaskGetTickCount()
|
||||||
|
// #define MILLIS_FUNCTION millis()
|
||||||
|
|
||||||
// ==== prototypes ===============================
|
// ==== prototypes ===============================
|
||||||
void setupLogging();
|
void setupLogging();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ void setupLogging() {
|
||||||
// === millis() - based timestamp ==
|
// === millis() - based timestamp ==
|
||||||
void printTimestamp(Print* logOutput) {
|
void printTimestamp(Print* logOutput) {
|
||||||
char c[24];
|
char c[24];
|
||||||
sprintf(c, "%10lu ", (long unsigned int) xTaskGetTickCount()/*millis()*/);
|
sprintf(c, "%10lu ", (long unsigned int) MILLIS_FUNCTION);
|
||||||
logOutput->print(c);
|
logOutput->print(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ void printTimestamp(Print* logOutput) {
|
||||||
// start-time-based timestamp ========
|
// start-time-based timestamp ========
|
||||||
void printTimestampMillis(Print* logOutput) {
|
void printTimestampMillis(Print* logOutput) {
|
||||||
char c[64];
|
char c[64];
|
||||||
unsigned long mm = xTaskGetTickCount();//millis();
|
unsigned long mm = MILLIS_FUNCTION;
|
||||||
int ms = mm % 1000;
|
int ms = mm % 1000;
|
||||||
int s = mm / 1000;
|
int s = mm / 1000;
|
||||||
int m = s / 60;
|
int m = s / 60;
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This is a simple MJPEG streaming webserver implemented for AI-Thinker ESP32-CAM
|
This is a MJPEG streaming webserver implemented for AI-Thinker ESP32-CAM
|
||||||
and ESP-EYE modules.
|
and ESP-EYE modules.
|
||||||
This is tested to work with VLC and Blynk video widget and can support up to 10
|
This is tested to work with VLC and Blynk video widget and can support up to 10
|
||||||
simultaneously connected streaming clients.
|
simultaneously connected streaming clients.
|
||||||
Simultaneous streaming is implemented with dedicated FreeRTOS tasks.
|
Simultaneous streaming is implemented with FreeRTOS tools: queue and tasks.
|
||||||
|
|
||||||
Inspired by and based on this Instructable: $9 RTSP Video Streamer Using the ESP32-CAM Board
|
Inspired by and based on this Instructable: $9 RTSP Video Streamer Using the ESP32-CAM Board
|
||||||
(https://www.instructables.com/id/9-RTSP-Video-Streamer-Using-the-ESP32-CAM-Board/)
|
(https://www.instructables.com/id/9-RTSP-Video-Streamer-Using-the-ESP32-CAM-Board/)
|
||||||
|
|
||||||
Board: AI-Thinker ESP32-CAM or ESP-EYE
|
|
||||||
Compile as:
|
|
||||||
ESP32 Dev Module
|
|
||||||
CPU Freq: 240
|
|
||||||
Flash Freq: 80
|
|
||||||
Flash mode: QIO
|
|
||||||
Flash Size: 4Mb
|
|
||||||
Partrition: Minimal SPIFFS
|
|
||||||
PSRAM: Enabled
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
|
@ -44,11 +35,6 @@ const char *c_pwd = AP_PWD;
|
||||||
// Camera models overview:
|
// Camera models overview:
|
||||||
// https://randomnerdtutorials.com/esp32-cam-camera-pin-gpios/
|
// https://randomnerdtutorials.com/esp32-cam-camera-pin-gpios/
|
||||||
|
|
||||||
// #define CAMERA_MODEL_WROVER_KIT
|
|
||||||
// #define CAMERA_MODEL_ESP_EYE
|
|
||||||
// #define CAMERA_MODEL_M5STACK_PSRAM
|
|
||||||
// #define CAMERA_MODEL_M5STACK_WIDE
|
|
||||||
// #define CAMERA_MODEL_AI_THINKER
|
|
||||||
|
|
||||||
#include "camera_pins.h"
|
#include "camera_pins.h"
|
||||||
|
|
||||||
|
@ -56,11 +42,11 @@ WebServer server(80);
|
||||||
|
|
||||||
// ===== rtos task handles =========================
|
// ===== rtos task handles =========================
|
||||||
// Streaming is implemented with tasks:
|
// Streaming is implemented with tasks:
|
||||||
TaskHandle_t tMjpeg; // handles client connections to the webserver
|
TaskHandle_t tMjpeg; // handles client connections to the webserver
|
||||||
TaskHandle_t tCam; // handles getting picture frames from the camera and storing them locally
|
TaskHandle_t tCam; // handles getting picture frames from the camera and storing them locally
|
||||||
TaskHandle_t tStream;
|
TaskHandle_t tStream;
|
||||||
|
|
||||||
uint8_t noActiveClients; // number of active clients
|
uint8_t noActiveClients; // number of active clients
|
||||||
|
|
||||||
// frameSync semaphore is used to prevent streaming buffer as it is replaced with the next frame
|
// frameSync semaphore is used to prevent streaming buffer as it is replaced with the next frame
|
||||||
SemaphoreHandle_t frameSync = NULL;
|
SemaphoreHandle_t frameSync = NULL;
|
||||||
|
@ -119,22 +105,6 @@ void setup()
|
||||||
.ledc_timer = LEDC_TIMER_0,
|
.ledc_timer = LEDC_TIMER_0,
|
||||||
.ledc_channel = LEDC_CHANNEL_0,
|
.ledc_channel = LEDC_CHANNEL_0,
|
||||||
.pixel_format = PIXFORMAT_JPEG,
|
.pixel_format = PIXFORMAT_JPEG,
|
||||||
/*
|
|
||||||
FRAMESIZE_96X96, // 96x96
|
|
||||||
FRAMESIZE_QQVGA, // 160x120
|
|
||||||
FRAMESIZE_QCIF, // 176x144
|
|
||||||
FRAMESIZE_HQVGA, // 240x176
|
|
||||||
FRAMESIZE_240X240, // 240x240
|
|
||||||
FRAMESIZE_QVGA, // 320x240
|
|
||||||
FRAMESIZE_CIF, // 400x296
|
|
||||||
FRAMESIZE_HVGA, // 480x320
|
|
||||||
FRAMESIZE_VGA, // 640x480
|
|
||||||
FRAMESIZE_SVGA, // 800x600
|
|
||||||
FRAMESIZE_XGA, // 1024x768
|
|
||||||
FRAMESIZE_HD, // 1280x720
|
|
||||||
FRAMESIZE_SXGA, // 1280x1024
|
|
||||||
FRAMESIZE_UXGA, // 1600x1200
|
|
||||||
*/
|
|
||||||
.frame_size = FRAME_SIZE,
|
.frame_size = FRAME_SIZE,
|
||||||
.jpeg_quality = JPEG_QUALITY,
|
.jpeg_quality = JPEG_QUALITY,
|
||||||
.fb_count = 2,
|
.fb_count = 2,
|
||||||
|
@ -202,6 +172,5 @@ void setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// vTaskDelay(1000);
|
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ void camCB(void* pvParameters) {
|
||||||
|
|
||||||
// Grab a frame from the camera and allocate frame chunk for it
|
// Grab a frame from the camera and allocate frame chunk for it
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
// frameChunck_t* f = (frameChunck_t*) ps_malloc( sizeof(frameChunck_t) );
|
|
||||||
frameChunck_t* f = (frameChunck_t*) allocateMemory(NULL, sizeof(frameChunck_t), true);
|
frameChunck_t* f = (frameChunck_t*) allocateMemory(NULL, sizeof(frameChunck_t), true);
|
||||||
if ( f ) {
|
if ( f ) {
|
||||||
// char* d = (char*) ps_malloc( fb->len );
|
// char* d = (char*) ps_malloc( fb->len );
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
#if defined(CAMERA_MULTICLIENT_QUEUE)
|
#if defined(CAMERA_MULTICLIENT_QUEUE)
|
||||||
|
|
||||||
// frameChunck_t frameChunck;
|
|
||||||
// streamInfo_t streamInfo;
|
|
||||||
QueueHandle_t streamingClients;
|
QueueHandle_t streamingClients;
|
||||||
|
|
||||||
volatile size_t camSize; // size of the current frame, byte
|
volatile size_t camSize; // size of the current frame, byte
|
||||||
|
|
Loading…
Reference in a new issue