Begin adding support for Android x86

laforge/wip
bossiel 9 years ago
parent 19922e10d5
commit c5ff66d362
  1. 20
      branches/2.0/doubango/Makefile.am
  2. 130
      branches/2.0/doubango/android_build.sh
  3. 113
      branches/2.0/doubango/bindings/Makefile.am
  4. 15
      branches/2.0/doubango/bindings/tinyWRAP.pc.in
  5. 314
      branches/2.0/doubango/configure.ac
  6. 1793
      branches/2.0/doubango/new-config.sub
  7. 39
      branches/2.0/doubango/plugins/audio_opensles/Makefile.am
  8. 324
      branches/2.0/doubango/plugins/audio_opensles/audio_opensles.cxx
  9. 20
      branches/2.0/doubango/plugins/audio_opensles/droid-makefile
  10. 15
      branches/2.0/doubango/plugins/audio_opensles/plugin_audio_opensles.pc
  11. 63
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/basic_op.h
  12. 60
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/config.h
  13. 99
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/dtx.h
  14. 629
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/ld8a.h
  15. 20
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/octet.h
  16. 17
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/oper_32b.h
  17. 23
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/sid.h
  18. 28
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/tab_dtx.h
  19. 52
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/tab_ld8a.h
  20. 50
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/typedef.h
  21. 30
      branches/2.0/doubango/thirdparties/andy/common/include/g729b/vad.h
  22. 71
      branches/2.0/doubango/thirdparties/andy/common/include/gsm.h
  23. 28
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/FrameClassify.h
  24. 53
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/LPCdecode.h
  25. 28
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/LPCencode.h
  26. 32
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/StateConstructW.h
  27. 53
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/StateSearchW.h
  28. 31
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/anaFilter.h
  29. 60
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/config.h
  30. 82
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/constants.h
  31. 59
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/createCB.h
  32. 29
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/doCPLC.h
  33. 37
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/enhancer.h
  34. 82
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/filter.h
  35. 30
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/gainquant.h
  36. 25
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/getCBvec.h
  37. 108
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/helpfun.h
  38. 24
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/hpInput.h
  39. 24
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/hpOutput.h
  40. 41
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/iCBConstruct.h
  41. 38
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/iCBSearch.h
  42. 43
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/iLBC_decode.h
  43. 221
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/iLBC_define.h
  44. 40
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/iLBC_encode.h
  45. 27
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/lsf.h
  46. 69
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/packing.h
  47. 24
      branches/2.0/doubango/thirdparties/andy/common/include/ilbc/syntFilter.h
  48. 5108
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/avcodec.h
  49. 116
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/avfft.h
  50. 95
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/dxva2.h
  51. 398
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/old_codec_ids.h
  52. 173
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/vaapi.h
  53. 226
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/vda.h
  54. 151
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/vdpau.h
  55. 113
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/version.h
  56. 168
      branches/2.0/doubango/thirdparties/andy/common/include/libavcodec/xvmc.h
  57. 69
      branches/2.0/doubango/thirdparties/andy/common/include/libavdevice/avdevice.h
  58. 50
      branches/2.0/doubango/thirdparties/andy/common/include/libavdevice/version.h
  59. 91
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/asrc_abuffer.h
  60. 131
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/avcodec.h
  61. 852
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/avfilter.h
  62. 271
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/avfiltergraph.h
  63. 150
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/buffersink.h
  64. 95
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/buffersrc.h
  65. 64
      branches/2.0/doubango/thirdparties/andy/common/include/libavfilter/version.h
  66. 2135
      branches/2.0/doubango/thirdparties/andy/common/include/libavformat/avformat.h
  67. 475
      branches/2.0/doubango/thirdparties/andy/common/include/libavformat/avio.h
  68. 89
      branches/2.0/doubango/thirdparties/andy/common/include/libavformat/version.h
  69. 43
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/adler32.h
  70. 65
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/aes.h
  71. 154
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/attributes.h
  72. 146
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/audio_fifo.h
  73. 6
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/audioconvert.h
  74. 66
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/avassert.h
  75. 7
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/avconfig.h
  76. 315
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/avstring.h
  77. 260
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/avutil.h
  78. 67
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/base64.h
  79. 77
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/blowfish.h
  80. 200
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/bprint.h
  81. 109
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/bswap.h
  82. 216
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/channel_layout.h
  83. 436
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/common.h
  84. 108
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/cpu.h
  85. 74
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/crc.h
  86. 152
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/dict.h
  87. 117
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/error.h
  88. 113
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/eval.h
  89. 144
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/fifo.h
  90. 66
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/file.h
  91. 95
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/hmac.h
  92. 200
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/imgutils.h
  93. 77
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/intfloat.h
  94. 40
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/intfloat_readwrite.h
  95. 621
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/intreadwrite.h
  96. 62
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/lfg.h
  97. 222
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/log.h
  98. 147
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/mathematics.h
  99. 49
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/md5.h
  100. 235
      branches/2.0/doubango/thirdparties/andy/common/include/libavutil/mem.h
  101. Some files were not shown because too many files have changed in this diff Show More

@ -13,15 +13,31 @@ SUBDIRS = tinySAK \
tinyMEDIA \
tinyRTP \
tinyDAV \
tinySIP
tinySIP \
\
bindings
if TARGET_OS_IS_ANDROID
SUBDIRS += plugins/audio_opensles
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = doubango.pc
if CROSS_COMPILING
install-data-hook:
echo "Cross-compilation is active. Do not run ldconfig";
else
install-data-hook:
$(MKDIR_P) $(DESTDIR)/etc/ld.so.conf.d
echo "$(libdir)" > $(DESTDIR)/etc/ld.so.conf.d/doubango.conf
ldconfig
endif
if CROSS_COMPILING
echo "Cross-compilation is active. Do not remove libs";
else
uninstall-hook:
rm -f $(DESTDIR)/etc/ld.so.conf.d/doubango.conf
rm -f $(DESTDIR)/etc/ld.so.conf.d/doubango.conf
endif

@ -0,0 +1,130 @@
#!/bin/bash
export HOME=`pwd`
### Options (change next values to 'no' to disable some features) ###
export DEBUG=no
export FFMPEG=yes
export LIBYUV=yes
export VPX=yes
export OPUS=yes
export OPENCORE_AMR=yes
export SPEEX_CODEC=yes
export SPEEX_DSP=yes
export SPEEX=yes
export ILBC=yes
export LIBGSM=yes
export G729=yes
export SRTP=yes
export WEBRTC=yes
export SSL=yes
if [ x$NDK = "x" ]
then
echo ERROR: NDK env variable is not set
exit 1;
fi
if [ x$1 = "xcommercial" ]
then
echo "************************"
echo " COMMERCIAL "
echo "************************"
export HOME=$HOME/android-projects/output/commercial
export ENABLE_NONFREE=no
export ENABLE_GPL=no
elif [ x$1 = "xlgpl" ]
then
echo "************************"
echo " LGPL "
echo "************************"
export HOME=$HOME/android-projects/output/lgpl
export ENABLE_NONFREE=yes
export ENABLE_GPL=no
else
echo "************************"
echo " GPL "
echo "************************"
export HOME=$HOME/android-projects/output/gpl
export ENABLE_NONFREE=yes
export ENABLE_GPL=yes
fi
export OPTIONS=
if [ x$FFMPEG = "xno" ]; then
export OPTIONS="${OPTIONS} --without-ffmpeg"
fi
if [ x$LIBYUV = "xno" ]; then
export OPTIONS="${OPTIONS} --without-yuv"
fi
if [ x$VPX = "xno" ]; then
export OPTIONS="${OPTIONS} --without-vpx"
fi
if [ x$OPUS = "xno" ]; then
export OPTIONS="${OPTIONS} --without-opus"
fi
if [ x$OPENCORE_AMR = "xno" ]; then
export OPTIONS="${OPTIONS} --without-amr"
fi
if [ x$SPEEX_CODEC = "xno" ]; then
export OPTIONS="${OPTIONS} --without-speex"
fi
if [ x$SPEEX_DSP = "xno" ]; then
export OPTIONS="${OPTIONS} --without-speexdsp"
fi
if [ x$ILBC = "xno" ]; then
export OPTIONS="${OPTIONS} --without-ilbc"
fi
if [ x$LIBGSM = "xno" ]; then
export OPTIONS="${OPTIONS} --without-gsm"
fi
if [ x$G729 = "xno" ]; then
export OPTIONS="${OPTIONS} --without-g729"
fi
if [ x$SRTP = "xno" ]; then
export OPTIONS="${OPTIONS} --without-srtp"
fi
if [ x$WEBRTC = "xno" ]; then
export OPTIONS="${OPTIONS} --without-webrtc"
fi
if [ x$SSL = "xno" ]; then
export OPTIONS="${OPTIONS} --without-ssl"
fi
for arch in armv5te armv7-a armv7-a-neon x86
do
if [ $arch = "x86" ]; then \
export HOST=i686-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 --with-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
make clean
make uninstall
make all
if [ $DEBUG = "yes" ]; then \
make install; \
else \
make install-strip; \
fi \
done
mkdir -p $HOME/imsdroid/libs/armeabi
mkdir -p $HOME/imsdroid/libs/armeabi-v7a
mkdir -p $HOME/imsdroid/libs/x86
mkdir -p $HOME/imsdroid/libs/mips
cp --force $HOME/armv5te/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi/libtinyWRAP.so
cp --force $HOME/armv5te/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/armeabi/libplugin_audio_opensles.so
cp --force $HOME/armv7-a/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libtinyWRAP.so
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/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

