Commit 86759bbc authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez

jni: build using LLVM/clang

* update build system to use LLVM/Clang for contrib/daemon/JNI
  compilation
* unify build system between daemon and JNI modules
* requires Android NDK r12b+ (build machine)
* uses clang 3.8, links with static stdc++

Tuleap: #575
Change-Id: I7003ee4469418b334fd98eaeb259616c5f8192ee
parent 36beae3a
......@@ -4,8 +4,6 @@ export ANDROID_HOME=$(ANDROID_SDK)
TOP=$(shell pwd)/ring-android
SRC=$(TOP)/app/src/main
LIBRINGJNI_H=${DAEMON_DIR}/src/dring/dring.h
LIBRINGJNI=$(SRC)/obj/local/${ARCH}/libring.so
JAVA_SOURCES=$(shell find $(SRC)/java/cx/ring/ -type f -name "*.java")
......@@ -40,7 +38,7 @@ define build_apk
$(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
endef
$(RING_APK): $(LIBRINGJNI) $(JAVA_SOURCES)
$(RING_APK): $(JAVA_SOURCES)
@echo
@echo "=== Building $@ for ${ARCH} ==="
@echo
......@@ -50,26 +48,6 @@ $(RING_APK): $(LIBRINGJNI) $(JAVA_SOURCES)
# many times the gradlew script is not executable by default
$(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
$(LIBRINGJNI): $(LIBRINGJNI_H)
@if [ -z "$(RING_BUILD_DIR)" ]; then echo "RING_BUILD_DIR not defined" ; exit 1; fi
@if [ -z "$(ANDROID_NDK)" ]; then echo "ANDROID_NDK not defined" ; exit 1; fi
@echo
@echo "=== Building libringjni ==="
@echo
$(VERBOSE)if [ -z "$(RING_SRC_DIR)" ] ; then RING_SRC_DIR='${DAEMON_DIR}'; fi ; \
if [ -z "$(RING_CONTRIB)" ] ; then RING_CONTRIB="$$RING_SRC_DIR/contrib/$(TARGET_TUPLE)"; fi ; \
if [ `echo "$(RING_BUILD_DIR)" | head -c 1` != "/" ] ; then \
RING_BUILD_DIR="../$(RING_BUILD_DIR)"; \
fi ; \
[ `echo "$$RING_CONTRIB" | head -c 1` != "/" ] && RING_CONTRIB="../$$RING_CONTRIB"; \
[ `echo "$$RING_SRC_DIR" | head -c 1` != "/" ] && RING_SRC_DIR="../$$RING_SRC_DIR"; \
$(ANDROID_NDK)/ndk-build -C $(SRC) \
RING_SRC_DIR="$$RING_SRC_DIR" \
RING_CONTRIB="$$RING_CONTRIB" \
RING_BUILD_DIR="$$RING_BUILD_DIR" \
NDK_DEBUG=$(NDK_DEBUG) \
TARGET_CFLAGS="$$RING_EXTRA_CFLAGS"
apk:
$(call build_apk)
......@@ -77,14 +55,11 @@ apkclean:
rm -f $(RING_APK)
lightclean:
cd $(SRC) && rm -rf libs/armeabi-v7a libs/x86 obj bin $(RING_APK)
cd $(SRC) && rm -rf libs/$(ARCH) obj bin $(RING_APK)
clean: lightclean
rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin
jniclean: lightclean
rm -f $(LIBRINGJNI)
distclean: clean jniclean
install: $(RING_APK)
......
#! /bin/bash
# Build Ring daemon for architecture specified by ANDROID_ABI
#for OSX/BSD
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
set -e
if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" ]; then
echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting."
echo "They must point to your NDK and SDK directories."
exit 1
fi
if [ -z "$ANDROID_ABI" ]; then
echo "Please set ANDROID_ABI to your architecture: armeabi-v7a, x86."
exit 1
fi
RELEASE=0
for i in ${@}; do
case "$i" in
release|--release)
RELEASE=1
;;
*)
;;
esac
done
ANDROID_TOPLEVEL_DIR="`pwd`"
ANDROID_APP_DIR="$(pwd)/ring-android"
HAVE_ARM=0
HAVE_X86=0
HAVE_MIPS=0
HAVE_64=0
# Set up ABI variables
if [ ${ANDROID_ABI} = "x86" ] ; then
TARGET_TUPLE="i686-linux-android"
PJ_TARGET_TUPLE="i686-pc-linux-android"
PATH_HOST="x86"
HAVE_X86=1
PLATFORM_SHORT_ARCH="x86"
elif [ ${ANDROID_ABI} = "x86_64" ] ; then
TARGET_TUPLE="x86_64-linux-android"
PJ_TARGET_TUPLE="x86_64-pc-linux-android"
PATH_HOST="x86_64"
HAVE_X86=1
HAVE_64=1
PLATFORM_SHORT_ARCH="x86_64"
elif [ ${ANDROID_ABI} = "mips" ] ; then
TARGET_TUPLE="mipsel-linux-android"
PJ_TARGET_TUPLE="mips-unknown-linux-androideabi"
PATH_HOST=$TARGET_TUPLE
HAVE_MIPS=1
PLATFORM_SHORT_ARCH="mips"
elif [ ${ANDROID_ABI} = "arm64-v8a" ] ; then
TARGET_TUPLE="aarch64-linux-android"
PJ_TARGET_TUPLE="arm64-unknown-linux-androideabi"
PATH_HOST=$TARGET_TUPLE
HAVE_ARM=1
HAVE_64=1
PLATFORM_SHORT_ARCH="arm64"
else
TARGET_TUPLE="arm-linux-androideabi"
PJ_TARGET_TUPLE="arm-unknown-linux-androideabi"
PATH_HOST=$TARGET_TUPLE
HAVE_ARM=1
PLATFORM_SHORT_ARCH="arm"
fi
if [ "${HAVE_64}" = 1 ];then
ANDROID_API_VERS=21
LIBDIR=lib64
else
ANDROID_API_VERS=16
LIBDIR=lib
fi
ANDROID_API=android-$ANDROID_API_VERS
export ANDROID_TOOLCHAIN="`pwd`/android-toolchain-$ANDROID_API_VERS-$PLATFORM_SHORT_ARCH"
if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
$ANDROID_NDK/build/tools/make_standalone_toolchain.py \
--arch=$PLATFORM_SHORT_ARCH \
--api $ANDROID_API_VERS \
--stl libc++ \
--install-dir=$ANDROID_TOOLCHAIN
fi
GCCVER=clang
CXXSTL="/"${GCCVER}
export GCCVER
export CXXSTL
export ANDROID_API
export TARGET_TUPLE
export PATH_HOST
export HAVE_ARM
export HAVE_X86
export HAVE_MIPS
export HAVE_64
export PLATFORM_SHORT_ARCH
# Add the NDK toolchain to the PATH, needed both for contribs and for building
# stub libraries
NDK_TOOLCHAIN_PATH=`echo ${ANDROID_TOOLCHAIN}/bin`
export NDK_TOOLCHAIN_PATH=${NDK_TOOLCHAIN_PATH}
export PATH=${NDK_TOOLCHAIN_PATH}:${PATH}
if [ -z "$DAEMON_DIR" ]; then
DAEMON_DIR="$(pwd)/../daemon"
echo "DAEMON_DIR not provided trying to find it in $DAEMON_DIR"
fi
if [ ! -d "$DAEMON_DIR" ]; then
echo 'Daemon not found.'
echo 'If you cloned the daemon in a custom location override' \
'DAEMON_DIR to point to it'
echo "You can also use our meta repo which contains both:
https://gerrit-ring.savoirfairelinux.com/#/admin/projects/ring-project"
exit 1
fi
EXTRA_CFLAGS="${EXTRA_CFLAGS} -O2 -DHAVE_PTHREADS -I${ANDROID_TOOLCHAIN}/include/c++/4.9.x"
# Setup LDFLAGS
if [ ${ANDROID_ABI} = "armeabi-v7a-hard" ] ; then
EXTRA_CFLAGS="${EXTRA_CFLAGS} -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
EXTRA_LDFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mcpu=cortex-a8 -lm_hard -D_NDK_MATH_NO_SOFTFP=1"
elif [ ${ANDROID_ABI} = "armeabi-v7a" ] ; then
EXTRA_CFLAGS="${EXTRA_CFLAGS} -march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=vfpv3-d16"
EXTRA_LDFLAGS="-march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=vfpv3-d16 -lm -Wl,--fix-cortex-a8"
fi
EXTRA_LDFLAGS="${EXTRA_LDFLAGS} -L${ANDROID_TOOLCHAIN}/${TARGET_TUPLE}/${LIBDIR}/${ANDROID_ABI} -L${ANDROID_TOOLCHAIN}/${TARGET_TUPLE}/${LIBDIR} -lm -landroid_support"
EXTRA_CXXFLAGS="${EXTRA_CFLAGS}"
EXTRA_CFLAGS="-std=c11 ${EXTRA_CFLAGS}"
# Make in //
UNAMES=$(uname -s)
MAKEFLAGS=
if which nproc >/dev/null
then
MAKEFLAGS=-j`nproc`
elif [ "$UNAMES" == "Darwin" ] && which sysctl >/dev/null
then
MAKEFLAGS=-j`sysctl -n machdep.cpu.thread_count`
fi
# Build buildsystem tools
cd "$DAEMON_DIR"
export PATH=`pwd`/extras/tools/build/bin:$PATH
echo "Building tools"
pushd extras/tools
./bootstrap
make $MAKEFLAGS
#FIXME
echo "HACK for old Jenkins builder...forcing libtool to be built"
make .libtool
popd
############
# Contribs #
############
echo "Building the contribs"
mkdir -p contrib/native-${TARGET_TUPLE}
ANDROID_BIN=${NDK_TOOLCHAIN_PATH}
CROSS_COMPILE=${ANDROID_BIN}/${TARGET_TUPLE}-
export CROSS_COMPILE="${CROSS_COMPILE}"
mkdir -p contrib/${TARGET_TUPLE}/lib/pkgconfig
pushd contrib/native-${TARGET_TUPLE}
../bootstrap --host=${TARGET_TUPLE} --disable-libav --enable-ffmpeg --disable-speexdsp
# Some libraries have arm assembly which won't build in thumb mode
# We append -marm to the CFLAGS of these libs to disable thumb mode
[ ${ANDROID_ABI} = "armeabi-v7a" ] && echo "NOTHUMB := -marm" >> config.mak
[ ${ANDROID_ABI} = "armeabi-v7a-hard" ] && echo "NOTHUMB := -marm" >> config.mak
# Release or not?
if [ $# -ne 0 ] && [ "$1" = "release" ]; then
OPTS=""
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
RELEASE=1
else
OPTS="--enable-debug"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
RELEASE=0
fi
export SYSROOT=$ANDROID_TOOLCHAIN/sysroot
echo "EXTRA_CFLAGS= -g -fpic ${EXTRA_CFLAGS}" >> config.mak
echo "EXTRA_CXXFLAGS= -g -fpic ${EXTRA_CXXFLAGS}" >> config.mak
echo "EXTRA_LDFLAGS= ${EXTRA_LDFLAGS} -L${SYSROOT}/usr/${LIBDIR}" >> config.mak
export RING_EXTRA_CFLAGS="${EXTRA_CFLAGS}"
export RING_EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS}"
export RING_EXTRA_LDFLAGS="${EXTRA_LDFLAGS} -L${SYSROOT}/usr/${LIBDIR}"
make list
make fetch
export PATH="$PATH:$PWD/../$TARGET_TUPLE/bin"
make
popd
############
# Make Ring #
############
RING_SRC_DIR="${DAEMON_DIR}"
RING_BUILD_DIR="`realpath build-android-${TARGET_TUPLE}`"
export RING_SRC_DIR="${RING_SRC_DIR}"
export RING_BUILD_DIR="${RING_BUILD_DIR}"
mkdir -p build-android-${TARGET_TUPLE}
cd build-android-${TARGET_TUPLE}
cd ${ANDROID_APP_DIR}
./make-swig.sh
if [ ! -f config.h ]; then
echo "Bootstraping"
cd ${DAEMON_DIR}
./autogen.sh
cd "${DAEMON_DIR}/build-android-${TARGET_TUPLE}"
echo "Configuring with ${OPTS}"
${ANDROID_TOPLEVEL_DIR}/configure.sh ${OPTS}
fi
if [ ${ANDROID_API} = "android-21" ] ; then
# android-21 has empty sys/shm.h headers that triggers shm detection but it
# doesn't have any shm functions and/or symbols. */
export ac_cv_header_sys_shm_h=no
fi
if [ ${ANDROID_ABI} = "x86" -a ${ANDROID_API} != "android-21" ] ; then
# NDK x86 libm.so has nanf symbol but no nanf definition, we don't known if
# intel devices has nanf. Assume they don't have it.
export ac_cv_lib_m_nanf=no
fi
echo "Building dring ${MAKEFLAGS}"
V=99 make $MAKEFLAGS
####################################
# Ring android UI and specific code
####################################
cd ${ANDROID_TOPLEVEL_DIR}
STATIC_LIBS_ALL="-llog -lOpenSLES -landroid \
-lopendht \
-lpjsip-${PJ_TARGET_TUPLE} \
-lpjsip-simple-${PJ_TARGET_TUPLE} \
-lpjsip-ua-${PJ_TARGET_TUPLE} -lpjsua-${PJ_TARGET_TUPLE} \
-lpjnath-${PJ_TARGET_TUPLE} \
-lpjmedia-${PJ_TARGET_TUPLE} \
-lpjlib-util-${PJ_TARGET_TUPLE} \
-lpj-${PJ_TARGET_TUPLE} \
-lupnp -lixml -lthreadutil \
-lsamplerate \
-lgnutls -lnettle -lhogweed -lgmp -liconv \
-lavformat -lavdevice -lavcodec -lavfilter -lavutil \
-lpcre -lsndfile -lyaml-cpp -ljsoncpp \
-luuid -lz -lswscale \
-lopus -lspeex -lvorbis -lvorbisenc -logg -lFLAC"
LIBRING_JNI_DIR=${ANDROID_APP_DIR}/app/src/main/libs/${ANDROID_ABI}
echo "Building Ring for Android to ${LIBRING_JNI_DIR}"
ARCH="${ANDROID_ABI}" DAEMON_DIR="${DAEMON_DIR}" make jniclean
mkdir -p ${LIBRING_JNI_DIR}
${NDK_TOOLCHAIN_PATH}/clang++ --shared -Wall -Wextra ${ANDROID_APP_DIR}/app/src/main/jni/ring_wrapper.cpp \
${RING_BUILD_DIR}/src/.libs/libring.a \
-static-libstdc++ \
-I${RING_SRC_DIR}/src -L${RING_SRC_DIR}/contrib/${TARGET_TUPLE}/lib \
--std=c++11 \
${STATIC_LIBS_ALL} \
-o ${LIBRING_JNI_DIR}/libring.so
This diff is collapsed.
......@@ -5,6 +5,11 @@ if [ -z "$ANDROID_NDK" ]; then
exit 1
fi
if [ -z "$NDK_TOOLCHAIN_PATH" ]; then
echo "Please set the NDK_TOOLCHAIN_PATH environment variable with its path."
exit 1
fi
if [ -z "$ANDROID_ABI" ]; then
echo "Please set ANDROID_ABI to your architecture: armeabi-v7a, armeabi, arm64-v8a, x86, x86_64 or mips."
exit 1
......@@ -29,17 +34,17 @@ if [ -n "$HAVE_ARM" ]; then
fi
fi
CPPFLAGS="-I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include"
LDFLAGS="$LDFLAGS -L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}"
CPPFLAGS="-I${NDK_TOOLCHAIN_PATH}/include/c++/4.9.x -I${RING_SRC_DIR}/contrib/${TARGET_TUPLE}/include "
LDFLAGS="$LDFLAGS -L${NDK_TOOLCHAIN_PATH}/${TARGET_TUPLE}/lib/${ANDROID_ABI} -L${RING_SRC_DIR}/contrib/${TARGET_TUPLE}/lib "
SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-$PLATFORM_SHORT_ARCH
SYSROOT=$NDK_TOOLCHAIN_PATH/sysroot
CPPFLAGS="$CPPFLAGS" \
CFLAGS="$CFLAGS ${RING_EXTRA_CFLAGS}" \
CXXFLAGS="$CXXFLAGS ${RING_EXTRA_CXXFLAGS}" \
LDFLAGS="$LDFLAGS ${RING_EXTRA_LDFLAGS}" \
CC="${CROSS_COMPILE}gcc --sysroot=${SYSROOT}" \
CXX="${CROSS_COMPILE}g++ --sysroot=${SYSROOT}" \
CC="clang" \
CXX="clang++" \
NM="${CROSS_COMPILE}nm" \
STRIP="${CROSS_COMPILE}strip" \
RANLIB="${CROSS_COMPILE}ranlib" \
......@@ -47,6 +52,6 @@ AR="${CROSS_COMPILE}ar" \
AS="${CROSS_COMPILE}as" \
PKG_CONFIG_LIBDIR=$RING_SRC_DIR/contrib/$TARGET_TUPLE/lib/pkgconfig \
$RING_SRC_DIR/configure --host=$TARGET_TUPLE $EXTRA_PARAMS \
--disable-shared --with-opensl --without-dbus --without-alsa --without-pulse \
--disable-shared --with-opensl --without-dbus --without-alsa --without-pulse --without-speexdsp \
--prefix=$RING_SRC_DIR/install-android-$TARGET_TUPLE \
$*
......@@ -525,7 +525,7 @@ public class DRingService extends Service {
return;
try {
System.loadLibrary("ringjni");
System.loadLibrary("ring");
isPjSipStackStarted = true;
} catch (UnsatisfiedLinkError e) {
......
# Copyright (C) 2004-2016 Savoir-faire Linux Inc.
#
# Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
# Adrien Beraud <adrien.beraud@savoirfairelinux.com>
#
# This program 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.
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
LOCAL_PATH:= $(call my-dir)
$(info PWD=$(PWD))
$(info RING_CONTRIB=$(RING_CONTRIB))
$(info RING_SRC_DIR=$(RING_SRC_DIR))
$(info RING_BUILD_DIR=$(RING_BUILD_DIR))
include $(CLEAR_VARS)
VERSION="1.1.0"
MY_PREFIX=/sdcard
MY_DATADIR=/data/data
ARCH=$(ANDROID_ABI)
CPP_STATIC= $(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++$(CXXSTL)/libs/$(ARCH)/libgnustl_static.a \
$(RING_CONTRIB)/lib/libgnutls.a \
$(RING_CONTRIB)/lib/libnettle.a \
$(RING_CONTRIB)/lib/libhogweed.a \
$(RING_CONTRIB)/lib/libogg.a \
$(RING_CONTRIB)/lib/libFLAC.a \
$(RING_CONTRIB)/lib/libavcodec.a \
$(RING_CONTRIB)/lib/libavfilter.a \
$(RING_CONTRIB)/lib/libavformat.a \
$(RING_CONTRIB)/lib/libavdevice.a \
$(RING_CONTRIB)/lib/libavutil.a \
$(RING_CONTRIB)/lib/libswscale.a \
$(RING_CONTRIB)/lib/libz.a \
$(RING_CONTRIB)/lib/libupnp.a \
$(RING_CONTRIB)/lib/libthreadutil.a \
$(RING_CONTRIB)/lib/libiconv.a \
$(RING_CONTRIB)/lib/libixml.a \
$(RING_CONTRIB)/lib/libgmp.a \
$(RING_CONTRIB)/lib/libopendht.a \
$(RING_CONTRIB)/lib/libjsoncpp.a
ifeq ($(ARCH),$(filter $(ARCH),x86))
CPP_STATIC += $(RING_CONTRIB)/lib/libpjlib-util-i686-pc-linux-android.a \
$(RING_CONTRIB)/lib/libpj-i686-pc-linux-android.a
else
CPP_STATIC += $(RING_CONTRIB)/lib/libpjlib-util-arm-unknown-linux-androideabi.a \
$(RING_CONTRIB)/lib/libpj-arm-unknown-linux-androideabi.a
endif
LOCAL_SRC_FILES := ring_wrapper.cpp
# RING_BUILD_DIR contains config.h, which we need
LOCAL_C_INCLUDES += $(LOCAL_PATH) \
$(RING_BUILD_DIR) \
$(RING_SRC_DIR) \
$(RING_SRC_DIR)/src \
$(RING_SRC_DIR)/contrib/$(TARGET_TUPLE)/include
LOCAL_MODULE := libringjni
LOCAL_CFLAGS += -fpic
LOCAL_CPPFLAGS += -DCCPP_PREFIX \
-DPROGSHAREDIR=\"${MY_DATADIR}/ring\" \
-DHAVE_CONFIG_H \
-DHAVE_SPEEX_CODEC \
-DHAVE_GSM_CODEC \
-w -frtti -fpic \
-std=c++11 -fexceptions -fpermissive \
-DAPP_NAME=\"Ring\" \
-DSWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON \
-DDEBUG_DIRECTOR_OWNED \
-DPJ_AUTOCONF=1
LOCAL_DISABLE_FATAL_LINKER_WARNINGS = true
LOCAL_LDFLAGS := -L$(RING_CONTRIB)/lib \
LOCAL_LDLIBS += -lz \
-llog \
-lOpenSLES \
$(RING_BUILD_DIR)/src/.libs/libring.a \
ifeq ($(ARCH),$(filter $(ARCH),x86))
LOCAL_LDLIBS += -lpj-i686-pc-linux-android \
-lpjsip-simple-i686-pc-linux-android \
-lpjlib-util-i686-pc-linux-android \
-lpjsip-ua-i686-pc-linux-android \
-lpjmedia-i686-pc-linux-android \
-lpjnath-i686-pc-linux-android \
-lpjmedia-audiodev-i686-pc-linux-android \
-lsrtp-i686-pc-linux-android \
-lpjsip-i686-pc-linux-android \
-lresample-i686-pc-linux-android
else
LOCAL_LDLIBS += -lpj-arm-unknown-linux-androideabi \
-lpjsip-simple-arm-unknown-linux-androideabi \
-lpjlib-util-arm-unknown-linux-androideabi \
-lpjsip-ua-arm-unknown-linux-androideabi \
-lpjmedia-arm-unknown-linux-androideabi \
-lpjnath-arm-unknown-linux-androideabi \
-lpjmedia-audiodev-arm-unknown-linux-androideabi \
-lsrtp-arm-unknown-linux-androideabi \
-lpjsip-arm-unknown-linux-androideabi \
-lresample-arm-unknown-linux-androideabi
endif
LOCAL_LDLIBS += -lhogweed \
-lspeexdsp -lvorbisfile -lyaml-cpp -ljsoncpp \
-lFLAC -lnettle \
-logg \
-lpcre -lsamplerate -luuid \
-lsndfile -lvorbis \
-lspeex -lvorbisenc \
-lgmp -lgnutls -lopendht \
-lavformat -lavcodec -lavutil \
-lopus -lspeex \
-landroid \
$(CPP_STATIC)
include $(BUILD_SHARED_LIBRARY)
########### Codecs ###############
#include $(CLEAR_VARS)
#LOCAL_MODULE := ulaw
#LOCAL_SRC_FILES := ../$(RING_BUILD_DIR)/src/audio/codecs/libcodec_ulaw.so
#include $(PREBUILT_SHARED_LIBRARY)
# Copyright (C) 2004-2016 Savoir-faire Linux Inc.
#
# Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
# Adrien Beraud <adrien.beraud@savoirfairelinux.com>
#
# This program 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.
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
APP_PLATFORM := android-16
APP_OPTIM := debug
APP_ABI := ${ANDROID_ABI}
NDK_TOOLCHAIN_VERSION := 4.9
APP_MODULES += libringjni
......@@ -42,7 +42,7 @@
%typemap(jstype) void * "byte[]"
%typemap(javain) void * "$javainput"
%typemap(in) void * %{
$1 = $input;
$1 = (void*)$input;
%}
%typemap(javadirectorin) void * "$jniinput"
%typemap(out) void * %{
......@@ -259,7 +259,7 @@ void init(ConfigurationCallback* confM, Callback* callM, VideoCallback* videoM)
};
if (!DRing::init(static_cast<DRing::InitFlag>(DRing::DRING_FLAG_DEBUG)))
return -1;
return;
registerCallHandlers(callEvHandlers);
registerConfHandlers(configEvHandlers);
......
......@@ -86,17 +86,17 @@ void rotateNV21(std::vector<uint8_t>& input, unsigned width, unsigned height, in
output[vOut] = input[vIn];
}
}
return output;
return;
}
JNIEXPORT void JNICALL Java_cx_ring_service_RingserviceJNI_setVideoFrame(JNIEnv *jenv, jclass jcls, void* frame, int frame_size, jlong target, int w, int h, int rotation)
JNIEXPORT void JNICALL Java_cx_ring_service_RingserviceJNI_setVideoFrame(JNIEnv *jenv, jclass jcls, jbyteArray frame, int frame_size, jlong target, int w, int h, int rotation)
{
uint8_t* f_target = (uint8_t*) ((intptr_t) target);
if (rotation == 0)
jenv->GetByteArrayRegion(frame, 0, frame_size, f_target);
jenv->GetByteArrayRegion(frame, 0, frame_size, (jbyte*)f_target);
else {
workspace.resize(frame_size);
jenv->GetByteArrayRegion(frame, 0, frame_size, workspace.data());
jenv->GetByteArrayRegion(frame, 0, frame_size, (jbyte*)workspace.data());
rotateNV21(workspace, w, h, rotation, f_target);
}
}
......@@ -133,7 +133,7 @@ void AndroidDisplayCb(ANativeWindow *window, std::unique_ptr<DRing::FrameBuffer>
size_t line_size_in = frame->width * 4;
size_t line_size_out = buffer.stride * 4;
for (size_t i=0, n=frame->height; i<n; i++)
memcpy(buffer.bits + line_size_out * i, frame->ptr + line_size_in * i, line_size_in);
memcpy((uint8_t*)buffer.bits + line_size_out * i, frame->ptr + line_size_in * i, line_size_in);
}
}
else
......@@ -173,11 +173,11 @@ JNIEXPORT void JNICALL Java_cx_ring_service_RingserviceJNI_registerVideoCallback
{
if(!sinkId) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
return 0;
return;
}
const char *arg1_pstr = (const char *)jenv->GetStringUTFChars(sinkId, 0);
if (!arg1_pstr)
return 0;
return;
const std::string sink(arg1_pstr);
jenv->ReleaseStringUTFChars(sinkId, arg1_pstr);
......@@ -194,17 +194,18 @@ JNIEXPORT void JNICALL Java_cx_ring_service_RingserviceJNI_unregisterVideoCallba
{
if(!sinkId) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
return 0;
return;
}
const char *arg1_pstr = (const char *)jenv->GetStringUTFChars(sinkId, 0);
if (!arg1_pstr)
return 0;
return;
const std::string sink(arg1_pstr);
jenv->ReleaseStringUTFChars(sinkId, arg1_pstr);
std::lock_guard<std::mutex> guard(windows_mutex);
DRing::registerSinkTarget(sink, DRing::SinkTarget {});
windows.erase(window);
ANativeWindow* nativeWindow = (ANativeWindow*)((intptr_t) window);
windows.erase(nativeWindow);
}
%}
......@@ -231,8 +232,8 @@ void applySettings(const std::string& name, const std::map<std::string, std::str
void addVideoDevice(const std::string &node);
void removeVideoDevice(const std::string &node);
uintptr_t obtainFrame(int length);
void releaseFrame(uintptr_t frame);
uint8_t* obtainFrame(int length);
void releaseFrame(uint8_t* frame);
void registerSinkTarget(const std::string& sinkId, const DRing::SinkTarget& target);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment