Skip to content

Fix ONVIF auto-discovery and improve service compatibility#2

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/update-rtsp-sub-stream-onvif
Draft

Fix ONVIF auto-discovery and improve service compatibility#2
Copilot wants to merge 5 commits into
mainfrom
copilot/update-rtsp-sub-stream-onvif

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 14, 2026

ONVIF camera auto-discovery was broken — devices were invisible to NVRs and ONVIF clients. Multiple root causes plus missing service handlers that caused clients to reject the device post-discovery.

Discovery fixes (onvif_discovery.sh)

  • Multicast reception: Added allmulti flag, ip maddr add group join, and WiFi power-save disable — without these, busybox nc never receives Probe packets on most embedded WiFi interfaces
  • Reliable Hello: Separated periodic Hello sender (30s) into independent background process — previously coupled to the nc listen loop, so if nc -w blocked (common busybox bug), Hello stopped entirely
  • timeout fallback: Wraps nc with timeout command when available, since busybox nc -w is unreliable across versions
  • Process cleanup: Stop handler now kills grandchild processes (nc spawned by Hello subshell)
setup_multicast() {
  ifconfig "$IFACE" multicast 2>/dev/null
  ifconfig "$IFACE" allmulti 2>/dev/null        # bypass kernel multicast filter
  ip maddr add 239.255.255.250 dev "$IFACE"    # IGMP group join
  iw dev "$IFACE" set power_save off 2>/dev/null # prevent WiFi dropping multicast
}

Auth fix (lighttpd.conf)

  • Exempted /onvif/* and /cgi-bin/onvif_* paths from HTTP digest auth — ONVIF uses WS-Security, not HTTP auth

Device service — 6 new handlers

  • GetServiceCapabilities, GetDiscoveryMode, GetHostname, GetDNS, GetNetworkProtocols, GetNetworkDefaultGateway
  • Standard XAddrs paths (/onvif/device_service instead of CGI paths)

Media service — 8 new handlers

  • GetServiceCapabilities, GetVideoEncoderConfigurationOptions, GetVideoSourceConfigurationOptions, GetCompatibleVideoEncoderConfigurations
  • GetVideoSourceConfiguration, GetVideoEncoderConfiguration (singular, by token)
  • GetAudioSourceConfigurations, GetAudioEncoderConfigurations
  • Sub-stream profile support throughout

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…d missing handlers

- Fix GetVideoSourceConfigurations to return both main (1920x1080) and sub (640x360) video source configs
- Add GetVideoSourceConfiguration (singular) handler for querying specific source config by token
- Add GetVideoEncoderConfiguration (singular) handler for querying specific encoder config by token
- Add GetAudioSourceConfigurations handler for listing audio source configurations
- Add GetAudioEncoderConfigurations handler for listing audio encoder configurations
- Add ConfigurationToken extraction from SOAP requests

Co-authored-by: symysak <103905928+symysak@users.noreply.github.com>
Copilot AI changed the title [WIP] Update RTSP sub stream for ONVIF compatibility Add ONVIF sub stream support to media service Mar 14, 2026
Copilot AI requested a review from symysak March 14, 2026 16:31
…tion, standard URLs

- Add setup_multicast() to join multicast group via route/ifconfig (fixes Probe reception)
- Fix PID management: use $! (background PID) instead of $$ (parent PID)
- Add periodic Hello every ~30 seconds so clients discover the device reliably
- Add WS-Discovery Bye message on shutdown
- Fix Probe detection to exclude ProbeMatch/Hello using SOAP Action URI
- Use standard ONVIF XAddrs paths (/onvif/device_service, /onvif/media_service)
- Exempt ONVIF paths from HTTP digest auth in lighttpd.conf

Co-authored-by: symysak <103905928+symysak@users.noreply.github.com>
Copilot AI changed the title Add ONVIF sub stream support to media service Fix ONVIF auto-discovery and add sub stream support Mar 14, 2026
Copilot AI and others added 2 commits March 14, 2026 16:57
Discovery fixes:
- Add allmulti flag to ensure multicast frame reception without IGMP join
- Add ip maddr add for explicit multicast group membership
- Disable WiFi power-save to prevent dropping multicast packets
- Separate Hello loop from Probe listener (independent background process)
- Use timeout command as fallback when busybox nc -w is unreliable
- Improve child process cleanup on stop (grandchildren too)

Device service additions:
- GetServiceCapabilities, GetDiscoveryMode, GetHostname
- GetDNS, GetNetworkProtocols, GetNetworkDefaultGateway

Media service additions:
- GetServiceCapabilities with streaming capabilities
- GetVideoEncoderConfigurationOptions with H264 options
- GetVideoSourceConfigurationOptions
- GetCompatibleVideoEncoderConfigurations

Co-authored-by: symysak <103905928+symysak@users.noreply.github.com>
- Clarify allmulti comment (bypasses filter, not IGMP join)
- Improve Probe detection to exclude both ProbeMatch and ProbeMatches

Co-authored-by: symysak <103905928+symysak@users.noreply.github.com>
Copilot AI changed the title Fix ONVIF auto-discovery and add sub stream support Fix ONVIF auto-discovery and improve service compatibility Mar 14, 2026
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.

2 participants