Skip to content

Send UDP media and timing to the RTSP peer's address - #74

Closed
PhilflowIO wants to merge 1 commit into
omarroth:mainfrom
PhilflowIO:udp-media-same-family-as-rtsp
Closed

PhilflowIO wants to merge 1 commit into
omarroth:mainfrom
PhilflowIO:udp-media-same-family-as-rtsp

Conversation

@PhilflowIO

Copy link
Copy Markdown

Fixes #73.

What was wrong

  • The RTSP connection is dialed by hostname, so for a dual-stack name like receiver.local the session usually runs over IPv6.
  • Audio data, audio control and the NTP timing probes re-resolved the hostname with net.ResolveUDPAddr, which prefers IPv4. All UDP media went to the receiver's IPv4 address.
  • Receivers that bind media sockets to the session's address family never see those packets. UxPlay does (IPV6_V6ONLY on an IPv6 session): video works, audio is silent, timing times out.

What this changes

  • New (*AirPlayClient).mediaHost() returns the remote IP (with IPv6 zone) of the established RTSP connection; it falls back to the hostname when there is no connection yet or the remote address is not TCP.
  • Audio data, audio control and NTP timing probe destinations use it. Same idea as PTP setup taking the local address from the RTSP connection (localIPForConnection).
  • Unit tests for IPv4, IPv6, link-local zone, nil and non-TCP connections, and that resolving keeps family and zone.

Testing

  • make test, go vet ./..., gofmt -l clean.
  • Live against UxPlay 1.73.7 on a Raspberry Pi 5 with -target <name>.local over IPv6: ~2450 audio packets in 20 s (before: none), no NTP timeouts.

Limits

  • The TCP video-data and event-channel dials still use the hostname; they follow the same address order as the RTSP dial and were not affected here.
  • Devices picked via discovery use an IPv4 literal and were not affected.

🤖 Generated with Claude Code

The RTSP connection is dialed by hostname, and the dial follows the
resolver's order, which usually puts IPv6 first for dual-stack names
such as "receiver.local". Audio data, audio control and NTP timing
probes re-resolved the hostname with net.ResolveUDPAddr, which prefers
IPv4. The session therefore ran over IPv6 while all UDP media went to
the receiver's IPv4 address.

Receivers that bind their media sockets to the session's address
family never see those packets. UxPlay does exactly that
(IPV6_V6ONLY on an IPv6 session): video works over the TCP mirror
stream, audio stays silent and timing times out.

Use the remote IP (and zone) of the established RTSP connection for
all UDP media and timing destinations. Fall back to the hostname when
there is no connection yet or its remote address is not TCP. This
mirrors how PTP setup already takes the local address from the RTSP
connection (localIPForConnection).

Verified against UxPlay 1.73.7 over IPv6 with `-target <name>.local`:
~2450 audio packets in 20 s (before: none), no NTP timeouts.

Limits: the TCP video-data and event-channel dials still use the
hostname; they follow the same address order as the RTSP dial, so they
were not affected here. Devices picked via discovery use an IPv4
literal and were not affected either.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
omarroth added a commit that referenced this pull request Nov 6, 2026
Anchor UDP audio and timing plus TCP video/event sockets to the address selected by the established control connection. This preserves the IPv6 family and scope zone for dual-stack target names and prevents secondary channels from landing on another resolved address.\n\nPR #74 supplied the core UDP diagnosis and live UxPlay verification; this implementation extends the invariant to every port returned for the RTSP session.\n\nRefs #73 and #74.
@omarroth

Copy link
Copy Markdown
Owner

See #73, should be superseded by 3773138. Included in v0.6.0 release.

@omarroth omarroth closed this Nov 15, 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.

No audio with a dual-stack -target hostname: UDP media goes to IPv4 while the session runs over IPv6

2 participants