Commit 3118df10 authored by Ghislain MARY's avatar Ghislain MARY

Fix build of mediastreamer2 SDK for Android.

parent 756e3d94
...@@ -2,23 +2,9 @@ ...@@ -2,23 +2,9 @@
**************************** ****************************
To build libmediastreamer for Android, you must: To build libmediastreamer for Android, you must:
1) download the Android ndk (r5b, r6) from google. 1) clone the linphone-android repository:
2) install the autotools: autoconf, automake, aclocal, libtoolize git clone git://git.linphone.org/linphone-android.git
3) run the ./prepare_sources.sh script in the linphone-android top level directory. This will download iLBC source files and convert some assembly files in VP8 project. 2) follow the README file of linphone-android and build using:
$ make mediastreamer2-sdk
$ ./prepare_sources.sh instead of:
$ make
4a) If you already build linphone-android, use the following command before building MS2 libs:
${my google ndk directory}/ndk-build clean
4b) finally from directory mediastreamer, just execute command:
$ ${my google ndk directory}/ndk-build NDK_APPLICATION_MK=jni/Application.mk
There's a sample Mediastream Java app, to build and run it :
5) Use eclipse to create a new Android project 'from existing sources' using mediastreamer/java folder
Some options can be passed to ndk-build, like "ndk-build SOME_OPTION=SOME_VALUE"
Option Name | Possible values
----------------------------------------
BUILD_X264 0 (don't build x264) or 1 (build x264)
BUILD_AMR 0 (don't build amr codec), light (try to use amr codec from android), full (build your own amr codec)
...@@ -244,26 +244,50 @@ endif ...@@ -244,26 +244,50 @@ endif
LOCAL_STATIC_LIBRARIES += cpufeatures LOCAL_STATIC_LIBRARIES += cpufeatures
ifeq ($(BUILD_MS2), 1) ifeq ($(BUILD_MEDIASTREAMER2_SDK), 1)
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
../tools/mediastream.c ../tools/mediastream.c
LOCAL_STATIC_LIBRARIES += \ ifneq ($(_BUILD_AMR), 0)
libgsm LOCAL_CFLAGS += -DHAVE_AMR
LOCAL_STATIC_LIBRARIES += libmsamr libopencoreamr
endif
ifneq ($(BUILD_AMRWB), 0)
LOCAL_STATIC_LIBRARIES += libvoamrwbenc
endif
ifeq ($(BUILD_SILK),1)
LOCAL_CFLAGS += -DHAVE_SILK
LOCAL_STATIC_LIBRARIES += libmssilk
endif
LOCAL_STATIC_LIBRARIES += libgsm
ifeq ($(BUILD_OPUS),1)
LOCAL_STATIC_LIBRARIES += libopus
endif
ifeq ($(BUILD_G729),1)
LOCAL_CFLAGS += -DHAVE_G729
LOCAL_STATIC_LIBRARIES += libbcg729 libmsbcg729
endif
ifeq ($(_BUILD_VIDEO),1) ifeq ($(_BUILD_VIDEO),1)
LOCAL_STATIC_LIBRARIES += \ LOCAL_STATIC_LIBRARIES += libvpx
libgsm \ ifeq ($(BUILD_X264),1)
libvpx \ LOCAL_STATIC_LIBRARIES += libmsx264 libx264
endif
LOCAL_SHARED_LIBRARIES += \
libavcodec-linphone \ libavcodec-linphone \
libswscale-linphone \ libswscale-linphone \
libavutil-linphone libavutil-linphone
LOCAL_LDLIBS += -lGLESv2
endif endif
ifeq ($(BUILD_SRTP),1) ifeq ($(BUILD_SRTP),1)
LOCAL_SHARED_LIBRARIES += libsrtp LOCAL_SHARED_LIBRARIES += libsrtp
endif
ifeq ($(BUILD_GPLV3_ZRTP),1)
LOCAL_SHARED_LIBRARIES += libssl-linphone libcrypto-linphone
LOCAL_SHARED_LIBRARIES += libzrtpcpp
endif endif
LOCAL_LDLIBS += -lGLESv2 -llog -ldl LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE_FILENAME := libmediastreamer2-$(TARGET_ARCH_ABI)
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
else else
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
package="org.linphone.mediastream" package="org.linphone.mediastream"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MediastreamerActivity" <activity android:name=".MediastreamerActivity"
...@@ -26,4 +26,4 @@ ...@@ -26,4 +26,4 @@
<uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission> <uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission> <uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
</manifest> </manifest>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="Linphone" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<property file="default.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: custom -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<property name="mediastreamer.package.name" value="org.linphone.mediastream" />
<target name="partial-clean">
<delete file="bin/${ant.project.name}.ap_" />
</target>
<target name="javadoc">
<echo level="info">Generate Javadoc</echo>
<javadoc
destdir="${javadoc.dir}"
verbose="off"
use="true"
classpath="${sdk.dir}/platforms/${target}/android.jar:libs/android-support-v4.jar:libs/gcm.jar"
sourcepath="${source.dir}:gen"
linkoffline="http://developer.android.com/reference file:/${sdk.dir}/docs/reference"
stylesheetfile="${sdk.dir}/docs/assets/android-developer-docs.css">
</javadoc>
</target>
<target name="-package-resources" depends="-crunch">
<!-- only package resources if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not package resources...">
<exec executable="${aapt}" failonerror="true">
<arg value="package" />
<arg value="-f" />
<arg value="-v" />
<arg value="--version-code" />
<arg value="${version.code}" />
<arg value="--version-name" />
<arg value="${version.name}" />
<arg value="--debug-mode" />
<arg value="-m" />
<arg value="-u" />
<arg value="-J" />
<arg path="${gen.absolute.dir}" />
<arg value="-M" />
<arg path="${out.manifest.abs.file}" />
<arg value="-I" />
<arg path="${project.target.android.jar}" />
<arg value="-F" />
<arg path="${out.absolute.dir}/${resource.package.file.name}" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />
<arg value="--rename-manifest-package" />
<arg value="${mediastreamer.package.name}" />
<arg value="--custom-package" />
<arg value="${mediastreamer.package.name}" />
</exec>
</do-only-if-not-library>
</target>
<target name="run">
<exec executable="adb">
<arg value="shell" />
<arg value="am" />
<arg value="start" />
<arg value="-a" />
<arg value="android.intent.action.MAIN" />
<arg value="-n" />
<arg value="${mediastreamer.package.name}/org.linphone.mediastream.MediastreamerActivity" />
</exec>
</target>
<target name="mediastreamer2-sdk">
<echo level="info">Creating library output jar file...</echo>
<property name="out.library.jar.file" location="${out.absolute.dir}/libmediastreamer2.jar" />
<jar destfile="${out.library.jar.file}">
<fileset dir="${out.classes.absolute.dir}"
includes="org/linphone/mediastream/**/*.class" />
</jar>
<zip destfile="libmediastreamer2-sdk-${version.name}.zip">
<zipfileset dir="libs" prefix="libs" includes="**/*.so" />
<zipfileset dir="${out.absolute.dir}" includes="libmediastreamer2.jar" prefix="libs"/>
</zip>
</target>
</project>
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-13
include $(call my-dir)/../../../../../jni/Application.mk
...@@ -83,15 +83,35 @@ public class MediastreamerActivity extends Activity { ...@@ -83,15 +83,35 @@ public class MediastreamerActivity extends Activity {
Object destroyMutex= new Object(); Object destroyMutex= new Object();
static { static {
String eabi = "armeabi";
if (Version.isX86()) {
eabi = "x86";
} else if (Version.isArmv7()) {
eabi = "armeabi-v7a";
}
// FFMPEG (audio/video) // FFMPEG (audio/video)
loadOptionalLibrary("avutil"); if (Version.isX86()) {
loadOptionalLibrary("swscale"); loadOptionalLibrary("avutil-linphone-x86");
loadOptionalLibrary("avcore"); loadOptionalLibrary("swscale-linphone-x86");
loadOptionalLibrary("avcodec"); loadOptionalLibrary("avcodec-linphone-x86");
loadOptionalLibrary("srtp"); } else if (Version.isArmv7()) {
loadOptionalLibrary("avutil-linphone-arm");
loadOptionalLibrary("swscale-linphone-arm");
loadOptionalLibrary("avcodec-linphone-arm");
}
// OPENSSL (cryptography)
// linphone suffix avoids collision with libs in /system/lib
loadOptionalLibrary("crypto-linphone-" + eabi);
loadOptionalLibrary("ssl-linphone-" + eabi);
// Secure RTP and key negotiation
loadOptionalLibrary("srtp-" + eabi);
loadOptionalLibrary("zrtpcpp-" + eabi); // GPLv3+
// Main library // Main library
System.loadLibrary("mediastreamer2"); System.loadLibrary("mediastreamer2-" + eabi);
} }
/** Called when the activity is first created. */ /** Called when the activity is first created. */
......
APP_PROJECT_PATH := $(call my-dir)/../
APP_MODULES := libspeex libgsm libortp libavutil libavcore libavcodec libswscale libvpx libmediastreamer2
APP_STL := stlport_static
# define linphone-root-dir to linphone base dir
BUILD_MS2 := 1
BUILD_SRTP := 1
linphone-root-dir:=$(APP_PROJECT_PATH)/../../../
APP_BUILD_SCRIPT:=$(linphone-root-dir)/jni/Android.mk
APP_PLATFORM := android-8
APP_ABI := armeabi-v7a x86
APP_CFLAGS:=-DDISABLE_NEON
...@@ -986,7 +986,7 @@ JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_setup ...@@ -986,7 +986,7 @@ JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_setup
JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_runLoop JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_runLoop
(JNIEnv *env, jobject obj, jint args) { (JNIEnv *env, jobject obj, jint args) {
run_non_interactive_loop((MediastreamDatas*)args); mediastream_run_loop((MediastreamDatas*)args);
} }
JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_clear JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerActivity_clear
......
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