From 86ae9af5743b90297d1cc3a992bf03200f406e8b Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Tue, 19 Mar 2024 13:45:22 +0100 Subject: [PATCH] WIP --- include/settings.h | 6 ++++++ lib/micro-jpg/src/jpg.cpp | 1 - .../include/micro_rtsp_streamer.h | 2 +- .../src/micro_rtsp_streamer.cpp | 20 +++++++++---------- platformio.ini | 3 ++- src/main.cpp | 3 +++ 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/include/settings.h b/include/settings.h index 9422efa..cf997cb 100644 --- a/include/settings.h +++ b/include/settings.h @@ -9,6 +9,12 @@ #define OTA_PASSWORD "ESP32CAM-RTSP" +// Time servers +#define NTP_SERVER_1 "nl.pool.ntp.org" +#define NTP_SERVER_2 "europe.pool.ntp.org" +#define NTP_SERVER_3 "time.nist.gov" +#define NTP_SERVERS NTP_SERVER_1, NTP_SERVER_2, NTP_SERVER_3 + #define RTSP_PORT 554 #define DEFAULT_FRAME_DURATION 200 diff --git a/lib/micro-jpg/src/jpg.cpp b/lib/micro-jpg/src/jpg.cpp index 9fa9a40..cb58f2d 100644 --- a/lib/micro-jpg/src/jpg.cpp +++ b/lib/micro-jpg/src/jpg.cpp @@ -83,7 +83,6 @@ bool jpg::decode(const uint8_t *data, size_t size) return false; } - jpeg_data_size = ptr; log_d("Total jpeg data = %d bytes", jpeg_data_end - jpeg_data_start); return true; diff --git a/lib/micro-rtsp-server/include/micro_rtsp_streamer.h b/lib/micro-rtsp-server/include/micro_rtsp_streamer.h index 80e3cfc..10fd18d 100644 --- a/lib/micro-rtsp-server/include/micro_rtsp_streamer.h +++ b/lib/micro-rtsp-server/include/micro_rtsp_streamer.h @@ -7,7 +7,7 @@ class micro_rtsp_streamer { public: micro_rtsp_streamer(); - void create_jpg_packet(const jpg jpg, uint32_t timestamp); + size_t create_jpg_packet(const uint8_t *jpg, const uint8_t *jpg_end, uint32_t timestamp); private : uint32_t ssrc_; diff --git a/lib/micro-rtsp-server/src/micro_rtsp_streamer.cpp b/lib/micro-rtsp-server/src/micro_rtsp_streamer.cpp index f411be7..bc54019 100644 --- a/lib/micro-rtsp-server/src/micro_rtsp_streamer.cpp +++ b/lib/micro-rtsp-server/src/micro_rtsp_streamer.cpp @@ -1,6 +1,6 @@ #include "micro_rtsp_streamer.h" -#include "rtp_payloads.h" +//#include "rtp_payloads.h" #include @@ -11,13 +11,13 @@ // RTP data header (http://www.ietf.org/rfc/rfc3550.txt) struct rtp_hdr { - uint version : 2; // protocol version - uint p : 1; // padding flag - uint x : 1; // header extension flag - uint cc : 4; // CSRC count - uint m : 1; // marker bit - uint pt : 7; // payload type - uint seq : 16; // sequence number + uint16_t version : 2; // protocol version + uint16_t p : 1; // padding flag + uint16_t x : 1; // header extension flag + uint16_t cc : 4; // CSRC count + uint16_t m : 1; // marker bit + uint16_t pt : 7; // payload type + uint16_t seq : 16; // sequence number uint32_t ts; // timestamp uint32_t ssrc; // synchronization source uint32_t csrc[]; // optional CSRC list @@ -30,8 +30,8 @@ struct rtp_hdr struct jpeghdr { - uint322_t tspec : 8; // type-specific field - uint322_t off : 24; // fragment byte offset + uint32_t tspec : 8; // type-specific field + uint32_t off : 24; // fragment byte offset uint8_t type; // id of jpeg decoder params uint8_t q; // quantization factor (or table id) uint8_t width; // frame width in 8 pixel blocks diff --git a/platformio.ini b/platformio.ini index 6560934..7a4992b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,7 +58,8 @@ board_build.embed_txtfiles = lib_deps = prampec/IotWebConf@^3.2.1 geeksville/Micro-RTSP@^0.1.6 - rzeldent/micro-moustache@^1.0.1 + rzeldent/micro-moustache + rzeldent/micro-timezonedb [env:esp32cam_ai_thinker] board = esp32cam_ai_thinker diff --git a/src/main.cpp b/src/main.cpp index 34c6008..481c36a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -392,6 +392,9 @@ void setup() #endif iotWebConf.init(); + // Set the time servers + configTime(0, 0, NTP_SERVERS); + // Try to initialize 3 times for (auto i = 0; i < 3; i++) {