Reputation: 5788
Update
Regarding the 1 Question, is it possible to make, throw clear WebRTC version (without libraries customization)? For example, can we manipulate with local AudioStream object, which we putted in PeerConnection?
And additional updates for the 2-nd. Can we change some WebRTC native C code, and continue building with depot tools scripts? Or we also should create our own scripts, for generation .so and .jar libraries? And what about Android changes. How we can build JNI changes, for new .jar library, in case of some changes in native C source?
Upvotes: 2
Views: 676
Reputation: 782
1) Webrtc libjingle uses android framework only for capturing audio/video data. In case of audio it uses android AudioRecord APIs for recording audio from the phone mic and passing it to the native which encode the data in suitable format and pass it to the remote end. Now, will give you few pointers in code like where exactly you can look for introducing your own audio instead of using phone mic. Check "WebRtcAudioRecord.java", where we use AudioRecord framework for capturing mic data as below :
int bytesRead = audioRecord.read(byteBuffer, byteBuffer.capacity());
This same byteBuffer is passed to the native for audio encoding and sending it to remote end :
nativeCacheDirectBufferAddress(byteBuffer, nativeAudioRecord);
So, all you need to do is copy your audio data in byteBuffer in a loop instead of reading from mic.
2) You can build webrtc source code as mentioned here. Just to summarize all the steps together, you can use beloow script:
#!/bin/sh
set -e
export GYP_DEFINES="OS=android"
if [ -f .gclient ];
then
echo "gclient exists so go ahead"
cd src
else
fetch --nohooks webrtc_android
cd src
git fetch --tags
git checkout branch-heads/55
gclient sync
./build/install-build-deps.sh
./build/install-build-deps-android.sh
gclient sync
gn gen out/x86 --args='target_os="android" target_cpu="x86" is_debug=false dcheck_always_on=true symbol_level=1 is_component_build=false'
gn gen out/x64 --args='target_os="android" target_cpu="x64" is_debug=false dcheck_always_on=true symbol_level=1 is_component_build=false'
gn gen out/arm64 --args='target_os="android" target_cpu="arm64" is_debug=false dcheck_always_on=true symbol_level=1 is_component_build=false'
gn gen out/armv7 --args='target_os="android" target_cpu="arm" is_debug=false dcheck_always_on=true symbol_level=1 is_component_build=false'
fi
ninja -C out/arm64
ninja -C out/armv7
ninja -C out/x86
ninja -C out/x64
This script will build android libjingle v55 for all the architecture, so that you can use the binary on device as well as on simulator.
Upvotes: 2