|
ESPHome 2026.11.0-dev
|
A single RTSP client: one TCP connection carrying both the RTSP control channel and, once playing, RTP/JPEG media interleaved on the same socket (RFC 2326 §10.12). More...
#include <rtsp_session.h>
Public Member Functions | |
| bool | is_active () const |
| bool | is_playing () const |
| void | open (std::unique_ptr< socket::Socket > socket, uint32_t now) |
| void | loop (uint32_t now, uint16_t port) |
| void | on_new_frame (const std::shared_ptr< camera::CameraImage > &image, const JpegInfo &jpeg, uint32_t now) |
| Ignored unless playing with no output pending; packets of the frame being sent point into that frame. | |
Protected Types | |
| enum class | State : uint8_t { INIT , READY , PLAYING } |
Protected Member Functions | |
| void | service_ (uint32_t now, uint16_t port) |
| void | close_ () |
| void | read_requests_ (uint32_t now, uint16_t port) |
| bool | process_input_ (uint16_t port) |
| Consumes buffered input up to and including the next request; true once a request was handled. | |
| void | consume_input_ (size_t len) |
| void | handle_request_ (StringRef request, uint16_t port) |
| void | handle_setup_ (StringRef transport_header) |
| void | handle_play_ () |
| void | queue_response_ (uint16_t code, const char *reason, const char *extra_headers_fmt=nullptr,...) __attribute__((format(printf |
| Queues "RTSP/1.0 <code> <reason>", CSeq, Session once set up, the extra headers and the blank line. | |
| void void | stop_playing_ () |
| bool | queue_next_packet_ () |
| void | drop_frame_ () |
| Releases the frame; the frame-backed rest of the current packet is sent as zeros to keep the framing. | |
| bool | flush_ (uint32_t now) |
| Writes what is queued; true once all of it is written, false while backlogged or after a failure. | |
Protected Attributes | |
| std::unique_ptr< socket::Socket > | socket_ |
| std::shared_ptr< camera::CameraImage > | frame_ |
| JpegInfo | jpeg_ |
| size_t | frame_sent_ {0} |
| uint32_t | cseq_ {0} |
| uint32_t | rtp_timestamp_ {0} |
| uint32_t | ssrc_ {0} |
| uint32_t | last_activity_ms_ {0} |
| uint32_t | last_frame_ms_ {0} |
| uint32_t | frame_progress_ms_ {0} |
| uint32_t | skip_len_ {0} |
| uint16_t | sequence_number_ {0} |
| uint16_t | request_len_ {0} |
| uint16_t | filler_len_ {0} |
| std::array< struct iovec, 4 > | iov_ {} |
| uint8_t | iov_pos_ {0} |
| uint8_t | iov_count_ {0} |
| State | state_ {State::INIT} |
| bool | should_close_ {false} |
| bool | close_after_send_ {false} |
| bool | sending_packet_ {false} |
| bool | read_pending_ {false} |
| char | session_id_ [9] {} |
| std::array< char, 512 > | request_buf_ {} |
| std::array< char, 256 > | send_buf_ {} |
A single RTSP client: one TCP connection carrying both the RTSP control channel and, once playing, RTP/JPEG media interleaved on the same socket (RFC 2326 §10.12).
No UDP transport is supported. The object is a reusable slot: open() starts a connection, and it closes itself when the connection ends.
Definition at line 47 of file rtsp_session.h.
|
strongprotected |
| Enumerator | |
|---|---|
| INIT | |
| READY | |
| PLAYING | |
Definition at line 58 of file rtsp_session.h.
|
protected |
Definition at line 168 of file rtsp_session.cpp.
|
protected |
Definition at line 275 of file rtsp_session.cpp.
|
protected |
Releases the frame; the frame-backed rest of the current packet is sent as zeros to keep the framing.
Definition at line 489 of file rtsp_session.cpp.
|
protected |
Writes what is queued; true once all of it is written, false while backlogged or after a failure.
Definition at line 501 of file rtsp_session.cpp.
|
protected |
Definition at line 389 of file rtsp_session.cpp.
|
protected |
Definition at line 280 of file rtsp_session.cpp.
|
protected |
Definition at line 378 of file rtsp_session.cpp.
|
inline |
Definition at line 49 of file rtsp_session.h.
|
inline |
Definition at line 50 of file rtsp_session.h.
| void esphome::rtsp_server::RTSPSession::loop | ( | uint32_t | now, |
| uint16_t | port ) |
Definition at line 177 of file rtsp_session.cpp.
| void esphome::rtsp_server::RTSPSession::on_new_frame | ( | const std::shared_ptr< camera::CameraImage > & | image, |
| const JpegInfo & | jpeg, | ||
| uint32_t | now ) |
Ignored unless playing with no output pending; packets of the frame being sent point into that frame.
Definition at line 404 of file rtsp_session.cpp.
| void esphome::rtsp_server::RTSPSession::open | ( | std::unique_ptr< socket::Socket > | socket, |
| uint32_t | now ) |
Definition at line 148 of file rtsp_session.cpp.
|
protected |
Consumes buffered input up to and including the next request; true once a request was handled.
Definition at line 247 of file rtsp_session.cpp.
|
protected |
Definition at line 419 of file rtsp_session.cpp.
|
protected |
Queues "RTSP/1.0 <code> <reason>", CSeq, Session once set up, the extra headers and the blank line.
Definition at line 357 of file rtsp_session.cpp.
|
protected |
Definition at line 210 of file rtsp_session.cpp.
|
protected |
Definition at line 190 of file rtsp_session.cpp.
|
protected |
Definition at line 399 of file rtsp_session.cpp.
|
protected |
Definition at line 105 of file rtsp_session.h.
|
protected |
Definition at line 85 of file rtsp_session.h.
|
protected |
Definition at line 96 of file rtsp_session.h.
|
protected |
Definition at line 81 of file rtsp_session.h.
|
protected |
Definition at line 90 of file rtsp_session.h.
|
protected |
Definition at line 83 of file rtsp_session.h.
|
protected |
Definition at line 99 of file rtsp_session.h.
|
protected |
Definition at line 101 of file rtsp_session.h.
|
protected |
Definition at line 100 of file rtsp_session.h.
|
protected |
Definition at line 82 of file rtsp_session.h.
|
protected |
Definition at line 88 of file rtsp_session.h.
|
protected |
Definition at line 89 of file rtsp_session.h.
|
protected |
Definition at line 107 of file rtsp_session.h.
|
protected |
Definition at line 112 of file rtsp_session.h.
|
protected |
Definition at line 94 of file rtsp_session.h.
|
protected |
Definition at line 86 of file rtsp_session.h.
|
protected |
Definition at line 114 of file rtsp_session.h.
|
protected |
Definition at line 106 of file rtsp_session.h.
|
protected |
Definition at line 93 of file rtsp_session.h.
|
protected |
Definition at line 108 of file rtsp_session.h.
|
protected |
Definition at line 104 of file rtsp_session.h.
|
protected |
Definition at line 92 of file rtsp_session.h.
|
protected |
Definition at line 79 of file rtsp_session.h.
|
protected |
Definition at line 87 of file rtsp_session.h.
|
protected |
Definition at line 103 of file rtsp_session.h.