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
diff --git a/ring-android/app/src/main/java/cx/ring/service/DRingService.java b/ring-android/app/src/main/java/cx/ring/service/DRingService.java
index bf7abe7..30b288d 100644
--- a/ring-android/app/src/main/java/cx/ring/service/DRingService.java
+++ b/ring-android/app/src/main/java/cx/ring/service/DRingService.java
@@ -525,7 +525,7 @@
return;
try {
- System.loadLibrary("ringjni");
+ System.loadLibrary("ring");
isPjSipStackStarted = true;
} catch (UnsatisfiedLinkError e) {
diff --git a/ring-android/app/src/main/jni/Android.mk b/ring-android/app/src/main/jni/Android.mk
deleted file mode 100644
index 069ea9e..0000000
--- a/ring-android/app/src/main/jni/Android.mk
+++ /dev/null
@@ -1,144 +0,0 @@
- # 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)
diff --git a/ring-android/app/src/main/jni/Application.mk b/ring-android/app/src/main/jni/Application.mk
deleted file mode 100644
index a42e745..0000000
--- a/ring-android/app/src/main/jni/Application.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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
diff --git a/ring-android/app/src/main/jni/jni_interface.i b/ring-android/app/src/main/jni/jni_interface.i
index 73111c3..4a5dab5 100644
--- a/ring-android/app/src/main/jni/jni_interface.i
+++ b/ring-android/app/src/main/jni/jni_interface.i
@@ -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 @@
};
if (!DRing::init(static_cast<DRing::InitFlag>(DRing::DRING_FLAG_DEBUG)))
- return -1;
+ return;
registerCallHandlers(callEvHandlers);
registerConfHandlers(configEvHandlers);
diff --git a/ring-android/app/src/main/jni/videomanager.i b/ring-android/app/src/main/jni/videomanager.i
index 4fc50d3..36b2414 100644
--- a/ring-android/app/src/main/jni/videomanager.i
+++ b/ring-android/app/src/main/jni/videomanager.i
@@ -86,17 +86,17 @@
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 @@
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 @@
{
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 @@
{
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 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);
}