@ -0,0 +1,113 @@
lib_LTLIBRARIES = libtinyWRAP.la
libtinyWRAP_la_LIBADD = \
../tinySAK/libtinySAK.la \
../tinyHTTP/libtinyHTTP.la \
../tinyXCAP/libtinyXCAP.la \
../tinyIPSec/libtinyIPSec.la \
../tinySIGCOMP/libtinySIGCOMP.la \
../tinySMS/libtinySMS.la \
../tinyNET/libtinyNET.la \
../tinySDP/libtinySDP.la \
../tinyRTP/libtinyRTP.la \
../tinyMEDIA/libtinyMEDIA.la \
../tinyMSRP/libtinyMSRP.la \
../tinyDAV/libtinyDAV.la \
../tinySIP/libtinySIP.la
libtinyWRAP_la_CPPFLAGS = \
-I_common \
-I. \
-I../tinySAK/src \
-I../tinyNET/src \
-I../tinyHTTP/include\
-I../tinyXCAP/include \
-I../tinySMS/include \
-I../tinySDP/include \
-I../tinyMEDIA/include \
-I../tinyMSRP/include \
-I../tinyDAV/include \
-I../tinySIP/include
libtinyWRAP_la_LDFLAGS = ${LDFLAGS}
if TARGET_OS_IS_ANDROID
libtinyWRAP_la_CPPFLAGS += -DANDROID=1 -Iandroid -fno-rtti -fno-exceptions
libtinyWRAP_la_LDFLAGS += -Wl,-shared,-Bsymbolic,--no-undefined,--whole-archive -lm -lstdc++ -lgcc -llog -ldl
else
libtinyWRAP_la_LDFLAGS +=
endif
if USE_SSL
libtinyWRAP_la_LIBADD += ${LIBSSL_LIBADD}
endif
if USE_FFMPEG
libtinyWRAP_la_LIBADD += ${LIBFFMPEG_LIBADD}
endif
if USE_H264
libtinyWRAP_la_LIBADD += ${LIBH264_LIBADD}
endif
if USE_VPX
libtinyWRAP_la_LIBADD += ${LIBVPX_LIBADD}
endif
if USE_YUV
libtinyWRAP_la_LIBADD += ${LIBYUV_LIB}
endif
if USE_OPUS
libtinyWRAP_la_LIBADD += ${LIBOPUS_LIBADD}
endif
if USE_AMR
libtinyWRAP_la_LIBADD += ${LIBAMR_LIBADD}
endif
if USE_SPEEX
libtinyWRAP_la_LIBADD += ${LIBSPEEX_LIBADD}
endif
if USE_SPEEXDSP
libtinyWRAP_la_LIBADD += ${LIBSPEEXDSP_LIBADD}
endif
if USE_GSM
libtinyWRAP_la_LIBADD += ${LIBGSM_LIBADD}
endif
if USE_G729
libtinyWRAP_la_LIBADD += ${LIBG729_LIBADD}
endif
if USE_ILBC
libtinyWRAP_la_LIBADD += ${LIBILBC_LIBADD}
endif
libtinyWRAP_la_SOURCES = \
_common/ActionConfig.cxx \
_common/AudioResampler.cxx \
_common/DDebug.cxx \
_common/MediaContent.cxx \
_common/MediaSessionMgr.cxx \
_common/Msrp.cxx \
_common/ProxyConsumer.cxx \
_common/ProxyPluginMgr.cxx \
_common/ProxyProducer.cxx \
_common/SafeObject.cxx \
_common/SipCallback.cxx \
_common/SipEvent.cxx \
_common/SipMessage.cxx \
_common/SipSession.cxx \
_common/SipStack.cxx \
_common/SipUri.cxx \
_common/SMSEncoder.cxx \
_common/Xcap.cxx
if TARGET_OS_IS_ANDROID
libtinyWRAP_la_SOURCES += java/android/tinyWRAP_wrap.cxx
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = tinyWRAP.pc

@ -0,0 +1,15 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
includedir = @includedir@
Name : libtinyWRAP
Description : Doubango Telecom tinyWRAP (Wrapper) library
Version : @PACKAGE_VERSION@
Requires:
Requires.private: tinySAK = @PACKAGE_VERSION@ tinyNET = @PACKAGE_VERSION@ tinySDP = @PACKAGE_VERSION@ tinyRTP = @PACKAGE_VERSION@ tinyMEDIA = @PACKAGE_VERSION@ tinyMSRP = @PACKAGE_VERSION@ tinyDAV = @PACKAGE_VERSION@
Conflicts:
Cflags : -I${includedir}/tinywrap
Libs : -L${libdir} -ltinyWRAP
Libs.private: @LIBFFMPEG_LIBADD@ @LIBH264_LIBADD@ @LIBVPX_LIBADD@ @LIBOPUS_LIBADD@ @LIBAMR_LIBADD@ @LIBSPEEX_LIBADD@ @LIBSPEEXDSP_LIBADD@ @LIBGSM_LIBADD@ @LIBG729_LIBADD@ @LIBILBC_LIBADD@

@ -7,11 +7,92 @@
AC_PREREQ([2.0])
AC_INIT(libdoubango, 2.0.1007, doubango(at)googlegroups(dot)com)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([tinySAK/src/tsk.c])
### HOST FOR CROSS-COMPILING
target_os=`uname -s`
android_cpu=unknown
case "$host" in
arm-*-linux-androideabi)
target_os=android
android_cpu=armv5te
;;
i686-*-linux-android)
target_os=android
android_cpu=x86
;;
*)
AC_MSG_NOTICE(["Using host as target os: $host"])
;;
esac
### ANDROID-CPU
AC_ARG_WITH(android-cpu,
[ --with-android-cpu[=cpu] set android CPU type [[default=armv5te]]
armv5te: ARMv5TE
armv7-a: ARMv7-a *without* NEON
armv7-a-neon: ARMv7-a *with* NEON
x86: X86],
[ android_cpu=$withval ])
### ANDROID-TOOLCHAIN (http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html)
if test "$target_os" = "android"; then
case "$android_cpu" in
x86)
export SYSROOT=$NDK/platforms/android-9/arch-x86
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
AC_SUBST(TARGET_ARCH, "x86")
;;
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 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp'
export LDFLAGS='-Wl,--fix-cortex-a8'
AC_SUBST(TARGET_ARCH, "arm")
;;
armv7-a-neon)
export ANDROID_PREFIX=arm-linux-androideabi
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 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
export LDFLAGS='-Wl,--fix-cortex-a8'
AC_SUBST(TARGET_ARCH, "arm")
;;
*)
export ANDROID_PREFIX=arm-linux-androideabi
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 --install-dir=$ANDROID_TOOLCHAIN
AC_SUBST(TARGET_ARCH, "arm")
;;
esac
AC_SUBST(NDK, $NDK)
export CFLAGS="${CFLAGS} -DANDROID=1 -fPIC"
export CPPFLAGS=$CFLAGS
export LDFLAGS="${LDFLAGS} -lc -lm -lgcc"
export PATH=$ANDROID_TOOLCHAIN/bin:$PATH
export CC=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-gcc
export AR=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-ar
export CXX=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-g++
export AS=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-as
export RANLIB=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-ranlib
export STRIP=$ANDROID_TOOLCHAIN/bin/$ANDROID_PREFIX-strip
fi
dnl find suitable C and C++ compilers
AC_PROG_CC
AC_PROG_CXX
@ -27,18 +108,21 @@ AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
## Are we using Windows?
#dnl detecting WIN32
#case "$host" in
# *cygwin* | *mingw*)
# AC_DEFINE([WIN32], [], "Using Windows as target os.")
# ;;
# *)
# AC_MSG_RESULT(${host} is not Windows... I will do my best.)
# ;;
#esac
### Set Target OS
AM_CONDITIONAL([TARGET_OS_IS_ANDROID], [test "x$target_os" = xandroid])
### CROSS COMPILATION?
AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = xyes])
### ENABLE GPL CODE
AC_ARG_ENABLE(gpl,
[ AS_HELP_STRING([--disable-gpl], [Disable GPL code]) ], [ ],[])
test "x$enable_gpl" = "x" && enable_gpl=yes
#echo Setting up build environment for ${target_cpu}${target_os}
### ENABLE NONFREE CODE
AC_ARG_ENABLE(nonfree,
[ AS_HELP_STRING([--disable-nonfree], [Disable NONFREE code]) ], [ ],[])
test "x$enable_nonfree" = "x" && enable_nonfree=yes
### ENABLE-DEBUG
AC_MSG_CHECKING(whether to enable debugging)
@ -47,14 +131,30 @@ AC_ARG_ENABLE(debug,
[ --enable-debug[=no/yes] turn on/off debugging
[[default=$debug_default]]],
[ if test "x$enableval" = "xyes" ; then
CFLAGS="$CFLAGS -O0 -g3 -DDEBUG"
AC_MSG_RESULT(yes)
AC_DEFINE(DEBUG_LEVEL, DEBUG_LEVEL_INFO, [])
else
CFLAGS="$CFLAGS -O3 -NDEBUG"
AC_MSG_RESULT(no)
AC_DEFINE(DEBUG_LEVEL, DEBUG_LEVEL_ERROR, [])
fi
],
[])
test "x$enable_debug" = "x" && enable_debug=no
AM_CONDITIONAL(USE_DEBUG, test x"$enable_debug" = x"yes")
if test "$enable_debug" = "yes"; then
CFLAGS="${CFLAGS} -O0 -g3 -DDEBUG"
CPPFLAGS=$CFLAGS
CXXFLAGS=$CFLAGS
else
if test "$target_os" = "android"; then
CFLAGS="${CFLAGS} -Os -s"
else
CFLAGS="${CFLAGS} -O3 -DNDEBUG"
fi
CPPFLAGS=$CFLAGS
CXXFLAGS=$CFLAGS
fi
### DEBUG-LEVEL
AC_ARG_WITH(debug-level,
@ -78,6 +178,22 @@ AC_ARG_WITH(debug-level,
fi
])
### CFLAGS && LDFLAGS
if test "$target_os" = "android"; then
home_dir=`pwd`
CFLAGS="${CFLAGS} -I${home_dir}/thirdparties/andy/${android_cpu}/include -I${home_dir}/thirdparties/andy/common/include -I${home_dir}/thirdparties/common/include/libyuv"
CPPFLAGS=$CFLAGS
LDFLAGS="${LDFLAGS} -L${home_dir}/thirdparties/andy/${android_cpu}/lib/dist"
if test "$enable_gpl" = yes; then
LDFLAGS="${LDFLAGS} -L${home_dir}/thirdparties/andy/${android_cpu}/lib/dist/gpl"
else
LDFLAGS="${LDFLAGS} -L${home_dir}/thirdparties/andy/${android_cpu}/lib/dist/lgpl"
fi
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
fi
AC_CHECK_FUNCS([stricmp strnicmp])
AC_TRY_COMPILE([#include <pthread.h>],
@ -171,7 +287,7 @@ AC_CHECK_MEMBER([struct sockaddr.sa_len], AC_DEFINE(TNET_HAVE_SA_LEN, 1), AC_DEF
AH_TEMPLATE([HAVE_APPEND_SALT_TO_KEY], [Checks if the installed libsrtp version support append_salt_to_key() function])
AH_TEMPLATE([HAVE_SRTP_PROFILE_GET_MASTER_KEY_LENGTH], [Checks if the installed libsrtp version support srtp_profile_get_master_key_length() function])
AH_TEMPLATE([HAVE_SRTP_PROFILE_GET_MASTER_SALT_LENGTH], [Checks if the installed libsrtp version support srtp_profile_get_master_salt_length() function])
have_srtp=check
have_srtp=no
want_srtp=check
path_srtp=undef
AC_SUBST(LIBSRTP_LIBADD, "")
@ -213,9 +329,9 @@ AM_CONDITIONAL([USE_SRTP], [test $have_srtp = yes])
# SSL
# --with-ssl / --without-ssl as argument to configure
########################################################
have_ssl=check
have_dtls_srtp=check
have_dtls=check
have_ssl=no
have_dtls_srtp=no
have_dtls=no
want_ssl=check
path_ssl=undef
AC_SUBST(LIBSSL_LIBADD, "")
@ -237,12 +353,14 @@ 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_DEFINE_UNQUOTED(HAVE_OPENSSL, 0, HAVE_OPENSSL) [have_ssl=no]
AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 0, HAVE_OPENSSL) [have_ssl=no], [-lcrypto]
))
AC_CHECK_LIB(crypto, BN_init, 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])
AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS) [have_dtls=yes])
# if opus not found and requested then, die.
AC_CHECK_LIB(crypto, BN_init,
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])
)
# if ssl not found and requested then, die.
test $have_ssl:$want_ssl = no:yes &&
AC_MSG_ERROR([You requested SSL (requires OpenSSL) but not found...die])
fi
@ -254,7 +372,7 @@ AM_CONDITIONAL([USE_SSL], [test $have_ssl = yes])
# FFmpeg
# --with-ffmpeg / --without-ffmpeg as argument to configure
########################################################
have_ffmpeg=check
have_ffmpeg=no
want_ffmpeg=check
path_ffmpeg=undef
AC_SUBST(LIBFFMPEG_LIBADD, "")
@ -275,19 +393,18 @@ AC_ARG_WITH(ffmpeg,
if test $want_ffmpeg != no; then
have_avutil=check
AC_CHECK_HEADERS(libavutil/avutil.h,
AC_CHECK_LIB(avutil, av_gettime, [have_avutil=yes] LIBFFMPEG_LIBADD="${LIBFFMPEG_LIBADD} -lavutil", [have_avutil=no] [have_ffmpeg=no])
AC_CHECK_LIB(avutil, av_gettime, [have_avutil=yes] LIBFFMPEG_LIBADD="-lavutil ${LIBFFMPEG_LIBADD}", [have_avutil=no])
)
have_swscale=check
AC_CHECK_HEADERS(libswscale/swscale.h,
AC_CHECK_LIB(swscale, sws_scale, [have_swscale=yes] LIBFFMPEG_LIBADD="${LIBFFMPEG_LIBADD} -lswscale", [have_swscale=no] [have_ffmpeg=no])
AC_CHECK_LIB(swscale, sws_scale, [have_swscale=yes] LIBFFMPEG_LIBADD="-lswscale ${LIBFFMPEG_LIBADD}", [have_swscale=no], [-lavutil])
)
have_avcodec=check
AC_CHECK_HEADERS(libavcodec/avcodec.h,
AC_CHECK_LIB(avcodec, avcodec_find_encoder, [have_avcodec=yes] LIBFFMPEG_LIBADD="${LIBFFMPEG_LIBADD} -lavcodec", [have_avcodec=no] [have_ffmpeg=no])
AC_CHECK_HEADERS(libavcodec/avcodec.h,
AC_CHECK_LIB(avcodec, avcodec_alloc_frame, [have_avcodec=yes] LIBFFMPEG_LIBADD="-lavcodec ${LIBFFMPEG_LIBADD}", [have_avcodec=no], [-lavutil])
)
test $have_ffmpeg = yes &&
AC_DEFINE_UNQUOTED(HAVE_FFMPEG, 1, HAVE_FFMPEG)
test $have_avutil:$have_swscale:$have_avcodec = yes:yes:yes &&
have_ffmpeg=yes && AC_DEFINE_UNQUOTED(HAVE_FFMPEG, 1, HAVE_FFMPEG)
# if ffmpeg not found and requested then, die.
test $have_ffmpeg:$want_ffmpeg = no:yes &&
@ -295,16 +412,16 @@ if test $want_ffmpeg != no; then
fi
AM_CONDITIONAL([USE_FFMPEG], [test $have_ffmpeg = yes])
AM_CONDITIONAL(USE_H264, false)
AC_SUBST(LIBH264_LIBADD, "")
AM_CONDITIONAL(USE_H264, [test $target_os:$enable_gpl = android:yes]) # H.264 is always there for Android and statically linked
AC_SUBST(LIBH264_LIBADD, "-lx264")
AC_ARG_WITH(h264, [ --with-h264 IMPORTANT: deprecated to be removed ],[], [])
########################################################
# VPX (VP8, VP9)
# --with-vpx / --without-vpx as argument to configure
########################################################
have_vpx=check
have_vpx=no
want_vpx=check
path_vpx=undef
AC_SUBST(LIBVPX_LIBADD, "")
@ -340,7 +457,7 @@ AM_CONDITIONAL([USE_VPX], [test $have_vpx = yes])
# YUV
# --with-yuv / --without-yuv as argument to configure
########################################################
have_yuv=check
have_yuv=no
want_yuv=check
path_yuv=undef
AC_SUBST(LIBYUV_INCLUDE, "")
@ -360,22 +477,27 @@ AC_ARG_WITH(yuv,
)
# only if --without-yuv not used
if test $want_yuv != no; then
AC_LANG_PUSH([C++])
# check for lib and headers
AC_CHECK_HEADERS(libyuv/libyuv.h,
AC_CHECK_LIB(yuv, I420Scale, AC_DEFINE_UNQUOTED(HAVE_LIBYUV, 1, HAVE_LIBYUV) [have_yuv=yes]
if test "x$path_yuv" = xundef; then
LIBYUV_INCLUDE="-I/usr/local/include"
LIBYUV_LIB="-L/usr/local/lib -lyuv"
if test "$target_os" != "android"; then
LIBYUV_INCLUDE="-I/usr/local/include -I/usr/local/include/libyuv"
LIBYUV_LIB="-L/usr/local/lib"
fi
else
LIBYUV_INCLUDE="-I${path_yuv}/include"
LIBYUV_LIB="-L${path_yuv}/lib -lyuv"
LIBYUV_INCLUDE="-I${path_yuv}/include ${path_yuv}/include/libyuv"
LIBYUV_LIB="-L${path_yuv}/lib"
fi
,
AC_DEFINE_UNQUOTED(HAVE_LIBYUV, 0, HAVE_LIBYUV) [have_yuv=no]
))
test $have_yuv = yes && LIBYUV_LIB="${LIBYUV_LIB} -lyuv"
# if opus not found and requested then, die.
test $have_yuv:$want_yuv = no:yes &&
AC_MSG_ERROR([You requested LIBYUV but not found...die])
AC_LANG_POP([C++])
fi
AM_CONDITIONAL([USE_YUV], [test $have_yuv = yes])
@ -384,7 +506,7 @@ AM_CONDITIONAL([USE_YUV], [test $have_yuv = yes])
# AMR
# --with-amr / --without-amr as argument to configure
########################################################
have_amr=check
have_amr=no
want_amr=check
path_amr=undef
AC_SUBST(LIBAMR_LIBADD, "")
@ -412,14 +534,14 @@ if test $want_amr != no; then
test $have_amr:$want_amr = no:yes &&
AC_MSG_ERROR([You requested AMR audio codec but not found...die])
fi
AM_CONDITIONAL([USE_AMR], [test $have_amr = yes])
AM_CONDITIONAL([USE_AMR], [test $have_amr:$enable_nonfree = yes:yes])
########################################################
# OPUS
# --with-opus / --without-opus as argument to configure
########################################################
have_opus=check
have_opus=no
want_opus=check
path_opus=undef
AC_SUBST(LIBOPUS_LIBADD, "")
@ -454,7 +576,7 @@ AM_CONDITIONAL([USE_OPUS], [test $have_opus = yes])
# SPEEX
# --with-speex / --without-speex as argument to configure
########################################################
have_speex=check
have_speex=no
want_speex=check
path_speex=undef
AC_SUBST(LIBSPEEX_LIBADD, "")
@ -489,7 +611,7 @@ AM_CONDITIONAL([USE_SPEEX], [test $have_speex = yes])
# SPEEXDSP
# --with-speexdsp / --without-speexdsp as argument to configure
########################################################
have_speexdsp=check
have_speexdsp=no
want_speexdsp=check
path_speexdsp=undef
AC_SUBST(LIBSPEEXDSP_LIBADD, "")
@ -543,7 +665,7 @@ AC_ARG_ENABLE(speexjb, [ --enable-speexjb IMPORTANT: deprecated to be removed],
# GSM
# --with-gsm / --without-gsm as argument to configure
########################################################
have_gsm=check
have_gsm=no
want_gsm=check
path_gsm=undef
AC_SUBST(LIBGSM_LIBADD, "")
@ -578,7 +700,7 @@ AM_CONDITIONAL([USE_GSM], [test $have_gsm = yes])
# G729
# --with-g729 / --without-g729 as argument to configure
########################################################
have_g729=check
have_g729=no
want_g729=check
path_g729=undef
AC_SUBST(LIBG729_LIBADD, "")
@ -610,14 +732,14 @@ if test $want_g729 != no; then
test $have_g729:$want_g729 = no:yes &&
AC_MSG_ERROR([You requested G729 audio codec but not found...die])
fi
AM_CONDITIONAL([USE_G729], [test $have_g729 = yes])
AM_CONDITIONAL([USE_G729], [test $have_g729:$enable_nonfree = yes:yes])
########################################################
# ILBC
# --with-ilbc / --without-ilbc as argument to configure
########################################################
have_ilbc=check
have_ilbc=no
want_ilbc=check
path_ilbc=undef
AC_SUBST(LIBILBC_LIBADD, "")
@ -648,6 +770,65 @@ fi
AM_CONDITIONAL([USE_ILBC], [test $have_ilbc = yes])
########################################################
# WEBRTC
# --with-webrtc / --without-webrtc as argument to configure
########################################################
have_webrtc=no
want_webrtc=check
path_webrtc=undef
AC_SUBST(LIBWEBRTC_LIBADD, "")
AC_ARG_WITH(webrtc,
[ --with-webrtc=PATH Build with WebRTC audio processing features (AEC, VAD, Noise supp...). PATH is optional.],
if test "x$withval" = "xyes"; then
want_webrtc=yes
path_webrtc=undef
elif test "x$withval" = "xno"; then
want_webrtc=no
path_webrtc=undef
elif test "$withval"; then
want_webrtc=yes
path_webrtc=$withval
fi,
)
# only if --without-webrtc not used
if test $want_webrtc != no; then
# WebRTC AEC
have_webrtc_aec=no
if test "$target_os" = "android"; then
AC_CHECK_HEADERS(webrtc/echo_control_mobile.h,
AC_CHECK_LIB(webrtc_aecm, WebRtcAecm_Create, [have_webrtc_aec=yes], [], [-lwebrtc_apm_utility -lwebrtc_system_wrappers -lwebrtc_spl])
)
else
AC_CHECK_HEADERS(webrtc/echo_cancellation.h,
AC_CHECK_LIB(webrtc_aec, WebRtcAec_Create, [have_webrtc_aec=yes], [], [-lwebrtc_apm_utility -lwebrtc_system_wrappers -lwebrtc_spl])
)
fi
# WebRTC NS
have_webrtc_ns=no
if test "$target_os" = "android"; then
AC_CHECK_HEADERS(webrtc/noise_suppression_x.h,
AC_CHECK_LIB(webrtc_nsx, WebRtcNsx_Process, [have_webrtc_ns=yes] [LIBWEBRTC_LIBADD="-lwebrtc_nsx ${LIBWEBRTC_LIBADD}"], [], [-lwebrtc_apm_utility -lwebrtc_system_wrappers -lwebrtc_spl])
)
else
AC_CHECK_HEADERS(webrtc/noise_suppression.h,
AC_CHECK_LIB(webrtc_ns, WebRtcNs_Process, [have_webrtc_ns=yes] [LIBWEBRTC_LIBADD="-lwebrtc_ns ${LIBWEBRTC_LIBADD}"], [], [-lwebrtc_apm_utility -lwebrtc_system_wrappers -lwebrtc_spl])
)
fi
if test $have_webrtc_aec:$have_webrtc_ns = yes:yes; then
have_webrtc=yes
AC_DEFINE_UNQUOTED(HAVE_WEBRTC, 1, HAVE_WEBRTC)
AC_DEFINE_UNQUOTED(HAVE_WEBRTC_DENOISE, 1, HAVE_WEBRTC_DENOISE)
LIBWEBRTC_LIBADD="${LIBWEBRTC_LIBADD} -lwebrtc_apm_utility -lwebrtc_system_wrappers -lwebrtc_spl"
fi
test $have_webrtc:$want_webrtc = no:yes &&
AC_MSG_ERROR([You requested WebRTC (audio processing features) but not found...die])
fi
AM_CONDITIONAL([USE_WEBRTC], [test $have_webrtc = yes])
AC_CONFIG_FILES(
Makefile
doubango.pc
@ -690,28 +871,37 @@ tinyDAV/tinyDAV.pc
tinySIP/Makefile
tinySIP/tinySIP.pc
)
AC_OUTPUT
bindings/Makefile
bindings/tinyWRAP.pc
plugins/audio_opensles/Makefile
plugins/audio_opensles/plugin_audio_opensles.pc
)
AC_OUTPUT
AC_MSG_NOTICE([
**************************************************************************
* CONGRATULATIONS
**************************************************************************
Cross Compilation: ${cross_compiling}
Target OS: ${target_os}
Host setup: ${host}
Install prefix: ${prefix}
Compiler: ${CC}
Enable GPL: $enable_gpl
Enable Non Free: $enable_nonfree
FFmpeg: $have_ffmpeg
VP8 video codec: $have_vpx
OPUS audio codec: $have_opus
ILBC audio codec: $have_ilbc
G.729 audio codec: $have_g729
G.729 audio codec: $have_g729 -> $enable_nonfree
GSM audio codec: $have_gsm
AMR audio codec: $have_amr
AMR audio codec: $have_amr -> $enable_nonfree
SPEEX audio codec: $have_speex
G.722 audio codec: yes
G.711 audio codec: yes
@ -725,11 +915,23 @@ DTLS: $have_dtls
SRTP: $have_srtp
WebRTC: Enabled($have_webrtc): AEC($have_webrtc_aec), NS($have_webrtc_ns)
Monotonic timers: $have_rt
RESOLV: $have_resolv
DEBUG: $debug_default
DEBUG: $enable_debug
Report any issue at https://groups.google.com/group/doubango
])
])
if test "$target_os" = "android"; then
AC_MSG_NOTICE([
--------------------------------------------------------------------------
- ANDRDOID
--------------------------------------------------------------------------
CPU: ${android_cpu}
])
fi

File diff suppressed because it is too large Load Diff

@ -0,0 +1,39 @@
lib_LTLIBRARIES = libplugin_audio_opensles.la
libplugin_audio_opensles_la_LIBADD = \
../../tinySAK/libtinySAK.la \
../../tinyNET/libtinyNET.la \
../../tinyMEDIA/libtinyMEDIA.la \
../../tinySDP/libtinySDP.la
libplugin_audio_opensles_la_CPPFLAGS = \
-I.. \
-I../../tinySAK/src \
-I../../tinyNET/src \
-I../../tinySDP/include \
-I../../tinyMEDIA/include \
-I../../tinyRTP/include \
-I../../tinyDAV/include
libplugin_audio_opensles_la_LDFLAGS = ${LDFLAGS}
if TARGET_OS_IS_ANDROID
libplugin_audio_opensles_la_CPPFLAGS += -DANDROID=1 -fno-rtti -fno-exceptions -I${NDK}/platforms/android-9/arch-${TARGET_ARCH}/usr/include
libplugin_audio_opensles_la_LDFLAGS += -Wl,-shared,-Bsymbolic,--no-undefined,--whole-archive -L${NDK}/platforms/android-9/arch-${TARGET_ARCH}/usr/lib -lOpenSLES -lm -lstdc++ -lgcc -llog -ldl
else
libplugin_audio_opensles_la_LDFLAGS +=
endif
if USE_SSL
libplugin_audio_opensles_la_LIBADD += ${LIBSSL_LIBADD}
endif
libplugin_audio_opensles_la_SOURCES = \
audio_opensles.cxx \
audio_opensles_consumer.cxx \
audio_opensles_device_impl.cxx \
audio_opensles_producer.cxx \
audio_opensles_device.cxx \
../../tinyDAV/src/audio/tdav_consumer_audio.c \
../../tinyDAV/src/audio/tdav_producer_audio.c
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = plugin_audio_opensles.pc

@ -1,51 +1,43 @@
/* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*/
#include "audio_opensles.h"
#include "audio_opensles_consumer.h"
#include "audio_opensles_producer.h"
#include "audio_opensles_device.h"
#include "audio_opensles_device_impl.h"
#include "tinymedia/tmedia_consumer.h"
#include "tinymedia/tmedia_producer.h"
#include "tsk_list.h"
#include "tsk_safeobj.h"
#include "tsk_debug.h"
#if AUDIO_OPENSLES_UNDER_ANDROID
// https://groups.google.com/group/android-ndk/browse_thread/thread/a1667f28162cf69b/8ef3a171df7f8dfe
extern "C"
{
void *__dso_handle = NULL;
}
#endif
typedef enum PLUGIN_INDEX_E
{
PLUGIN_INDEX_AUDIO_CONSUMER,
PLUGIN_INDEX_AUDIO_PRODUCER,
PLUGIN_INDEX_COUNT
}
PLUGIN_INDEX_T;
/* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*/
#include "audio_opensles.h"
#include "audio_opensles_consumer.h"
#include "audio_opensles_producer.h"
#include "audio_opensles_device.h"
#include "audio_opensles_device_impl.h"
#include "tinymedia/tmedia_consumer.h"
#include "tinymedia/tmedia_producer.h"
#include "tsk_list.h"
#include "tsk_safeobj.h"
#include "tsk_debug.h"
typedef enum PLUGIN_INDEX_E
{
PLUGIN_INDEX_AUDIO_CONSUMER,
PLUGIN_INDEX_AUDIO_PRODUCER,
PLUGIN_INDEX_COUNT
}
PLUGIN_INDEX_T;
int __plugin_get_def_count()
{
return PLUGIN_INDEX_COUNT;
@ -80,8 +72,8 @@ tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
}
}
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
{
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
{
switch(index){
case PLUGIN_INDEX_AUDIO_CONSUMER:
{
@ -96,13 +88,13 @@ tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
return tsk_null;
}
}
}
//
// SLES AudioInstance
//
}
}
//
// SLES AudioInstance
//
typedef struct audio_opensles_instance_s
{
TSK_DECLARE_OBJECT;
@ -120,7 +112,7 @@ typedef struct audio_opensles_instance_s
bool isPlayoutAvailable;
bool isRecordingAvailable;
SLAudioDevice* device;
SLAudioDevice* device;
SLAudioDeviceCallbackImpl* callback;
TSK_DECLARE_SAFEOBJ;
@ -144,15 +136,15 @@ static tsk_object_t* audio_opensles_instance_dtor(tsk_object_t * self)
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;
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);
@ -203,27 +195,27 @@ audio_opensles_instance_handle_t* audio_opensles_instance_create(uint64_t sessio
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->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->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;
@ -259,67 +251,67 @@ int audio_opensles_instance_prepare_consumer(audio_opensles_instance_handle_t* _
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->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);
if((ret = self->device->SpeakerIsAvailable(&_bool))){
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() failed with error code=%d", ret);
}
else{
if(!_bool){
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() returned false");
}
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->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->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->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);
}
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;
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:
@ -348,25 +340,25 @@ int audio_opensles_instance_prepare_producer(audio_opensles_instance_handle_t* _
tsk_safeobj_lock(self);
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);
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");
}
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);
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");
}
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);
@ -374,32 +366,32 @@ int audio_opensles_instance_prepare_producer(audio_opensles_instance_handle_t* _
}
}
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);
}
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;
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:
@ -570,4 +562,4 @@ int audio_opensles_instance_destroy(audio_opensles_instance_handle_t** _self){
*_self = tsk_null;
return 0;
}

@ -1,18 +1,16 @@
APP := lib$(PROJECT)_$(MARCH).$(EXT)
APP := lib$(PROJECT).$(EXT)
THIRDPARTIES_INC := ../../thirdparties/android/include
THIRDPARTIES_INC_COMMON := ../../thirdparties/common/include
THIRDPARTIES_LIB := ../../thirdparties/android/lib
THIRDPARTIES_MARCH_LIB := ../../thirdparties/android/lib/$(MARCH)
DOUBANGO_LIB := ../../android-projects/output
DOUBANGO_INSTALL_INC := $(DOUBANGO_INSTALL_HOME)/include
DOUBANGO_INSTALL_LIB := $(DOUBANGO_INSTALL_HOME)/lib
SLES_INC := $(SLES_INSTALL_HOME)/include
SLES_LIB := $(SLES_INSTALL_HOME)/lib
################################
CFLAGS := $(CFLAGS_LIB) -I$(THIRDPARTIES_INC) -I$(THIRDPARTIES_INC_COMMON) \
-I../../tinySAK/src -I../../tinyMEDIA/include -I../../tinySDP/include -I../../tinyRTP/include -I../../tinyDAV/include
CFLAGS := $(CFLAGS_LIB) -DANDROID=1 -I$(SLES_INC) -I$(DOUBANGO_INSTALL_INC)/tinysak -I$(DOUBANGO_INSTALL_INC)/tinymedia -I$(DOUBANGO_INSTALL_INC)/tinysdp -I$(DOUBANGO_INSTALL_INC)/tinyrtp -I$(DOUBANGO_INSTALL_INC)/tinydav
LDFLAGS := $(LDFLAGS_LIB) -L$(THIRDPARTIES_LIB) -L$(THIRDPARTIES_LIB)/android-9 -L$(THIRDPARTIES_MARCH_LIB) -L$(DOUBANGO_LIB) \
-ltinySAK_$(MARCH) -ltinyMEDIA_$(MARCH) -ltinySDP_$(MARCH) -lm -ldl -llog -lgcc -lstdc++ -lOpenSLES -lgnustl_static
LDFLAGS := $(LDFLAGS_LIB) -L$(SLES_LIB) -L$(DOUBANGO_INSTALL_LIB) -ltinySAK -ltinyMEDIA -ltinySDP
# -L$(DOUBANGO_SRC_HOME)/thirdparties/andy/$(CPU)/lib/dist -lm -ldl -llog -lgcc -lstdc++ -lOpenSLES -lgnustl
all: $(APP)
@ -36,7 +34,7 @@ endif
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
%.o: %.cxx
$(CPP) -c $(INCLUDE) $(CFLAGS) $< -o $@
$(CXX) -c $(INCLUDE) $(CFLAGS) $< -o $@
install: $(APP)
$(ANDROID_SDK_ROOT)/tools/adb remount

@ -0,0 +1,15 @@
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
Name : libplugin_audio_opensles
Description : Doubango Telecom plugin_audio_opensles (OpenSL-ES) plugin
Version : 2.0.1007
Requires:
Requires.private: tinySAK = 2.0.1007 tinyNET = 2.0.1007 tinySDP = 2.0.1007 tinyMEDIA = 2.0.1007
Conflicts:
Cflags : -I${includedir}/plugin_audio_opensles
Libs : -L${libdir} -lplugin_audio_opensles
Libs.private: -lssl -lcrypto

@ -0,0 +1,63 @@
/*___________________________________________________________________________