Add support for Android x86_64 and ARM64

This commit is contained in:
Doubango Telecom 2019-04-30 15:01:39 +02:00
parent 671dbaaf77
commit 7604ae6761
62 changed files with 454 additions and 385 deletions

View File

@ -101,17 +101,21 @@ if [ x$SSL = "xno" ]; then
export OPTIONS="${OPTIONS} --without-ssl"
fi
for arch in armv5te armv7-a armv7-a-neon x86
for arch in armv5te armv7-a armv7-a-neon arm64 x86 x64
do
if [ $arch = "x86" ]; then \
export HOST=i686-linux-android; \
elif [ $arch = "x64" ]; then \
export HOST=x86_64-linux-android; \
elif [ $arch = "arm64" ]; then \
export HOST=aarch64-linux-android; \
else \
export HOST=arm-linux-androideabi; \
fi \
echo -e building for ARCH="$arch, OPTIONS=$OPTIONS.... \n"
./configure --host=$HOST --with-android-cpu=$arch --prefix=$HOME/$arch --without-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
./configure --host=$HOST --with-android-cpu=$arch --prefix=$HOME/$arch --with-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
make clean
make uninstall
make all
@ -124,7 +128,9 @@ done
mkdir -p $HOME/imsdroid/libs/armeabi
mkdir -p $HOME/imsdroid/libs/armeabi-v7a
mkdir -p $HOME/imsdroid/libs/arm64-v8a
mkdir -p $HOME/imsdroid/libs/x86
mkdir -p $HOME/imsdroid/libs/x86_64
mkdir -p $HOME/imsdroid/libs/mips
cp --force $HOME/armv5te/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi/libtinyWRAP.so
@ -134,7 +140,13 @@ cp --force $HOME/armv7-a/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7
cp --force $HOME/armv7-a/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libplugin_audio_opensles.so
cp --force $HOME/armv7-a-neon/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libtinyWRAP_neon.so
cp --force $HOME/arm64/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/arm64-v8a/libtinyWRAP.so
cp --force $HOME/arm64/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/arm64-v8a/libplugin_audio_opensles.so
cp --force $HOME/x86/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/x86/libtinyWRAP.so
cp --force $HOME/x86/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/x86/libplugin_audio_opensles.so
cp --force $HOME/x64/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/x86_64/libtinyWRAP.so
cp --force $HOME/x64/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/x86_64/libplugin_audio_opensles.so

View File

@ -22,7 +22,15 @@ case "$host" in
target_os=android
android_cpu=armv5te
;;
i686-*-linux-android)
aarch64-*-linux-android)
target_os=android
android_cpu=arm64
;;
x86_64-*-linux-android)
target_os=android
android_cpu=x64
;;
i686-*-linux-android)
target_os=android
android_cpu=x86
;;
@ -37,7 +45,9 @@ AC_ARG_WITH(android-cpu,
armv5te: ARMv5TE
armv7-a: ARMv7-a *without* NEON
armv7-a-neon: ARMv7-a *with* NEON
x86: X86],
arm64: aarch64
x86: X86
x64: X86_64],
[ android_cpu=$withval ])
### ANDROID-TOOLCHAIN (http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html)
@ -48,14 +58,31 @@ if test "$target_os" = "android"; then
export ANDROID_PREFIX=i686-linux-android
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-DANDROID=1'
AC_SUBST(TARGET_ARCH, "x86")
;;
x64)
export SYSROOT=$NDK/platforms/android-21/arch-x86_64
export ANDROID_PREFIX=x86_64-linux-android
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86_64
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86_64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-DANDROID=1'
AC_SUBST(TARGET_ARCH, "x86")
;;
arm64)
export ANDROID_PREFIX=aarch64-linux-android
export SYSROOT=$NDK/platforms/android-21/arch-arm64
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-arm64
$NDK/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-DANDROID=1 -D__ARMEL__'
AC_SUBST(TARGET_ARCH, "arm")
;;
armv7-a)
export ANDROID_PREFIX=arm-linux-androideabi
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp'
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -DANDROID=1 -D__ARMEL__'
export LDFLAGS='-Wl,--fix-cortex-a8'
AC_SUBST(TARGET_ARCH, "arm")
;;
@ -64,7 +91,7 @@ if test "$target_os" = "android"; then
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a-neon
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon -DANDROID=1'
export LDFLAGS='-Wl,--fix-cortex-a8'
AC_SUBST(TARGET_ARCH, "arm")
;;
@ -73,13 +100,14 @@ if test "$target_os" = "android"; then
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-armv5te
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-DANDROID=1 -D__ARMEL__'
AC_SUBST(TARGET_ARCH, "arm")
;;
esac
AC_SUBST(NDK, $NDK)
export CFLAGS="${CFLAGS} -DANDROID=1"
export CFLAGS="${CFLAGS} -fPIC"
export CPPFLAGS=$CFLAGS
export LDFLAGS="${LDFLAGS} -lc -lm -lgcc"
@ -401,10 +429,10 @@ AC_ARG_WITH(ssl,
if test $want_ssl != no; then
# check for lib and headers
AC_CHECK_HEADERS(openssl/ssl.h,
AC_CHECK_LIB(ssl, SSL_library_init, AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 1, HAVE_OPENSSL) [have_ssl=yes] LIBSSL_LIBADD="${LIBSSL_LIBADD} -lssl",
AC_CHECK_LIB(ssl, SSL_connect, AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 1, HAVE_OPENSSL) [have_ssl=yes] LIBSSL_LIBADD="${LIBSSL_LIBADD} -lssl",
AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 0, HAVE_OPENSSL) [have_ssl=no], [-lcrypto]
))
AC_CHECK_LIB(crypto, BN_init,
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data,
LIBSSL_LIBADD="${LIBSSL_LIBADD} -lcrypto"
AC_CHECK_LIB(ssl, SSL_CTX_set_tlsext_use_srtp, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS_SRTP, 1, HAVE_OPENSSL_DTLS_SRTP) [have_dtls_srtp=yes],[],[-lcrypto])
AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS) [have_dtls=yes],[],[-lcrypto])
@ -465,7 +493,7 @@ AM_CONDITIONAL([USE_FFMPEG], [test $have_ffmpeg = yes])
########################################################
# X264
########################################################
AM_CONDITIONAL(USE_X264, [test $target_os:$enable_gpl = android:yes]) # X264 is always there for Android and statically linked
AM_CONDITIONAL(USE_X264, [test $target_os:$enable_gpl:$have_ffmpeg = android:yes:yes]) # X264 is always there for Android and statically linked
AC_SUBST(LIBX264_LIBADD, "-lx264")
AC_ARG_WITH(x264, [ --with-x264 IMPORTANT: deprecated to be removed ],[], [])

View File

