Skip to content

Commit 4dc36fb

Browse files
committed
Work in progress
1 parent 4b50b52 commit 4dc36fb

File tree

12 files changed

+208
-204
lines changed

12 files changed

+208
-204
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ There are a lot of boards available that are all called ESP32-CAM.
9797
However, there are differences in CPU (type/speed/cores), how the camera is connected, presence of PSRAM or not...
9898
To select the right board use the table below and use the configuration that is listed below for your board:
9999

100-
| Board | Image | CPU | SRAM | Flash | PSRAM | Camera | | Site |
100+
| Board | Image | CPU | SRAM | Flash | PSRAM | Camera | Extras | Manufacturer site |
101101
|--- |--- |--- |--- |--- | --- |--- |--- |--- |
102102
| Espressif ESP32-Wrover CAM | ![img](assets/boards/esp32-wrover-cam.jpg) | ESP32 | 520KB | 4Mb | 4MB | OV2640 | | |
103103
| AI-Thinker ESP32-CAM | ![img](assets/boards/ai-thinker-esp32-cam-ipex.jpg) ![img](assets/boards/ai-thinker-esp32-cam.jpg) | ESP32-S | 520KB | 4Mb | 4MB | OV2640 | | [https://docs.ai-thinker.com/esp32-cam](https://docs.ai-thinker.com/esp32-cam) |

dotnet_riscv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 70e3cb657b88224d7d98e0aa8d0d8f7f9ed5c288

lib/micro-rtsp-server/include/micro_rtsp_camera.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22

3+
#include <micro_rtsp_source.h>
34
#include <esp_camera.h>
45

5-
class micro_rtsp_camera
6+
class micro_rtsp_camera : public micro_rtsp_source
67
{
78
public:
89
micro_rtsp_camera();
@@ -11,12 +12,12 @@ class micro_rtsp_camera
1112
esp_err_t initialize(camera_config_t *camera_config);
1213
esp_err_t deinitialize();
1314

14-
void update_frame();
15+
virtual void update_frame();
1516

16-
uint8_t *data() const { return fb_->buf; }
17-
size_t width() const { return fb_->width; }
18-
size_t height() const { return fb_->height; }
19-
size_t size() const { return fb_->len; }
17+
virtual uint8_t *data() const { return fb_->buf; }
18+
virtual size_t width() const { return fb_->width; }
19+
virtual size_t height() const { return fb_->height; }
20+
virtual size_t size() const { return fb_->len; }
2021

2122
private:
2223
esp_err_t init_result_;

lib/micro-rtsp-server/include/micro_rtsp_requests.h

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <map>
34
#include <string>
45

56
class micro_rtsp_requests
@@ -8,40 +9,41 @@ class micro_rtsp_requests
89
std::string process_request(const std::string& request);
910

1011
private:
11-
enum rtsp_command
12-
{
13-
rtsp_command_unknown,
14-
rtsp_command_option, // OPTIONS
15-
rtsp_command_describe, // DESCRIBE
16-
rtsp_command_setup, // SETUP
17-
rtsp_command_play, // PLAY
18-
rtsp_command_teardown // TEARDOWN
19-
};
20-
21-
const char* available_stream_name_ = "mjpeg/1";
22-
23-
rtsp_command parse_command(const std::string &request);
12+
// enum rtsp_command
13+
// {
14+
// rtsp_command_unknown,
15+
// rtsp_command_options, // OPTIONS
16+
// rtsp_command_describe, // DESCRIBE
17+
// rtsp_command_setup, // SETUP
18+
// rtsp_command_play, // PLAY
19+
// rtsp_command_teardown // TEARDOWN
20+
// };
21+
22+
static const std::string available_stream_name_;
23+
24+
//rtsp_command parse_command(const std::string &request);
25+
//static bool parse_cseq(const std::string &line, unsigned long &cseq);
2426
bool parse_client_port(const std::string &request);
25-
bool parse_cseq(const std::string &request);
26-
bool parse_stream_url(const std::string &request);
27+
//bool parse_stream_url(const std::string &request);
2728

28-
std::string date_header();
29-
std::string rtsp_error(unsigned short code, const std::string& message);
29+
//static std::string date_header();
30+
static std::string handle_rtsp_error(unsigned long cseq, unsigned short code, const std::string &message);
3031

31-
std::string handle_option(const std::string &request);
32-
std::string handle_describe(const std::string &request);
33-
std::string handle_setup(const std::string &request);
34-
std::string handle_play(const std::string &request);
35-
std::string handle_teardown(const std::string &request);
32+
static std::string handle_options(unsigned long cseq);
33+
static std::string handle_describe(unsigned long cseq, const std::string &request);
34+
std::string handle_setup(unsigned long cseq, const std::map<std::string, std::string> &request);
35+
std::string handle_play(unsigned long cseq);
36+
std::string handle_teardown(unsigned long cseq);
3637

37-
unsigned long cseq_;
38+
//unsigned long cseq_;
3839

39-
std::string host_url_;
40-
unsigned short host_port_;
41-
std::string stream_name_;
40+
// std::string host_url_;
41+
// unsigned short host_port_;
42+
// std::string stream_name_;
4243

4344
bool tcp_transport_;
44-
unsigned short client_port_;
45+
unsigned short start_client_port_;
46+
unsigned short end_client_port_;
4547

4648
unsigned short rtp_streamer_port_;
4749
unsigned short rtcp_streamer_port_;

lib/micro-rtsp-server/include/micro_rtsp_server.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
class micro_rtsp_server : WiFiServer
1414
{
1515
public:
16-
micro_rtsp_server(micro_rtsp_camera &source, unsigned frame_interval = 100);
16+
micro_rtsp_server(micro_rtsp_source &source);
1717
~micro_rtsp_server();
1818

1919
void begin(unsigned short port = 554);
2020
void end();
2121

22-
unsigned get_frame_interval() { return frame_interval_; }
22+
unsigned get_frame_interval() const { return frame_interval_; }
2323
unsigned set_frame_interval(unsigned value) { return frame_interval_ = value; }
2424

2525
void loop();
2626

27-
size_t clients() { return clients_.size(); }
27+
size_t clients() const { return clients_.size(); }
2828

2929
class rtsp_client : public WiFiClient, public micro_rtsp_requests
3030
{
@@ -36,7 +36,7 @@ class micro_rtsp_server : WiFiServer
3636
};
3737

3838
private:
39-
micro_rtsp_camera &source_;
39+
micro_rtsp_source &source_;
4040
unsigned frame_interval_;
4141
unsigned long next_frame_update_;
4242
unsigned long next_check_client_;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include <stdint.h>
5+
6+
// Interface for a video source
7+
class micro_rtsp_source
8+
{
9+
public:
10+
virtual void update_frame() = 0;
11+
12+
virtual uint8_t *data() const = 0;
13+
virtual size_t width() const = 0;
14+
virtual size_t height() const = 0;
15+
virtual size_t size() const = 0;
16+
};

lib/micro-rtsp-server/include/micro_rtsp_streamer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22

33
#include <jpg_section.h>
4-
#include <micro_rtp_structs.h>
4+
#include <micro_rtsp_camera.h> // Add this line to include the definition of micro_rtsp_camera
5+
#include <micro_rtsp_structs.h>
56

67
// https://en.wikipedia.org/wiki/Maximum_transmission_unit
78
constexpr size_t max_wifi_mtu = 2304;
@@ -32,11 +33,11 @@ typedef struct __attribute__((packed))
3233
class micro_rtsp_streamer
3334
{
3435
public:
35-
micro_rtsp_streamer(const uint16_t width, const uint16_t height);
36+
micro_rtsp_streamer(const micro_rtsp_source& source);
3637
rtp_over_tcp_hdr_t *create_jpg_packet(const uint8_t *jpg_scan, const uint8_t *jpg_scan_end, uint8_t **jpg_offset, const uint32_t timestamp, const uint8_t *quantization_table_luminance, const uint8_t *quantization_table_chrominance);
3738

3839
private:
39-
uint16_t width_, height_;
40+
const micro_rtsp_source& source_;
4041
uint32_t ssrc_;
4142
uint16_t sequence_number_;
4243
};

lib/micro-rtsp-server/include/micro_rtp_structs.h renamed to lib/micro-rtsp-server/include/micro_rtsp_structs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// https://www.ietf.org/rfc/rfc2326#section-10.12
66
typedef struct __attribute__((packed))
77
{
8-
char magic='$'; // Magic encapsulation ASCII dollar sign (24 hexadecimal)
9-
uint8_t channel; // Channel identifier
10-
uint16_t length; // Network order
8+
char magic = '$'; // Magic encapsulation ASCII dollar sign (24 hexadecimal)
9+
uint8_t channel; // Channel identifier
10+
uint16_t length; // Network order
1111
} rtp_over_tcp_hdr_t;
1212

1313
// RTP data header - http://www.ietf.org/rfc/rfc3550.txt

0 commit comments

Comments
 (0)