mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-17 13:38:02 +00:00
Work in progress
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <micro_rtsp_source.h>
|
||||
|
||||
#include <esp_camera.h>
|
||||
|
||||
class micro_rtsp_source_camera : public micro_rtsp_source
|
||||
class micro_rtsp_camera
|
||||
{
|
||||
public:
|
||||
micro_rtsp_source_camera();
|
||||
virtual ~micro_rtsp_source_camera();
|
||||
micro_rtsp_camera();
|
||||
virtual ~micro_rtsp_camera();
|
||||
|
||||
esp_err_t initialize(camera_config_t *camera_config);
|
||||
esp_err_t deinitialize();
|
||||
19
lib/micro-rtsp-server/include/micro_rtsp_jpeg.h
Normal file
19
lib/micro-rtsp-server/include/micro_rtsp_jpeg.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <tuple>
|
||||
|
||||
class micro_rtsp_jpeg
|
||||
{
|
||||
public:
|
||||
micro_rtsp_jpeg(const uint8_t *jpeg, size_t size);
|
||||
|
||||
protected:
|
||||
bool decode_jpeg(uint8_t *jpg, size_t size);
|
||||
std::tuple<const uint8_t *, size_t> find_jpeg_section(uint8_t **ptr, uint8_t *end, uint8_t flag);
|
||||
|
||||
std::tuple<const uint8_t *, size_t> quantization_table_0_;
|
||||
std::tuple<const uint8_t *, size_t> quantization_table_1_;
|
||||
std::tuple<const uint8_t *, size_t> jpeg_data_;
|
||||
};
|
||||
53
lib/micro-rtsp-server/include/micro_rtsp_requests.h
Normal file
53
lib/micro-rtsp-server/include/micro_rtsp_requests.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class micro_rtsp_requests
|
||||
{
|
||||
public:
|
||||
std::string process_request(const std::string& 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
|
||||
};
|
||||
|
||||
const std::string available_stream_name_ = "mjpeg/1";
|
||||
|
||||
rtsp_command parse_command(const std::string &request);
|
||||
bool parse_client_port(const std::string &request);
|
||||
bool parse_cseq(const std::string &request);
|
||||
bool parse_stream_url(const std::string &request);
|
||||
|
||||
std::string date_header();
|
||||
std::string rtsp_error(unsigned short code, const std::string& message);
|
||||
|
||||
std::string handle_option(const std::string &request);
|
||||
std::string handle_describe(const std::string &request);
|
||||
std::string handle_setup(const std::string &request);
|
||||
std::string handle_play(const std::string &request);
|
||||
std::string handle_teardown(const std::string &request);
|
||||
|
||||
unsigned long cseq_;
|
||||
|
||||
std::string host_url_;
|
||||
unsigned short host_port_;
|
||||
std::string stream_name_;
|
||||
|
||||
bool tcp_transport_;
|
||||
unsigned short client_port_;
|
||||
|
||||
unsigned short rtp_streamer_port_;
|
||||
unsigned short rtcp_streamer_port_;
|
||||
|
||||
unsigned long rtsp_session_id_;
|
||||
|
||||
bool stream_active_;
|
||||
bool stream_stopped_;
|
||||
};
|
||||
@@ -1,74 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <micro_rtsp_source.h>
|
||||
#include <vector>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
class micro_rtsp_server : public WiFiServer
|
||||
#include "micro_rtsp_camera.h"
|
||||
#include "micro_rtsp_requests.h"
|
||||
|
||||
class micro_rtsp_server : WiFiServer
|
||||
{
|
||||
public:
|
||||
micro_rtsp_server(micro_rtsp_source *source, unsigned frame_interval = 100, unsigned short port = 554);
|
||||
micro_rtsp_server(const micro_rtsp_camera& source, unsigned frame_interval = 100, unsigned short port = 554);
|
||||
~micro_rtsp_server();
|
||||
|
||||
unsigned get_frame_interval() { return frame_interval_; }
|
||||
unsigned set_frame_interval(unsigned value) { return frame_interval_ = value; }
|
||||
|
||||
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
|
||||
class rtsp_client : public WiFiClient, public micro_rtsp_requests
|
||||
{
|
||||
public:
|
||||
rtsp_client(const WiFiClient &wifi_client);
|
||||
rtsp_client(const WiFiClient &client);
|
||||
~rtsp_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_;
|
||||
const micro_rtsp_camera &source_;
|
||||
|
||||
unsigned frame_interval_;
|
||||
|
||||
unsigned frame_interval_;
|
||||
unsigned long next_frame_update_;
|
||||
|
||||
unsigned long next_check_client_;
|
||||
std::list<rtsp_client *> clients_;
|
||||
std::list<rtsp_client> clients_;
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
#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;
|
||||
};
|
||||
6
lib/micro-rtsp-server/include/micro_rtssp_streamer.h
Normal file
6
lib/micro-rtsp-server/include/micro_rtssp_streamer.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class micro_rtsp_streamer
|
||||
{
|
||||
public:
|
||||
};
|
||||
Reference in New Issue
Block a user