/
/
/
1"""Constants for Chromecast Player provider."""
2
3from __future__ import annotations
4
5from music_assistant_models.config_entries import ConfigEntry
6from music_assistant_models.enums import ConfigEntryType
7
8from music_assistant.constants import (
9 CONF_ENTRY_FLOW_MODE,
10 CONF_ENTRY_HTTP_PROFILE_DEFAULT_3,
11 CONF_ENTRY_OUTPUT_CODEC,
12 create_sample_rates_config_entry,
13)
14
15MASS_APP_ID = "C35B0678"
16APP_MEDIA_RECEIVER = "CC1AD845"
17SENDSPIN_CAST_APP_ID = "DD107DDB"
18SENDSPIN_CAST_NAMESPACE = "urn:x-cast:sendspin"
19CONF_USE_MASS_APP = "use_mass_app"
20DASHBOARD_NAMESPACE = "urn:x-cast:io.music-assistant.cast"
21
22# keepalive media the cast receiver plays while showing a dashboard
23DASHBOARD_KEEPALIVE_SUFFIXES = ("/dashboard-keepalive.mp4", "/keepalive.png")
24
25# Interval (seconds) before an unavailable player is re-evaluated as a possible
26# passive multichannel endpoint that should be removed from the setup.
27MULTICHANNEL_RECHECK_INTERVAL = 600
28
29# Devices known to not work with the Sendspin Cast bridge.
30# Tuple of (manufacturer, model) where "*" is a wildcard.
31# These devices will not get a Sendspin bridge, allowing other protocols
32# (e.g. AirPlay bridge) to handle them instead.
33SENDSPIN_CAST_BLOCKLIST: set[tuple[str, str]] = {
34 ("Harman Luxury Audio", "*"),
35 ("*", "HK OMNI ADAPT+AMP"),
36}
37
38CAST_PLAYER_CONFIG_ENTRIES = (
39 CONF_ENTRY_OUTPUT_CODEC,
40 CONF_ENTRY_HTTP_PROFILE_DEFAULT_3,
41 # enable flow mode by default as cast devices handle a continuous
42 # flow stream more reliably than enqueueing individual tracks
43 ConfigEntry.from_dict({**CONF_ENTRY_FLOW_MODE.to_dict(), "default_value": True}),
44 ConfigEntry(
45 key=CONF_USE_MASS_APP,
46 type=ConfigEntryType.BOOLEAN,
47 default_value=True,
48 advanced=True,
49 ),
50)
51
52# originally/officially cast supports 96k sample rate (even for groups)
53# but it seems a (recent?) update broke this ?!
54# For now only set safe default values and let the user try out higher values
55CONF_ENTRY_SAMPLE_RATES_CAST = create_sample_rates_config_entry(
56 max_sample_rate=192000,
57 max_bit_depth=24,
58 safe_max_sample_rate=48000,
59 safe_max_bit_depth=16,
60)
61CONF_ENTRY_SAMPLE_RATES_CAST_GROUP = create_sample_rates_config_entry(
62 max_sample_rate=96000,
63 max_bit_depth=24,
64 safe_max_sample_rate=48000,
65 safe_max_bit_depth=16,
66)
67
68# Measured defaults for known Cast models.
69CAST_MODEL_STATIC_DELAY: dict[tuple[str, str], int] = {
70 ("Google Inc.", "Google Home Mini"): 330,
71 ("Google Inc.", "Google Nest Mini"): 427,
72 ("Google Inc.", "Chromecast Audio"): 335,
73 ("Google Inc.", "Google Nest Hub"): 188,
74}
75CAST_FALLBACK_STATIC_DELAY = 330
76
77
78def get_cast_model_static_delay(manufacturer: str, model: str) -> int:
79 """
80 Look up the default static delay for a Cast device model.
81
82 :param manufacturer: Device manufacturer (e.g., "Google Inc.").
83 :param model: Device model name (e.g., "Google Nest Mini").
84 """
85 return CAST_MODEL_STATIC_DELAY.get((manufacturer, model), CAST_FALLBACK_STATIC_DELAY)
86