17 ESP_LOGE(TAG,
"Socket %s failed: errno %d", what, errno);
26 ESP_LOGE(TAG,
"Socket creation failed: errno %d", errno);
62 session.loop(now, this->
port_);
63 playing |= session.is_playing();
84#ifdef USE_SOCKET_IPV4_ALLOW
91 if (!session.is_active()) {
96 if (free_slot ==
nullptr) {
97 ESP_LOGW(TAG,
"Max connections (%d) reached, rejecting connection", MAX_RTSP_CONNECTIONS);
101 ESP_LOGD(TAG,
"Accepted RTSP connection");
102 free_slot->
open(std::move(sock), now);
111 if (!
parse_jpeg_info(image->get_data_buffer(), image->get_data_length(), jpeg) ||
112 jpeg.
width > RTP_JPEG_MAX_DIMENSION || jpeg.
height > RTP_JPEG_MAX_DIMENSION) {
116 "Dropping frame %" PRIu16
"x%" PRIu16
": not a baseline 4:2:2/4:2:0 JPEG without restart markers"
117 " of at most %" PRIu16
" px per side",
125 session.on_new_frame(image, jpeg, now);
133 " Max connections: %u",
134 this->
port_, MAX_RTSP_CONNECTIONS);
135#ifdef USE_SOCKET_IPV4_ALLOW
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void mark_failed()
Mark this component as failed.
virtual void start_stream(CameraRequester requester)=0
virtual void stop_stream(CameraRequester requester)=0
virtual void add_listener(CameraListener *listener)=0
Add a listener to receive camera events.
static Camera * instance()
The singleton instance of the camera implementation.
void on_camera_image(const std::shared_ptr< camera::CameraImage > &image) override
socket::ListenSocket * socket_
float get_setup_priority() const override
void socket_failed_(const char *what)
std::array< RTSPSession, MAX_RTSP_CONNECTIONS > sessions_
void dump_config() override
void accept_new_connections_(uint32_t now)
A single RTSP client: one TCP connection carrying both the RTSP control channel and,...
void open(std::unique_ptr< socket::Socket > socket, uint32_t now)
int setblocking(bool blocking)
bool ready() const
Check if the socket has buffered data ready to read.
int bind(const struct sockaddr *addr, socklen_t addrlen)
int setsockopt(int level, int optname, const void *optval, socklen_t optlen)
std::unique_ptr< BSDSocketImpl > accept_loop_monitored(struct sockaddr *addr, socklen_t *addrlen)
void dump_config(const char *tag) const
One config line per allowed network.
bool admit(const struct sockaddr *peer, socklen_t len, const char *tag, uint32_t now)
allows(peer), logging a refused peer at most once every REJECT_LOG_INTERVAL_MS.
ESPHOME_LOG_TAG(TAG, "rtsp_server")
bool parse_jpeg_info(const uint8_t *data, size_t len, JpegInfo &out)
Scans JPEG marker segments (SOF0/1, DQT, SOS) for the dimensions, quantization tables and the start o...
constexpr float LATE
For components that should be initialized at the very end of the setup process.
socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t port)
Set a sockaddr to the any address and specified port for the IP version used by socket_ip().
std::unique_ptr< ListenSocket > socket_ip_loop_monitored(int type, int protocol)
Application App
Global storage of Application pointer - only one Application can exist.
The fields of a JPEG frame that an RFC 2435 RTP/JPEG payload needs. Pointers refer into the frame.