Change audio input (microphone) and output (speakers) in MacOS

947 views
Skip to first unread message

Yuval Tal

unread,
Feb 7, 2020, 6:46:33 AM2/7/20
to discuss-webrtc
Hello,

I've been struggling to find a way to change the microphone and speakers that WebRTC.framework uses. Is there an API call that needs to be made to switch them or is there some kind of global settings that the current process has (not system default)? Can I change the device during a session?

Thank you,

-Yuval

Nishant Kashyap

unread,
Feb 7, 2020, 8:30:48 AM2/7/20
to discuss-webrtc
Hi Yuval,

Please check the link. This will put you in the right direction.

Thanks

Yuval Tal

unread,
Feb 7, 2020, 8:47:47 AM2/7/20
to discuss...@googlegroups.com
Thank you but I’m looking for an objective C API to call into the WebRTC.framework. Sorry  if I wasn’t clear. 

--

---
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/80157af2-2fde-4781-a20d-1533f9a02a50%40googlegroups.com.
--
Sent from Gmail Mobile

Henrik Andreasson

unread,
Feb 7, 2020, 8:47:53 AM2/7/20
to discuss-webrtc
Given that WebRTC.framework is used in the question I assume that it is about native WebRTC for mobile platforms.
If so, WebRTC does not contain any support for device selection. Instead the client must implement it using default APIs in Android and iOS.

--

Henrik Andreasson

unread,
Feb 7, 2020, 8:59:39 AM2/7/20
to discuss-webrtc
There is none. It is up to the client to add support for it or to rely on the built-in (default) handling.

Yuval Tal

unread,
Feb 7, 2020, 9:03:56 AM2/7/20
to discuss...@googlegroups.com
Thank you. I was referring actually to MacOS. In IOS there is AVAudioSessiom, but there is no clear alternative in MacOS. Any pointers would be helpful. Thanks again. 

Henrik Andreasson

unread,
Feb 7, 2020, 9:14:01 AM2/7/20
to discuss-webrtc
On MacOS you should be able to use these (rather old and not well maintained) enumeration APIs.
But they are not supported from the top layer (Peerconnection). Instead you must create your own ADM and inject it the PCF like so.
That will give you access to the required enumeration APIs. If you don't inject your own ADM, a default ADM will be created internally
and it can't be accessed from "the outside".

Yuval Tal

unread,
Feb 8, 2020, 10:59:07 PM2/8/20
to discuss...@googlegroups.com
Thanks. When you say inject, you mean that I need to create my own version of RTCPeerConnectionFactory? Because the version that is part of the SDK, specifically passes nullptr on MacOS.  And then I need to add my own Objective-C methods to call the ADM methods? I'm just not sure how other projects use this SDK with these limitations of controlling audio input/output.

Thanks!

-Yuval


Alexandre GOUAILLARD

unread,
Feb 9, 2020, 2:45:05 AM2/9/20
to discuss...@googlegroups.com
On Sun, Feb 9, 2020 at 4:58 AM Yuval Tal <yuv...@gmail.com> wrote:
Thanks. When you say inject, you mean that I need to create my own version of RTCPeerConnectionFactory? Because the version that is part of the SDK, specifically passes nullptr on MacOS.  And then I need to add my own Objective-C methods to call the ADM methods? I'm just not sure how other projects use this SDK with these limitations of controlling audio input/output.

No. 

You need to create your own ADM class and instance. This ADM can for example use the enumeration API internally. Then you should use the specific RTCPeerConnectionFactory
 constructor that allows you to provide the pointer to the ADM object you would have created. Then, you have access to the ADM object and can use its API.

the alternative is to use the default simpler RTCPeerConnectionFactory constructor, in which case the ADM is created automatically for you but you do not have access to it, and cannot manipulate audio devices (change input, output, ...).

We have an example in C++ here:

HTH



--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Message has been deleted

Rahav Lussato

unread,
Feb 10, 2020, 9:00:45 AM2/10/20
to discuss-webrtc
Hi, I have the same issue.
I don't get the RTCPeerConnectionFactory contractor with the option to inject adm in WebRTC.Framework when building webrtc framework for working in swift. 

I see that "RTCPeerConnectionFactory+Native.h" is not in the BUILD.gn file under "if (is_mac)" on line 1388, when i add it and run the build again with:

gn gen out/Default --args='is_debug=false use_rtti=true rtc_include_tests=false use_custom_libcxx=false'
ninja -v -C out/Default -j7

i get ninja: error: '../../sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h', needed by 'obj/sdk/copy_framework_headers_mac_framework_objc.stamp', missing and no known rule to make it

Elise Monaghan

unread,
Jun 23, 2021, 9:49:15 PM6/23/21
to discuss-webrtc
Any insight here? I too am trying to find a constructor for RTCPeerConnectionFactory that allows me to pass in a pointer to a (custom) ADM, but no luck ....
Reply all
Reply to author
Forward
0 new messages