Skip to content

Commit 30ee183

Browse files
committed
rename methods to be more clear
1 parent c8f8c0c commit 30ee183

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

examples/local_audio/full_duplex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ async def main() -> None:
2222
devices = rtc.MediaDevices()
2323

2424
# Open microphone with AEC and prepare a player for remote audio feeding AEC reverse stream
25-
mic = devices.open_microphone(enable_aec=True)
26-
player = devices.open_output_player(apm_for_reverse=mic.apm)
25+
mic = devices.open_input(enable_aec=True)
26+
player = devices.open_output(apm_for_reverse=mic.apm)
2727

2828
# Mixer for all remote audio streams
2929
mixer = rtc.AudioMixer(sample_rate=48000, num_channels=1)

examples/local_audio/publish_mic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def main() -> None:
2121

2222
# Create media devices helper and open default microphone with AEC enabled
2323
devices = rtc.MediaDevices()
24-
mic = devices.open_microphone(enable_aec=True)
24+
mic = devices.open_input(enable_aec=True)
2525

2626
try:
2727
await room.connect(url, token)

livekit-rtc/livekit/rtc/media_devices.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
This module provides a small, Pythonic helper around native audio I/O for
3535
LiveKit RTC usage:
3636
37-
- Capture the default microphone and feed frames into `rtc.AudioSource`.
37+
- Capture the default audio input device and feed frames into `rtc.AudioSource`.
3838
- Optionally enable audio processing via `rtc.AudioProcessingModule` (AEC,
3939
noise suppression, high-pass filter, AGC). Frames are processed in 10 ms
4040
chunks as required by APM.
4141
- Play arbitrary audio frames to the default speaker. When AEC is enabled on
42-
the microphone, the `OutputPlayer` can feed the APM reverse stream so echo
42+
the input, the `OutputPlayer` can feed the APM reverse stream so echo
4343
cancellation has access to render (speaker) audio.
4444
4545
Notes on AEC wiring:
@@ -83,8 +83,8 @@ def get_output_delay(self) -> float:
8383

8484

8585
@dataclass
86-
class MicrophoneCapture:
87-
"""Holds resources for an active microphone capture.
86+
class InputCapture:
87+
"""Holds resources for an active audio input capture.
8888
8989
Attributes:
9090
source: `rtc.AudioSource` that receives captured frames. This can be
@@ -239,8 +239,8 @@ class MediaDevices:
239239
conventions and the `sounddevice` library. It provides:
240240
241241
- Device enumeration helpers.
242-
- Microphone capture into `rtc.AudioSource` with optional APM processing.
243-
- Output player that can feed APM reverse stream for AEC.
242+
- Audio input capture into `rtc.AudioSource` with optional APM processing.
243+
- Audio output player that can feed APM reverse stream for AEC.
244244
245245
Design notes:
246246
- APM operates on 10 ms frames; this module slices input/output audio into
@@ -301,25 +301,25 @@ def default_output_device(self) -> Optional[int]:
301301
return dev[1] if isinstance(dev, (list, tuple)) else None
302302

303303
# Capture / Playback
304-
def open_microphone(
304+
def open_input(
305305
self,
306306
*,
307307
enable_aec: bool = True,
308308
noise_suppression: bool = True,
309309
high_pass_filter: bool = True,
310310
auto_gain_control: bool = True,
311311
input_device: Optional[int] = None,
312-
queue_capacity: int = 200,
312+
queue_capacity: int = 50,
313313
input_channel_index: Optional[int] = None,
314-
) -> MicrophoneCapture:
315-
"""Open the default (or chosen) microphone and start capture.
314+
) -> InputCapture:
315+
"""Open the default (or chosen) audio input device and start capture.
316316
317317
Frames are sliced into 10 ms chunks. If any processing option is enabled,
318318
an `AudioProcessingModule` is created and applied to each frame before it
319319
is queued for `AudioSource.capture_frame`.
320320
321321
To enable AEC end-to-end, pass the returned `apm` to
322-
`open_output_player(apm_for_reverse=...)` and route remote audio through
322+
`open_output(apm_for_reverse=...)` and route remote audio through
323323
that player so reverse frames are provided to APM.
324324
325325
Args:
@@ -333,7 +333,7 @@ def open_microphone(
333333
only that channel is opened (via sounddevice mapping) and used as mono input.
334334
335335
Returns:
336-
MicrophoneCapture: Holder with `source`, `apm`, and `aclose()`.
336+
InputCapture: Holder with `source`, `apm`, and `aclose()`.
337337
"""
338338
loop = self._loop
339339
source = AudioSource(self._in_sr, self._channels, loop=loop)
@@ -452,15 +452,15 @@ async def _pump() -> None:
452452
pass
453453

454454
task = asyncio.create_task(_pump())
455-
return MicrophoneCapture(
455+
return InputCapture(
456456
source=source,
457457
input_stream=input_stream,
458458
task=task,
459459
apm=apm,
460460
delay_estimator=delay_estimator,
461461
)
462462

463-
def open_output_player(
463+
def open_output(
464464
self,
465465
*,
466466
apm_for_reverse: Optional[AudioProcessingModule] = None,
@@ -469,7 +469,7 @@ def open_output_player(
469469
"""Create an `OutputPlayer` for rendering and (optionally) AEC reverse.
470470
471471
Args:
472-
apm_for_reverse: Pass the APM used by the microphone to enable AEC.
472+
apm_for_reverse: Pass the APM used by the audio input device to enable AEC.
473473
output_device: Optional output device index (default system device if None).
474474
"""
475475
return OutputPlayer(

0 commit comments

Comments
 (0)