16static constexpr size_t INTERLEAVED_HEADER_LEN = 4;
17static constexpr size_t RTP_HEADER_LEN = 12;
18static constexpr size_t JPEG_HEADER_LEN = 8;
19static constexpr size_t QUANT_HEADER_LEN = 4;
20static constexpr size_t QTABLE_LEN = 64;
21static constexpr size_t RTP_JPEG_PAYLOAD_SIZE = 1024;
22static constexpr size_t MAX_PACKET_SIZE = INTERLEAVED_HEADER_LEN + RTP_HEADER_LEN + JPEG_HEADER_LEN + QUANT_HEADER_LEN +
23 2 * QTABLE_LEN + RTP_JPEG_PAYLOAD_SIZE;
25static constexpr uint16_t RTP_JPEG_MAX_DIMENSION = 255 * 8;
28static constexpr uint32_t FRAME_STALL_MS = 500;
52 void open(std::unique_ptr<socket::Socket> socket,
uint32_t now);
70 void queue_response_(uint16_t code,
const char *reason,
const char *extra_headers_fmt =
nullptr, ...)
99 std::array<struct iovec, 4>
iov_{};
StringRef is a reference to a string owned by something else.
A single RTSP client: one TCP connection carrying both the RTSP control channel and,...
void void stop_playing_()
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.
void service_(uint32_t now, uint16_t port)
uint32_t last_activity_ms_
std::unique_ptr< socket::Socket > socket_
std::array< char, 512 > request_buf_
void handle_setup_(StringRef transport_header)
bool queue_next_packet_()
std::array< char, 256 > send_buf_
std::shared_ptr< camera::CameraImage > frame_
void read_requests_(uint32_t now, uint16_t port)
std::array< struct iovec, 4 > iov_
uint32_t frame_progress_ms_
void open(std::unique_ptr< socket::Socket > socket, uint32_t now)
void consume_input_(size_t len)
bool process_input_(uint16_t port)
Consumes buffered input up to and including the next request; true once a request was handled.
void handle_request_(StringRef request, uint16_t port)
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 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.
uint16_t sequence_number_
std::vector< uint8_t > & out
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...
The fields of a JPEG frame that an RFC 2435 RTP/JPEG payload needs. Pointers refer into the frame.
const uint8_t * scan_data