Skip to content

Fix ONVIF NVR compatibility for RTSP streaming#2151

Open
Moonbesk wants to merge 1 commit intoAlexxIT:masterfrom
Moonbesk:fix/onvif-nvr-compat
Open

Fix ONVIF NVR compatibility for RTSP streaming#2151
Moonbesk wants to merge 1 commit intoAlexxIT:masterfrom
Moonbesk:fix/onvif-nvr-compat

Conversation

@Moonbesk
Copy link
Copy Markdown

Summary

This PR fixes three issues that cause ONVIF clients (e.g. Hikvision ISC/iSecure Center) to fail when connecting to go2rtc's ONVIF server for RTSP streaming. The failure rate was approximately 80-90%.

Root Causes

  1. ONVIF capabilities declare RTP_TCP as false — ONVIF clients check GetCapabilities and GetServiceCapabilities before attempting RTSP SETUP. When RTP_TCP=false, clients like Hikvision ISC skip the SETUP entirely, resulting in silent stream failure.

  2. RTSP server rejects UDP transport requests — When an ONVIF client sends SETUP with RTP/AVP (UDP), the server returns 461 Unsupported transport. Since go2rtc only supports TCP interleaved, the server should accept the request but respond with TCP interleaved transport parameters.

  3. SDP track accumulation on re-DESCRIBE — Some ONVIF clients reuse the same RTSP connection to send multiple DESCRIBE requests (e.g. when switching profiles). The Senders and Receivers slices were never reset, causing duplicate tracks to accumulate and break playback.

Changes

  • pkg/onvif/server.go: Set RTP_TCP to true in both GetCapabilities and GetServiceCapabilities responses
  • pkg/rtsp/server.go: Accept RTP/AVP (UDP) SETUP requests and respond with TCP interleaved transport
  • internal/rtsp/rtsp.go: Clean up previous consumer and reset Senders/Receivers on re-DESCRIBE

Testing

Tested with Hikvision ISC (iSecure Center) NVR platform connecting to go2rtc v1.9.14 ONVIF server. After the fix, streams connect reliably (previously ~80-90% failure rate).

…forms

1. Fix duplicate SDP tracks on re-DESCRIBE within same RTSP connection
2. Declare RTP_TCP=true in ONVIF capabilities for NVR compatibility
3. Accept UDP SETUP requests and force TCP interleaved transport in response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant