#!/bin/sh# This script is used to build the webrtc static library.# You need to put it into the webrtc source code root directory.rm-rfout# check the paramsif[$#!=1];thenecho"Usage:"echo" sh build_webrtc_static_lib.sh STATIC_MODULE_NAME"echo"For example:"echo" sh build_webrtc_static_lib.sh audio_processing"exit1filib_name=$1# build the 32bit static librarygngenout/intermediate/arm--args='target_os="android"target_cpu="arm"use_custom_libcxx=false'ninja-Cout/intermediate/arm${lib_name}rm-rfout/intermediate/arm/tmpmkdir-pout/intermediate/arm/tmp# copy all .o files to a temp directoryfindout/intermediate/arm/obj-name*.o|xargs-n1-I{}cp{}./out/intermediate/arm/tmpcdout/intermediate/arm/tmp# use the .o files to generate static libraryarrclib${lib_name}.a*.ocd../../../..mkdir-pout/lib/armeabi-v7acpout/intermediate/arm/tmp/lib${lib_name}.aout/lib/armeabi-v7a# build the 64bit static librarygngenout/intermediate/arm64--args='target_os="android"target_cpu="arm64"use_custom_libcxx=false'ninja-Cout/intermediate/arm64${lib_name}rm-rfout/intermediate/arm64/tmpmkdir-pout/intermediate/arm64/tmp# copy all .o files to a temp directoryfindout/intermediate/arm64/obj-name*.o|xargs-n1-I{}cp{}./out/intermediate/arm64/tmpcdout/intermediate/arm64/tmp# use the .o files to generate static libraryarrclib${lib_name}.a*.ocd../../../..mkdir-pout/lib/arm64-v8acpout/intermediate/arm64/tmp/lib${lib_name}.aout/lib/arm64-v8arm-rfout/intermediate# copy the header filesmkdir-pout/includeheaders=`find.-name'*.h'`forheaderin$headersdoecho"copy header path: ${header}"cp--parents${header}out/includedone
#include<rtc_base/thread.h>extern"C"JNIEXPORTjstringJNICALLJava_com_glumes_nativelib_NativeLib_stringFromJNI(JNIEnv*env,jobject/* this */){std::stringhello="Hello from C++";autothread=rtc::Thread::Create();thread->Start();thread->BlockingCall([]{LOGI("RUN BLOCK CALL");});thread->Stop();returnenv->NewStringUTF(hello.c_str());}
后续会基于这个工程进行更多 WebRTC API 的探索,争取将 WebRTC 相关的代码设计应用到我们的项目中。