Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/selkies/audio_config.py: 67%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

6 statements  

1# This Source Code Form is subject to the terms of the Mozilla Public 

2# License, v. 2.0. If a copy of the MPL was not distributed with this 

3# file, You can obtain one at https://mozilla.org/MPL/2.0/. 

4 

5"""Process-wide audio-encoding knobs. 

6 

7The server resolves its audio settings once and publishes them here; the 

8vendored WebRTC codec classes (constructed deep inside the codec factory, 

9where no settings object reaches) read them at construction time. This module 

10stays dependency-free so the WebSocket-only path can publish values without 

11importing the WebRTC stack. 

12""" 

13 

14from typing import Optional 

15 

16# RED redundancy depth for RedOpusEncoder: None = the encoder's own default, 

17# 0 = primary-only (plain Opus), N = carry N redundant blocks per packet. 

18red_distance: Optional[int] = None 

19 

20 

21def set_red_distance(distance: int) -> None: 

22 """Publish the RED redundancy depth, clamped to non-negative.""" 

23 global red_distance 

24 red_distance = max(0, int(distance))