Repository navigation
feat: RTSP multicast, with fallback to TCP (#69) - #73
Conversation
|
/review |
Code Review by Qodo
1.
|
On Linux a socket bound to the wildcard address receives every group joined on that port on the device, so two slots on different groups with the same port would mix their streams (found by the review of #73).
d571d97 to
559de2f
Compare
|
Code done, CI green, Qodo findings addressed. Waiting for the device round in #74. |
A fourth transport for a slot, Multicast: SETUP asks for "RTP/AVP;multicast", the reply's destination and port are joined on the interface of the RTSP connection, and the stream is received by the UDP loop of #67 (TEARDOWN on close, keepalives over RTSP). It is for third-party servers and NVRs: Majestic answers a multicast SETUP with 400 and XM cameras with 451, and both turn a multicast request that carries client_port into unicast. So Multicast falls back to TCP, like Auto, when the SETUP is refused, when the reply is not a usable multicast group, or when no video arrives within 3 s, and remembers it for the URL. A failed multicast does not mark the URL for Auto's UDP. Joining a group from a DatagramChannel needs API 24: below Android 7 the slot uses TCP. The Wi-Fi multicast lock of #68 is held while joined.
- A reply with port 0 is not a usable group: fall back instead of binding an unrelated port. - Multicast is not restricted to the RTSP peer: the group selects the stream and a server may send it from another interface; only a named source restricts it. - The group socket binds to the group address, not the wildcard, so two slots on different groups with one port do not mix their streams.
On Linux a socket bound to the wildcard address receives every group joined on that port on the device, so two slots on different groups with the same port would mix their streams (found by the review of #73).
9bc9290 to
a00d6f2
Compare
559de2f to
936a22c
Compare
|
Device test: |
On Linux a socket bound to the wildcard address receives every group joined on that port on the device, so two slots on different groups with the same port would mix their streams (found by the review of #73).
feat: RTSP multicast, with fallback to TCP (#69)
Closes #69. Stacked on #72 (plain RTP over UDP), which is stacked on #70 (UDP for RTSP).
What changes
A fourth transport for a slot, Multicast, next to TCP / UDP / Auto in the URL dialog (
--es transport multicastwith a shared link):RTP/AVP;multicast. The reply'sdestinationandportare joined on the network interface of the RTSP connection, and the stream is received by the UDP loop of feat: RTSP over UDP unicast, with fallback to TCP (#67) #70: one thread, reorder buffer, sender check against the RTSP peer andsource, keepalives over RTSP, TEARDOWN on close. The Wi‑Fi multicast lock of feat: receive plain RTP from Majestic outgoing over UDP, unicast and multicast (#68) #72 is held while joined.400 'client_port' not found, XM answers451, and both turn a multicast request that carriesclient_portinto unicast. So with these cameras a Multicast slot simply plays over TCP. The mode is meant for third-party servers and NVRs.DatagramChannelneeds API 26 on Android (the lint check caught that it is not 24). On older systems a Multicast slot uses TCP.Tests (
RtspSessionTest, scripted server)Device test (when the hardware is free)