Skip to content

Fix chromecast support#20

Closed
nerijus wants to merge 1 commit into
stupside:mainfrom
nerijus:main
Closed

Fix chromecast support#20
nerijus wants to merge 1 commit into
stupside:mainfrom
nerijus:main

Conversation

@nerijus

@nerijus nerijus commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

In internal/device/device.go, Discover() only does an SSDP search for urn: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.4 for playback, and that same module ships a dns package with DiscoverCastDNSEntries() built on grandcat/zeroconf — whose hashes are already in castor's go.sum. So no new dependencies are needed at all.
The patch does three things:

internal/device/device.goDiscover() now runs the SSDP scan and an mDNS _googlecast._tcp browse in parallel under the same timeout, merging results. The old body moved into discoverDLNA().
internal/device/chromecast.go — adds discoverChromecast(), which drains the entry channel until the timeout, dedupes by UUID (mDNS re-announces duplicates), prefers the friendly DeviceName from the TXT record, and preserves non-default ports in the address as host:port — cast groups advertise on random high ports, not 8009.
connectChromecast() — now parses an optional host:port address via net.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.

@stupside stupside added duplicate This issue or pull request already exists enhancement New feature or request labels Jul 19, 2026
@stupside

Copy link
Copy Markdown
Owner

Thanks a lot for this. I combined it with #19 into #21, where your discovery implementation is the base commit (kept under your authorship) plus a test and a DLNA cleanup on top. Closing in favor of #21. 🙏

@stupside stupside closed this Jul 19, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants