Randomize Broadcast ID per stream instead of using static values

This commit is contained in:
2026-03-24 12:09:16 +01:00
parent e1d717ed5c
commit 4036fee1f5
2 changed files with 7 additions and 5 deletions

View File

@@ -1588,7 +1588,6 @@ if start_stream:
analog_gain=cfg.get('analog_gain', 50),
bigs=[
auracast_config.AuracastBigConfig(
id=cfg.get('id', 123456),
code=(cfg['stream_passwort'].strip() or None),
name=cfg['name'],
program_info=cfg['program_info'],
@@ -1643,8 +1642,6 @@ if start_stream:
if not stream.get('input_device'):
continue
stream_id = radio_id * 1000 + i + 1 # Unique ID per stream
# Check if this specific stream uses stereo (dante_stereo_X_Y device)
input_device = stream['input_device']
stream_is_stereo = is_stereo_mode or input_device.startswith('dante_stereo_')
@@ -1652,7 +1649,6 @@ if start_stream:
num_channels = 2 if stream_is_stereo else 1
bigs.append(auracast_config.AuracastBigConfig(
id=stream_id,
code=(stream.get('stream_password', '').strip() or None),
name=stream['name'],
program_info=stream['program_info'],

View File

@@ -133,6 +133,10 @@ def save_settings(persisted: dict, secondary: bool = False) -> None:
def gen_random_add() -> str:
return ':'.join(['%02X' % random.randint(0, 255) for _ in range(6)])
def gen_random_broadcast_id() -> int:
"""Generate a random 24-bit Broadcast ID (1..0xFFFFFF)."""
return random.randint(1, 0xFFFFFF)
app = FastAPI()
# Allow CORS for frontend on localhost
@@ -454,10 +458,12 @@ async def init_radio(transport: str, conf: auracast_config.AuracastConfigGroup,
conf.qos_config.max_transport_latency_ms = int(conf.qos_config.number_of_retransmissions) * 10 + 3
# Only generate a new random_address if the BIG is still at the model default.
# Generate fresh random_address and broadcast ID for any BIG still at model defaults.
for big in conf.bigs:
if not getattr(big, 'random_address', None) or big.random_address == DEFAULT_RANDOM_ADDRESS:
big.random_address = gen_random_add()
if big.id == DEFAULT_BIG_ID:
big.id = gen_random_broadcast_id()
# Log the final, fully-updated configuration just before creating the Multicaster
log.info('Final multicaster config (transport=%s):\n %s', transport, conf.model_dump_json(indent=2))