How to Change Audio Input and Output Devices in WebRTC on macOS with SwiftUI?

195 views
Skip to first unread message

Long Enertee

unread,
Aug 20, 2024, 4:50:07 AM8/20/24
to discuss-webrtc

Hi everyone,

I am currently working on a macOS application using WebRTC and SwiftUI. I need to enable users to dynamically switch audio input (microphone) and output (speakers) devices within the app, without affecting the system-wide settings.

I’ve implemented custom audio handling using AVAudioEngine and AVCaptureDevice to manage audio input and output. However, I am encountering some issues integrating these changes with WebRTC.

Specifically:

1. The WebRTC library for macOS does not include RTCAudioDevice, so I manually added RTCAudioDevice to create an AudioDeviceModule. Although there are no errors when adding it, I am unable to send and receive audio through WebRTC.

2. I need guidance on:

Dynamically changing the audio input device (microphone) used by WebRTC.

Changing the audio output device (speakers) for WebRTC.

Ensuring that these changes take effect immediately without disrupting the ongoing WebRTC session.


If anyone has experience with this issue or can point me to relevant resources or examples, I would greatly appreciate it!


Thank you in advance for your help!


Best regards

Henrik Andreasson

unread,
Aug 20, 2024, 5:29:41 AM8/20/24
to discuss...@googlegroups.com
Not sure if it is exactly what you need but here is an example of an externally injected ADM https://github.com/mstyura/RTCAudioDevice

--
This list falls under the WebRTC Code of Conduct - https://webrtc.org/support/code-of-conduct.
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/070b3efc-3258-4b40-92a8-91cd40f795c5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages