-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
590 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
Oops, something went wrong.