mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-14 04:04:02 +00:00
WIP
This commit is contained in:
74
lib/micro-rtsp-server/include/micro_rtsp_server.h
Normal file
74
lib/micro-rtsp-server/include/micro_rtsp_server.h
Normal file
@@ -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
lib/micro-rtsp-server/include/micro_rtsp_source.h
Normal file
15
lib/micro-rtsp-server/include/micro_rtsp_source.h
Normal file
@@ -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
lib/micro-rtsp-server/include/micro_rtsp_source_camera.h
Normal file
27
lib/micro-rtsp-server/include/micro_rtsp_source_camera.h
Normal file
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user