Fix chromecast support#20
Closed
nerijus wants to merge 1 commit into
Closed
Conversation
Owner
birhantprkc
pushed a commit
to birhantprkc/castor
that referenced
this pull request
Jul 20, 2026
Extract the entry->Info mapping out of discoverChromecast into a testable chromecastInfo helper and cover it: IPv4/IPv6 selection, DeviceName->Name->Host fallback, non-default cast-group ports, and rejection of address-less entries. Fold the name and dedupe fallbacks into cmp.Or. This branch combines the two parallel fixes for stupside#5: the discovery implementation from stupside#20 and the test approach from stupside#19. Co-authored-by: Nerijus Baliūnas <591932+nerijus@users.noreply.github.com> Co-authored-by: Bartosz Fenski <fenio@debian.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
internal/device/device.go,Discover()only does an SSDP search forurn:schemas-upnp-org:device:MediaRenderer:1. Chromecasts don't advertise via SSDP as MediaRenderers — they announce over mDNS as_googlecast._tcp.local. There's even a comment admitting it:"Chromecast discovery requires mDNS which the current dependency set doesn't ship; callers connect to known Chromecast addresses directly."
That comment is actually outdated: castor already depends on
github.com/vishen/go-chromecast v0.3.4for playback, and that same module ships adnspackage withDiscoverCastDNSEntries()built ongrandcat/zeroconf— whose hashes are already in castor'sgo.sum. So no new dependencies are needed at all.The patch does three things:
internal/device/device.go—Discover()now runs the SSDP scan and an mDNS_googlecast._tcpbrowse in parallel under the same timeout, merging results. The old body moved intodiscoverDLNA().internal/device/chromecast.go— addsdiscoverChromecast(), which drains the entry channel until the timeout, dedupes by UUID (mDNS re-announces duplicates), prefers the friendlyDeviceNamefrom the TXT record, and preserves non-default ports in the address ashost:port— cast groups advertise on random high ports, not 8009.connectChromecast()— now parses an optionalhost:portaddress vianet.SplitHostPort, falling back to 8009 for a bare host, so existing configs with plain IPs keep working and cast groups become connectable.go.mod — adds the four indirect requires (
grandcat/zeroconf,miekg/dns,cenkalti/backoff,golang.org/x/net); all already present in go.sum.