基于Boost.Asio的rtsp库,支持Server/Client,推流/拉流。
协议名称 | 网络传输协议 | 延时 | 编码类型 | 主动/被动 |
---|---|---|---|---|
RTSP | TCP/UDP/组播 | 0~3s | H264/H265 | 拉流/推流 |
RTMP | TCP | 0~3s | H264 | 拉流/推流 |
HLS | HTTP短连接 | 1~10s | H264/H265 | 拉流 |
HTTP-FLV | HTTP长连接 | 0~3s | H264 | 拉流 |
WebRTC | HTTP长连接 | 0~3s | H264/H265 | 拉流/推流 |
SRT | UDP | 0~3s | H264 | 推流 |
使用Boost.Asio作为基础通信库,方便开发者集成librtsp库时,可以与其他通信库共用boost io_context
使用C++20协程,简化异步编程
使用boost::beast::http::request解析rtsp报文
RFC 2326: Real Time Streaming Protocol (RTSP)
1.4 Protocol Properties
Easy to parse: RTSP can be parsed by standard HTTP or MIME parsers.
classDiagram
class TcpServer {
+start() : void
+shutdown() : void
}
class RtspSession {
+start() : void
+stop() : void
+on_options(req, resp) : void
+on_describe(req, resp) : void
+on_setup(req, resp) : void
+on_play(req, resp) : void
}
TcpServer --> RtspSession : creates
TcpServer --> RtspSession : manages
编译环境:x86_64 Ubuntu 22.04 gcc 11.4.0
RFC 2326: Real Time Streaming Protocol (RTSP)
RFC 2550: RTP: A Transport Protocol for Real-Time Applications
RFC 3984: RTP Payload Format for H.264 Video
RFC 2435: RTP Payload Format for JPEG-compressed Video
https://github.com/bluenviron/gortsplib
https://github.com/mnpk/librtsp
https://github.com/mpromonet/v4l2rtspserver
https://github.com/ZLMediaKit/ZLMediaKit