devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

Question: Getting audio playback and capture devices are currently used in the OS by default #28

Closed Stasyanych closed 1 year ago

Stasyanych commented 2 years ago

Thank you for a very useful library! I would like to know how to get audio devices that are currently used in the OS by default and is it possible to do this in the current version of the library? Thank you in advance for your answer.

devopvoid commented 2 years ago

I started to create wiki pages for this library. There is a wiki page for media devices. Right now, the Java API does not have methods implemented to retrieve the default device of the OS. BUT, the native code does have an implementation which works at least for Windows and macOS, Linux not tested with default devices.

Will add these methods to the Java implementation.

Stasyanych commented 2 years ago

Thanks a lot for the quick response.

polyn0m commented 2 years ago

@devopvoid 0.6 resolve this?

devopvoid commented 2 years ago

The version 0.6.0 should resolve this issue.

MediaDevices.getDefaultAudioRenderDevice(); (e.g. speaker) MediaDevices.getDefaultAudioCaptureDevice(); (e.g. microphone)

Please let me know if this works for you.

Stasyanych commented 2 years ago

It works for me. I'm tested this on Win10. But on MacOS getDeafultAudioRenderDevice() return empty device name if used embedded speaker.

Stasyanych commented 2 years ago

Hello, dear friend! Thanks again for the great work done. I continue to investigate the WebRTC library in more detail and found the following problems with getting a list of devices. Problems concern macOS: 1) The "deviceConnected" and "deviceDisconnected" method of the DeviceChange Listener interface returns an empty name if it has Cyrillic characters. The problem is clearly in the encoding 2) The AudioDeviceModule method.getPlayoutDevices() returns the device names correctly, but the descriptor values are missing. 3) The number of devices that mediaDevices and AudioDeviceModule returns is different. This leads to the fact that it is not always possible to correctly install the connected device in the DeviceChangeListener event I attach a screenshot that shows everything described above.

diff_devices

polyn0m commented 1 year ago

Hello @devopvoid

This issue fix in next version?

devopvoid commented 1 year ago

I'm on it. Will test the mac version this week and comment on this issue.

devopvoid commented 1 year ago

The latest snapshot now works with Cyrillic and other characters.

Stasyanych commented 1 year ago

Thanks for the fix for the Cyrillic problem. Please tell me, has anything been done with the fact that all capture devices and playout devices guid returned as null when received through AudioDeviceModule? This behavior is only on MacOS. On win10 everything is fine. In our correspondence above I attached a screenshot where you can see it. Thank you in advance for the answer!