Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Feb 10, 2024
1 parent 9ba1116 commit 97fc4ce
Show file tree
Hide file tree
Showing 26 changed files with 590 additions and 30 deletions.
3 changes: 2 additions & 1 deletion boards/esp32cam_ai_thinker.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down
8 changes: 5 additions & 3 deletions boards/esp32cam_espressif_esp32s2_cam_board.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32s2_out.ld"
},
"core": "esp32",
Expand Down Expand Up @@ -31,7 +31,9 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'" ],
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
Expand All @@ -58,4 +60,4 @@
},
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrap-cam-v1.1.html",
"vendor": "Espressif"
}
}
8 changes: 5 additions & 3 deletions boards/esp32cam_espressif_esp32s2_cam_header.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32s2_out.ld"
},
"core": "esp32",
Expand Down Expand Up @@ -31,7 +31,9 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'" ],
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
Expand All @@ -58,4 +60,4 @@
},
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrap-cam-v1.1.html",
"vendor": "Espressif"
}
}
3 changes: 2 additions & 1 deletion boards/esp32cam_espressif_esp32s3_cam_lcd.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
Expand Down
3 changes: 2 additions & 1 deletion boards/esp32cam_espressif_esp32s3_eye.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
Expand Down
7 changes: 4 additions & 3 deletions boards/esp32cam_espressif_esp_eye.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32_out.ld",
"partitions": "huge_app.csv"
},
Expand Down Expand Up @@ -31,7 +31,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=1'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down Expand Up @@ -62,4 +63,4 @@
},
"url": "https://www.espressif.com/en/products/devkits/esp-eye/overview",
"vendor": "Espressif"
}
}
3 changes: 2 additions & 1 deletion boards/esp32cam_freenove_wrover_kit.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down
5 changes: 3 additions & 2 deletions boards/esp32cam_m5stack_camera.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32_out.ld",
"partitions": "huge_app.csv"
},
Expand Down Expand Up @@ -28,6 +28,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=1'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D GROVE_SDA=13'",
"'-D GROVE_SCL=4'"
],
Expand Down Expand Up @@ -60,4 +61,4 @@
},
"url": "https://docs.m5stack.com/en/unit/m5camera",
"vendor": "M5STACK"
}
}
1 change: 1 addition & 0 deletions boards/esp32cam_m5stack_camera_psram.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D GROVE_SDA=13'",
"'-D GROVE_SCL=4'"
],
Expand Down
5 changes: 3 additions & 2 deletions boards/esp32cam_m5stack_esp32cam.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32_out.ld",
"partitions": "huge_app.csv"
},
Expand Down Expand Up @@ -32,6 +32,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D MICROPHONE_GPIO=32'",
"'-D GROVE_SDA=13'",
"'-D GROVE_SCL=4'"
Expand Down Expand Up @@ -65,4 +66,4 @@
},
"url": "https://docs.m5stack.com/en/unit/esp32cam",
"vendor": "M5STACK"
}
}
7 changes: 4 additions & 3 deletions boards/esp32cam_m5stack_unitcam.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32_out.ld",
"partitions": "huge_app.csv"
},
Expand Down Expand Up @@ -29,7 +29,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=1'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down Expand Up @@ -60,4 +61,4 @@
},
"url": "https://docs.m5stack.com/en/unit/unit_cam",
"vendor": "M5STACK"
}
}
3 changes: 2 additions & 1 deletion boards/esp32cam_m5stack_unitcams3.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D I2C_MEMS_SDA=48'",
"'-D I2C_MEMS_SCL=47'",
"'-D TF_CS=9'",
Expand Down Expand Up @@ -80,4 +81,4 @@
},
"url": "https://docs.m5stack.com/en/unit/Unit-CamS3",
"vendor": "M5STACK"
}
}
7 changes: 4 additions & 3 deletions boards/esp32cam_m5stack_wide.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32_out.ld",
"partitions": "huge_app.csv"
},
Expand Down Expand Up @@ -29,7 +29,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down Expand Up @@ -60,4 +61,4 @@
},
"url": "https://shop.m5stack.com/collections/m5-cameras",
"vendor": "M5STACK"
}
}
3 changes: 2 additions & 1 deletion boards/esp32cam_seeed_xiao_esp32s3_sense.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=2'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D I2C_MEMS_SDA=41'",
"'-D I2C_MEMS_SCL=42'",
"'-D TF_CS=21'",
Expand Down Expand Up @@ -80,4 +81,4 @@
},
"url": "https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html",
"vendor": "Seeed Studio"
}
}
1 change: 1 addition & 0 deletions boards/esp32cam_ttgo_t_camera.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=1'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'",
"'-D LCD_SSD1306_PIN_SDA=21'",
"'-D LCD_SSD1306_PIN_SCL=22'",
"'-D BUTTON_RIGHT_PIN=34'",
Expand Down
3 changes: 2 additions & 1 deletion boards/esp32cam_ttgo_t_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"'-D CAMERA_CONFIG_LEDC_TIMER=LEDC_TIMER_0'",
"'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'",
"'-D CAMERA_CONFIG_FB_COUNT=1'",
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'"
"'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'",
"'-D CAMERA_CONFIG_SCCB_I2C_PORT=I2C_NUM_0'"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
Expand Down
74 changes: 74 additions & 0 deletions lib/micro-rtsp-server/include/micro_rtsp_server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#pragma once