@ -30,60 +30,60 @@
#include "tsk_debug.h"
typedef enum PLUGIN_INDEX_E {
PLUGIN_INDEX_AUDIO_CONSUMER,
PLUGIN_INDEX_AUDIO_PRODUCER,
PLUGIN_INDEX_COUNT
PLUGIN_INDEX_AUDIO_CONSUMER,
PLUGIN_INDEX_AUDIO_PRODUCER,
PLUGIN_INDEX_COUNT
}
PLUGIN_INDEX_T;
int __plugin_get_def_count()
{
return PLUGIN_INDEX_COUNT;
return PLUGIN_INDEX_COUNT;
}
tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
{
switch(index) {
case PLUGIN_INDEX_AUDIO_CONSUMER:
return tsk_plugin_def_type_consumer;
case PLUGIN_INDEX_AUDIO_PRODUCER:
return tsk_plugin_def_type_producer;
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_type_none;
}
}
switch (index) {
case PLUGIN_INDEX_AUDIO_CONSUMER:
return tsk_plugin_def_type_consumer;
case PLUGIN_INDEX_AUDIO_PRODUCER:
return tsk_plugin_def_type_producer;
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_type_none;
}
}
}
tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
{
switch(index) {
case PLUGIN_INDEX_AUDIO_CONSUMER:
case PLUGIN_INDEX_AUDIO_PRODUCER: {
return tsk_plugin_def_media_type_audio;
}
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_media_type_none;
}
}
switch (index) {
case PLUGIN_INDEX_AUDIO_CONSUMER:
case PLUGIN_INDEX_AUDIO_PRODUCER: {
return tsk_plugin_def_media_type_audio;
}
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_media_type_none;
}
}
}
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
{
switch(index) {
case PLUGIN_INDEX_AUDIO_CONSUMER: {
return audio_consumer_opensles_plugin_def_t;
}
case PLUGIN_INDEX_AUDIO_PRODUCER: {
return audio_producer_opensles_plugin_def_t;
}
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_null;
}
}
switch (index) {
case PLUGIN_INDEX_AUDIO_CONSUMER: {
return audio_consumer_opensles_plugin_def_t;
}
case PLUGIN_INDEX_AUDIO_PRODUCER: {
return audio_producer_opensles_plugin_def_t;
}
default: {
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_null;
}
}
}
//
@ -91,25 +91,25 @@ tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
//
typedef struct audio_opensles_instance_s {
TSK_DECLARE_OBJECT;
TSK_DECLARE_OBJECT;
uint64_t sessionId;
uint64_t sessionId;
bool isStarted;
bool isStarted;
bool isConsumerPrepared;
bool isConsumerStarted;
bool isProducerPrepared;
bool isProducerStarted;
bool isConsumerPrepared;
bool isConsumerStarted;
bool isProducerPrepared;
bool isProducerStarted;
bool isSpeakerAvailable;
bool isPlayoutAvailable;
bool isRecordingAvailable;
bool isSpeakerAvailable;
bool isPlayoutAvailable;
bool isRecordingAvailable;
SLAudioDevice* device;
SLAudioDeviceCallbackImpl* callback;
SLAudioDevice* device;
SLAudioDeviceCallbackImpl* callback;
TSK_DECLARE_SAFEOBJ;
TSK_DECLARE_SAFEOBJ;
}
audio_opensles_instance_t;
typedef tsk_list_t audio_opensles_instances_L_t;
@ -118,442 +118,442 @@ static audio_opensles_instances_L_t* __audioInstances = tsk_null;
static tsk_object_t* audio_opensles_instance_ctor(tsk_object_t * self, va_list * app)
{
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
if(audioInstance) {
tsk_safeobj_init(audioInstance);
}
return self;
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
if (audioInstance) {
tsk_safeobj_init(audioInstance);
}
return self;
}
static tsk_object_t* audio_opensles_instance_dtor(tsk_object_t * self)
{
AUDIO_OPENSLES_DEBUG_INFO("Audio Instance destroyed");
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
if(audioInstance) {
tsk_safeobj_lock(audioInstance);
if(audioInstance->device) {
audioInstance->device->SetCallback(NULL);
audioInstance->device->Terminate();
delete audioInstance->device;
audioInstance->device = tsk_null;
}
if(audioInstance->callback) {
delete audioInstance->callback;
audioInstance->callback = tsk_null;
}
tsk_safeobj_unlock(audioInstance);
AUDIO_OPENSLES_DEBUG_INFO("Audio Instance destroyed");
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
if (audioInstance) {
tsk_safeobj_lock(audioInstance);
if (audioInstance->device) {
audioInstance->device->SetCallback(NULL);
audioInstance->device->Terminate();
delete audioInstance->device;
audioInstance->device = tsk_null;
}
if (audioInstance->callback) {
delete audioInstance->callback;
audioInstance->callback = tsk_null;
}
tsk_safeobj_unlock(audioInstance);
tsk_safeobj_deinit(audioInstance);
}
return self;
tsk_safeobj_deinit(audioInstance);
}
return self;
}
static int audio_opensles_instance_cmp(const tsk_object_t *_ai1, const tsk_object_t *_ai2)
{
return ((int)_ai1 - (int)_ai2);
return (int)((uintptr_t)_ai1 - (uintptr_t)_ai2);
}
static const tsk_object_def_t audio_opensles_instance_def_s = {
sizeof(audio_opensles_instance_t),
audio_opensles_instance_ctor,
audio_opensles_instance_dtor,
audio_opensles_instance_cmp,
sizeof(audio_opensles_instance_t),
audio_opensles_instance_ctor,
audio_opensles_instance_dtor,
audio_opensles_instance_cmp,
};
const tsk_object_def_t *audio_opensles_instance_def_t = &audio_opensles_instance_def_s;
audio_opensles_instance_handle_t* audio_opensles_instance_create(uint64_t sessionId)
{
audio_opensles_instance_t* audioInstance = tsk_null;
audio_opensles_instance_t* audioInstance = tsk_null;
// create list used to hold instances
if(!__audioInstances && !(__audioInstances = tsk_list_create())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new list");
return tsk_null;
}
// create list used to hold instances
if (!__audioInstances && !(__audioInstances = tsk_list_create())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new list");
return tsk_null;
}
//= lock the list
tsk_list_lock(__audioInstances);
//= lock the list
tsk_list_lock(__audioInstances);
// find the instance from the list
const tsk_list_item_t* item;
tsk_list_foreach(item, __audioInstances) {
if(((audio_opensles_instance_t*)item->data)->sessionId == sessionId) {
audioInstance = (audio_opensles_instance_t*)tsk_object_ref(item->data);
break;
}
}
// find the instance from the list
const tsk_list_item_t* item;
tsk_list_foreach(item, __audioInstances) {
if (((audio_opensles_instance_t*)item->data)->sessionId == sessionId) {
audioInstance = (audio_opensles_instance_t*)tsk_object_ref(item->data);
break;
}
}
if(!audioInstance) {
audio_opensles_instance_t* _audioInstance;
if(!(_audioInstance = (audio_opensles_instance_t*)tsk_object_new(&audio_opensles_instance_def_s))) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new audio instance");
goto done;
}
if (!audioInstance) {
audio_opensles_instance_t* _audioInstance;
if (!(_audioInstance = (audio_opensles_instance_t*)tsk_object_new(&audio_opensles_instance_def_s))) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new audio instance");
goto done;
}
if(!(_audioInstance->device = new SLAudioDevice())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio device");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if (!(_audioInstance->device = new SLAudioDevice())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio device");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if(!(_audioInstance->callback = new SLAudioDeviceCallbackImpl())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio transport");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if((_audioInstance->device->SetCallback(_audioInstance->callback))) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::RegisterAudioCallback() failed");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if (!(_audioInstance->callback = new SLAudioDeviceCallbackImpl())) {
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio transport");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if ((_audioInstance->device->SetCallback(_audioInstance->callback))) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::RegisterAudioCallback() failed");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if((_audioInstance->device->Init())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::Init() failed");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
if ((_audioInstance->device->Init())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::Init() failed");
TSK_OBJECT_SAFE_FREE(_audioInstance);
goto done;
}
_audioInstance->sessionId = sessionId;
audioInstance = _audioInstance;
tsk_list_push_back_data(__audioInstances, (void**)&_audioInstance);
}
_audioInstance->sessionId = sessionId;
audioInstance = _audioInstance;
tsk_list_push_back_data(__audioInstances, (void**)&_audioInstance);
}
done:
//= unlock the list
tsk_list_unlock(__audioInstances);
//= unlock the list
tsk_list_unlock(__audioInstances);
return audioInstance;
return audioInstance;
}
int audio_opensles_instance_prepare_consumer(audio_opensles_instance_handle_t* _self, tmedia_consumer_t** _consumer)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
const struct audio_consumer_opensles_s* consumer = (const struct audio_consumer_opensles_s*)*_consumer;
if(!self || !self->device || !self->callback || !_consumer || !*_consumer) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
const struct audio_consumer_opensles_s* consumer = (const struct audio_consumer_opensles_s*)*_consumer;
if (!self || !self->device || !self->callback || !_consumer || !*_consumer) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
if(self->isConsumerPrepared) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already prepared");
return 0;
}
if (self->isConsumerPrepared) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already prepared");
return 0;
}
int ret;
bool _bool;
int ret;
bool _bool;
tsk_safeobj_lock(self);
tsk_safeobj_lock(self);
self->callback->SetConsumer(consumer);
self->callback->SetConsumer(consumer);
if((ret = self->device->SpeakerIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() failed with error code=%d", ret);
}
else {
if(!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() returned false");
}
self->isSpeakerAvailable = _bool;
}
if ((ret = self->device->SpeakerIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() failed with error code=%d", ret);
}
else {
if (!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() returned false");
}
self->isSpeakerAvailable = _bool;
}
if((ret = self->device->InitSpeaker())) {
AUDIO_OPENSLES_DEBUG_ERROR("InitSpeaker() failed with error code=%d", ret);
}
else if((ret = self->device->SetSpeakerOn(audio_consumer_opensles_is_speakerOn(consumer)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetSpeakerOn() failed with error code=%d", ret);
}
if ((ret = self->device->InitSpeaker())) {
AUDIO_OPENSLES_DEBUG_ERROR("InitSpeaker() failed with error code=%d", ret);
}
else if ((ret = self->device->SetSpeakerOn(audio_consumer_opensles_is_speakerOn(consumer)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetSpeakerOn() failed with error code=%d", ret);
}
if((ret = self->device->PlayoutIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() failed with error code =%d", ret);
}
else {
if(!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() returned false");
}
self->isPlayoutAvailable = _bool;
}
if ((ret = self->device->PlayoutIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() failed with error code =%d", ret);
}
else {
if (!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() returned false");
}
self->isPlayoutAvailable = _bool;
}
if((ret = self->device->SetStereoPlayout(((*_consumer)->audio.in.channels == 2)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoPlayout(%d==2) failed with error code=%d", (*_consumer)->audio.in.channels, ret);
}
if ((ret = self->device->SetStereoPlayout(((*_consumer)->audio.in.channels == 2)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoPlayout(%d==2) failed with error code=%d", (*_consumer)->audio.in.channels, ret);
}
//if((ret = self->device->SetPlayoutBuffer(AudioDeviceModule::kFixedBufferSize, (*_consumer)->audio.ptime))){
// AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", (*_consumer)->audio.ptime, ret);
//}
// always request 10ms buffers
if((ret = self->device->SetPlayoutBuffer(10))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", 10, ret);
}
//if((ret = self->device->SetPlayoutBuffer(AudioDeviceModule::kFixedBufferSize, (*_consumer)->audio.ptime))){
// AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", (*_consumer)->audio.ptime, ret);
//}
// always request 10ms buffers
if ((ret = self->device->SetPlayoutBuffer(10))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", 10, ret);
}
int playoutSampleRate = (*_consumer)->audio.out.rate ? (*_consumer)->audio.out.rate : (*_consumer)->audio.in.rate;
if((ret = self->device->SetPlayoutSampleRate(playoutSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutSampleRate(%d) failed with error code=%d", playoutSampleRate, ret);
}
int playoutSampleRate = (*_consumer)->audio.out.rate ? (*_consumer)->audio.out.rate : (*_consumer)->audio.in.rate;
if ((ret = self->device->SetPlayoutSampleRate(playoutSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutSampleRate(%d) failed with error code=%d", playoutSampleRate, ret);
}
if((ret = self->device->InitPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitPlayout() failed with error code = %d", ret);
goto done;
}
if ((ret = self->device->InitPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitPlayout() failed with error code = %d", ret);
goto done;
}
// init output parameters
if((ret = self->device->StereoPlayout(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("StereoPlayout() failed with error code=%d", ret);
}
else {
(*_consumer)->audio.out.channels = (_bool ? 2 : 1);
}
if((ret = self->device->PlayoutSampleRate(&playoutSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutSampleRate() failed with error code=%d", ret);
}
else {
(*_consumer)->audio.out.rate = playoutSampleRate;
}
// init output parameters
if ((ret = self->device->StereoPlayout(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("StereoPlayout() failed with error code=%d", ret);
}
else {
(*_consumer)->audio.out.channels = (_bool ? 2 : 1);
}
if ((ret = self->device->PlayoutSampleRate(&playoutSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutSampleRate() failed with error code=%d", ret);
}
else {
(*_consumer)->audio.out.rate = playoutSampleRate;
}
done:
tsk_safeobj_unlock(self);
tsk_safeobj_unlock(self);
self->isConsumerPrepared = (ret == 0);
self->isConsumerPrepared = (ret == 0);
return ret;
return ret;
}
int audio_opensles_instance_prepare_producer(audio_opensles_instance_handle_t* _self, tmedia_producer_t** _producer)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device || !self->callback || !_producer || !*_producer) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device || !self->callback || !_producer || !*_producer) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
if(self->isProducerPrepared) {
AUDIO_OPENSLES_DEBUG_WARN("Producer already prepared");
return 0;
}
if (self->isProducerPrepared) {
AUDIO_OPENSLES_DEBUG_WARN("Producer already prepared");
return 0;
}
int ret;
bool _bool;
int ret;
bool _bool;
tsk_safeobj_lock(self);
tsk_safeobj_lock(self);
self->callback->SetProducer((const struct audio_producer_opensles_s*)*_producer);
self->callback->SetProducer((const struct audio_producer_opensles_s*)*_producer);
if((ret = self->device->RecordingIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() failed with error code =%d", ret);
}
else {
if(!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() returned false");
}
self->isRecordingAvailable = _bool;
}
if ((ret = self->device->RecordingIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() failed with error code =%d", ret);
}
else {
if (!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() returned false");
}
self->isRecordingAvailable = _bool;
}
if((ret = self->device->MicrophoneIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() failed with error code =%d", ret);
}
else {
if(!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() returned false");
}
else {
if((ret = self->device->InitMicrophone())) {
AUDIO_OPENSLES_DEBUG_ERROR("InitMicrophone() failed with error code =%d", ret);
}
}
}
if ((ret = self->device->MicrophoneIsAvailable(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() failed with error code =%d", ret);
}
else {
if (!_bool) {
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() returned false");
}
else {
if ((ret = self->device->InitMicrophone())) {
AUDIO_OPENSLES_DEBUG_ERROR("InitMicrophone() failed with error code =%d", ret);
}
}
}
if((ret = self->device->SetStereoRecording(((*_producer)->audio.channels == 2)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoRecording(%d==2) failed with error code=%d", (*_producer)->audio.channels, ret);
}
if ((ret = self->device->SetStereoRecording(((*_producer)->audio.channels == 2)))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoRecording(%d==2) failed with error code=%d", (*_producer)->audio.channels, ret);
}
int recordingSampleRate = (*_producer)->audio.rate;
if((ret = self->device->SetRecordingSampleRate(recordingSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetRecordingSampleRate(%d) failed with error code=%d", recordingSampleRate, ret);
}
int recordingSampleRate = (*_producer)->audio.rate;
if ((ret = self->device->SetRecordingSampleRate(recordingSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("SetRecordingSampleRate(%d) failed with error code=%d", recordingSampleRate, ret);
}
if((ret = self->device->InitRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitRecording() failed with error code = %d", ret);
goto done;
}
if ((ret = self->device->InitRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitRecording() failed with error code = %d", ret);
goto done;
}
// init output parameters
if((ret = self->device->StereoRecording(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("StereoRecording() failed with error code=%d", ret);
}
else {
(*_producer)->audio.channels = (_bool ? 2 : 1);
}
if((ret = self->device->RecordingSampleRate(&recordingSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingSampleRate() failed with error code=%d", ret);
}
else {
(*_producer)->audio.rate = recordingSampleRate;
}
// init output parameters
if ((ret = self->device->StereoRecording(&_bool))) {
AUDIO_OPENSLES_DEBUG_ERROR("StereoRecording() failed with error code=%d", ret);
}
else {
(*_producer)->audio.channels = (_bool ? 2 : 1);
}
if ((ret = self->device->RecordingSampleRate(&recordingSampleRate))) {
AUDIO_OPENSLES_DEBUG_ERROR("RecordingSampleRate() failed with error code=%d", ret);
}
else {
(*_producer)->audio.rate = recordingSampleRate;
}
done:
tsk_safeobj_unlock(self);
tsk_safeobj_unlock(self);
self->isProducerPrepared = (ret == 0);
self->isProducerPrepared = (ret == 0);
return ret;
return ret;
}
int audio_opensles_instance_start_consumer(audio_opensles_instance_handle_t* _self)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
tsk_safeobj_lock(self);
if(!self->isConsumerPrepared) {
AUDIO_OPENSLES_DEBUG_ERROR("Consumer not prepared");
goto done;
}
tsk_safeobj_lock(self);
if (!self->isConsumerPrepared) {
AUDIO_OPENSLES_DEBUG_ERROR("Consumer not prepared");
goto done;
}
if(self->isConsumerStarted) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
goto done;
}
if (self->isConsumerStarted) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
goto done;
}
if(self->isPlayoutAvailable) {
int ret;
if((ret = self->device->StartPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("StartPlayout() failed with error code = %d", ret);
}
if (self->isPlayoutAvailable) {
int ret;
if ((ret = self->device->StartPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("StartPlayout() failed with error code = %d", ret);
}
self->isConsumerStarted = self->device->Playing();
AUDIO_OPENSLES_DEBUG_INFO("isPlaying=%s", (self->isConsumerPrepared ? "true" : "false"));
}
self->isConsumerStarted = self->device->Playing();
AUDIO_OPENSLES_DEBUG_INFO("isPlaying=%s", (self->isConsumerPrepared ? "true" : "false"));
}
done:
tsk_safeobj_unlock(self);
return (self->isConsumerStarted ? 0 : -1);
tsk_safeobj_unlock(self);
return (self->isConsumerStarted ? 0 : -1);
}
int audio_opensles_instance_start_producer(audio_opensles_instance_handle_t* _self)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
tsk_safeobj_lock(self);
if(!self->isProducerPrepared) {
AUDIO_OPENSLES_DEBUG_ERROR("Producer not prepared");
goto done;
}
tsk_safeobj_lock(self);
if (!self->isProducerPrepared) {
AUDIO_OPENSLES_DEBUG_ERROR("Producer not prepared");
goto done;
}
if(self->isProducerStarted) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
goto done;
}
if (self->isProducerStarted) {
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
goto done;
}
if(self->isRecordingAvailable) {
int ret;
if((ret = self->device->StartRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("StartRecording() failed with error code = %d", ret);
}
if (self->isRecordingAvailable) {
int ret;
if ((ret = self->device->StartRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("StartRecording() failed with error code = %d", ret);
}
self->isProducerStarted = self->device->Recording();
AUDIO_OPENSLES_DEBUG_INFO("isRecording=%s", (self->isProducerStarted ? "true" : "false"));
}
self->isProducerStarted = self->device->Recording();
AUDIO_OPENSLES_DEBUG_INFO("isRecording=%s", (self->isProducerStarted ? "true" : "false"));
}
done:
tsk_safeobj_unlock(self);
return (self->isProducerStarted ? 0 : -1);
tsk_safeobj_unlock(self);
return (self->isProducerStarted ? 0 : -1);
}
int audio_opensles_instance_stop_consumer(audio_opensles_instance_handle_t* _self)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
tsk_safeobj_lock(self);
tsk_safeobj_lock(self);
if(!self->isConsumerStarted) {
goto done;
}
if (!self->isConsumerStarted) {
goto done;
}
int ret;
if((ret = self->device->StopPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("StopPlayout() failed with error code = %d", ret);
}
else {
self->isConsumerStarted = self->device->Playing();
self->isConsumerPrepared = false;
}
int ret;
if ((ret = self->device->StopPlayout())) {
AUDIO_OPENSLES_DEBUG_ERROR("StopPlayout() failed with error code = %d", ret);
}
else {
self->isConsumerStarted = self->device->Playing();
self->isConsumerPrepared = false;
}
done:
tsk_safeobj_unlock(self);
return (self->isConsumerStarted ? -1 : 0);
tsk_safeobj_unlock(self);
return (self->isConsumerStarted ? -1 : 0);
}
int audio_opensles_instance_stop_producer(audio_opensles_instance_handle_t* _self)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device || !self->callback) {
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
return -1;
}
tsk_safeobj_lock(self);
tsk_safeobj_lock(self);
if(!self->isProducerStarted) {
goto done;
}
if (!self->isProducerStarted) {
goto done;
}
int ret;
if((ret = self->device->StopRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("StopRecording() failed with error code = %d", ret);
}
else {
self->isProducerStarted = self->device->Recording();
self->isProducerPrepared = false;
}
int ret;
if ((ret = self->device->StopRecording())) {
AUDIO_OPENSLES_DEBUG_ERROR("StopRecording() failed with error code = %d", ret);
}
else {
self->isProducerStarted = self->device->Recording();
self->isProducerPrepared = false;
}
done:
tsk_safeobj_unlock(self);
return (self->isProducerStarted ? -1 : 0);
tsk_safeobj_unlock(self);
return (self->isProducerStarted ? -1 : 0);
}
int audio_opensles_instance_set_speakerOn(audio_opensles_instance_handle_t* _self, bool speakerOn)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device ) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
return self->device->SetSpeakerOn(speakerOn);
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
return self->device->SetSpeakerOn(speakerOn);
}
int audio_opensles_instance_set_microphone_volume(audio_opensles_instance_handle_t* _self, int32_t volume)
{
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if(!self || !self->device ) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
return self->device->SetMicrophoneVolume(volume);
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
if (!self || !self->device) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
return self->device->SetMicrophoneVolume(volume);
}
int audio_opensles_instance_destroy(audio_opensles_instance_handle_t** _self)
{
if(!_self || !*_self) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
tsk_list_lock(__audioInstances);
if(tsk_object_get_refcount(*_self)==1) {
tsk_list_remove_item_by_data(__audioInstances, *_self);
}
else {
tsk_object_unref(*_self);
}
tsk_list_unlock(__audioInstances);
*_self = tsk_null;
return 0;
if (!_self || !*_self) {
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
return -1;
}
tsk_list_lock(__audioInstances);
if (tsk_object_get_refcount(*_self) == 1) {
tsk_list_remove_item_by_data(__audioInstances, *_self);
}
else {
tsk_object_unref(*_self);
}
tsk_list_unlock(__audioInstances);
*_self = tsk_null;
return 0;
}

View File

@ -1,11 +1,24 @@
#!/bin/bash
export NDK=/home/android-ndk-r10e
export PREFIX_BASE=/home/openssl-1.1.0h/android
export PREFIX_BASE=$(pwd)/android
export HOST=arm-linux-androideabi
export CPU=ARM
if [ w$1 = "wx86" ]
if [ w$1 = "wx64" ]
then
echo "************************"
echo " X64 "
echo "************************"
export HOST=x86_64-linux-android
export CPU=x86_64
export SYSROOT=$NDK/platforms/android-21/arch-x86_64
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86_64
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86_64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
export LDFLAGS=''
export OS=android64
elif [ w$1 = "wx86" ]
then
echo "************************"
echo " X86 "
@ -14,10 +27,23 @@ then
export CPU=x86
export SYSROOT=$NDK/platforms/android-9/arch-x86
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86 --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86 --platform=android-9 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
export LDFLAGS=''
export OS=android-x86
elif [ w$1 = "warm64" ]
then
echo "************************"
echo " ARM64 "
echo "************************"
export HOST=aarch64-linux-android
export CPU=arm64
export SYSROOT=$NDK/platforms/android-21/arch-arm64
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-arm64
$NDK/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-fPIC -D__ARMEL__ -DWEBRTC_DETECT_ARM_NEON -DWEBRTC_ARCH_ARM_NEON' # For FFmpeg: '-fno-PIC'
export LDFLAGS=''
export OS=android64-aarch64
elif [ w$1 = "warmv7a" ]
then
echo "************************"
@ -68,6 +94,9 @@ export CXX=$ANDROID_TOOLCHAIN/bin/$HOST-g++
export AS=$ANDROID_TOOLCHAIN/bin/$HOST-gcc
export RANLIB=$ANDROID_TOOLCHAIN/bin/$HOST-ranlib
export CFLAGS="${CFLAGS} -DANDROID=1 -fPIC"
export CPPFLAGS=$CFLAGS
./Configure -no-shared --prefix=$PREFIX_BASE/$CPU --openssldir=$PREFIX_BASE/$CPU/openssl $OS -I$ANDROID_TOOLCHAIN/sysroot/ -I$ANDROID_TOOLCHAIN/sysroot/usr/include
make clean
make

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.