This section mainly shares video calls in the way of operating audio devices on Android and iOS, such as mediating volume size, enabling the speaker (please specify the source of this series of articles reproduced, blog Park Rtc.blacker).
First look at the directory structure in WEBRTC that handles audio device code:
The first way is to call the Android or OBJECTC API directly, the code is as follows (Webrtcaudiotrack.java):
Manipulate audio Devices by invoking the Audiomanager class provided by Android (WebRTC is written in C + +, which calls these Java methods via JNI).
Here's how to manipulate audio devices in iOS (AUDIO_DEVICE_IMPL.MM).
2, before the introduction of another way we can think about it, since WEBRTC is implemented in C + +, you can use JNI to invoke the Android API, and then not through the JNI call Java, but directly call his underlying implementation class library it? With this question we look directly Audio Device initialization method (audio_device_impl.cc):
By compiling the instruction Webrtc_android_opensles to control how the audio device is manipulated, if enabled, the direct call to Opensles,opensles instructions is as follows:
OpenSL ES provides a C-language interface that can be called through C + +, which is basically similar to the interface that is called through Java in Android:
- Android.media.MediaPlayer
- Android.media.MediaRecorder
For Android NDK Development, the API provided by OpenSL ES with JNI calls allows you to do most of the audio operations without using Java.
Opensles_input.h content is as follows:
Opensles_output.h as follows:
Above, if there are errors or omissions, please correct or add, thank you!
Android IOS WebRTC Audio Video Development Summary (16)