我想从带有 RTSP 的设备中检索一些视频数据。
基于 UDP 的 RTSP 运行良好,但我需要它基于 TCP。
发出 RTSP 命令后,我收到了 RTP,但我不知道如何在这里处理它们。 有效载荷如下:$[channel - 1 bytes][length - 2bytes][data]
问题是我收到这样的数据包,有时还会收到 channel 为 10 或 99 等的其他数据包。
那么任何人都可以提供一些关于如何处理有效载荷的意见吗?
最佳答案
RFC 2326 "Real Time Streaming Protocol (RTSP)" 中应有尽有.您需要“10.12 嵌入式(交错)二进制数据”:
Stream data such as RTP packets is encapsulated by an ASCII dollar sign (24 hexadecimal), followed by a one-byte channel identifier, followed by the length of the encapsulated binary data as a binary, two-byte integer in network byte order. The stream data follows immediately afterwards, without a CRLF, but including the upper-layer protocol headers. Each $ block contains exactly one upper-layer protocol data unit, e.g., one RTP packet.
还有一个小例子:
S->C: $\000{2 byte length}{"length" bytes data, w/RTP header}
S->C: $\000{2 byte length}{"length" bytes data, w/RTP header}
S->C: $\001{2 byte length}{"length" bytes RTCP packet}
关于tcp - 通过 TCP 使用 RTSP 抓取视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12110541/