#include <WiFiServer.h>
#include <micro_rtsp_source.h>
#include <vector>
#include <list>

class micro_rtsp_server : public WiFiServer
{
public:
micro_rtsp_server(micro_rtsp_source *source, unsigned frame_interval = 100, unsigned short port = 554);
~micro_rtsp_server();

void loop();

unsigned get_frame_interval() { return frame_interval_; }
unsigned set_frame_interval(unsigned value) { return frame_interval_ = value; }

size_t clients() { return clients_.size(); }

class rtsp_client
{
public:
rtsp_client(const WiFiClient &wifi_client);
void handle_request();

private:
enum rtsp_command
{
rtsp_command_unknown,
rtsp_command_option, // OPTIONS
rtsp_command_describe, // DESCRIBE
rtsp_command_setup, // SETUP
rtsp_command_play, // PLAY
rtsp_command_teardown // TEARDOWN
};

rtsp_command parse_command(const String& request);
unsigned long parse_cseq(const String& request);
bool parse_stream_url(const String& request);

int parse_client_port(const String& request);


WiFiClient wifi_client_;

bool tcp_transport_;

String host_url_;
unsigned short host_port_;
String stream_name_;
uint stream_id_;

unsigned short rtp_port_;
// enum rtsp_state state_;

String date_header();

void handle_option(unsigned long cseq);
void handle_describe(unsigned long cseq, const String& stream_url);
void handle_setup(unsigned long cseq, const String& stream_url);
void handle_play();
void handle_teardown();
};

private:
micro_rtsp_source *source_;

unsigned frame_interval_;
unsigned long next_frame_update_;

unsigned long next_check_client_;
std::list<rtsp_client *> clients_;
};
15 changes: 15 additions & 0 deletions lib/micro-rtsp-server/include/micro_rtsp_source.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <stddef.h>
#include <stdint.h>

class micro_rtsp_source
{
public:
virtual void update_frame();

virtual uint8_t *data() const = 0;
virtual size_t width() const = 0;
virtual size_t height() const = 0;
virtual size_t size() const = 0;
};
27 changes: 27 additions & 0 deletions lib/micro-rtsp-server/include/micro_rtsp_source_camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <micro_rtsp_source.h>

#include <esp_camera.h>

class micro_rtsp_source_camera : public micro_rtsp_source
{
public:
micro_rtsp_source_camera();
virtual ~micro_rtsp_source_camera();

esp_err_t initialize(camera_config_t *camera_config);
esp_err_t deinitialize();
// sensor_t* esp_camera_sensor_get();

void update_frame();

uint8_t *data() const { return fb->buf; }
size_t width() const { return fb->width; }
size_t height() const { return fb->height; }
size_t size() const { return fb->len; }

private:
esp_err_t init_result;
camera_fb_t *fb;
};
Loading

0 comments on commit 97fc4ce

Please sign in to comment.