Skip to content

Commit

Permalink
Android: Support API Level 34 with GStreamer-1.24
Browse files Browse the repository at this point in the history
This patch mainly revises the gradle and ndk-build build scripts
to support Android API Level 34 with GStreamer v1.24
(the latest GST release as of 2024.03).

Signed-off-by: Wook Song <[email protected]>
  • Loading branch information
wooksong authored and jaeyun-jung committed Apr 4, 2024
1 parent 5062d48 commit d8e002e
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bat text eol=crlf
24 changes: 0 additions & 24 deletions java/android/build.gradle

This file was deleted.

16 changes: 13 additions & 3 deletions java/android/nnstreamer/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
namespace "org.nnsuite.nnstreamer"
compileSdk 34
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
ndkBuild {
ndkVersion "25.2.9519653"
def gstRoot

if (project.hasProperty('gstAndroidRoot'))
Expand Down Expand Up @@ -65,6 +66,13 @@ android {
}
}
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug {
testCoverageEnabled true
Expand Down Expand Up @@ -92,6 +100,7 @@ android {
jniLibs.srcDirs += project.properties['NNFW_EXT_LIBRARY_PATH']
println 'Set jniLibs.srcDirs includes libraries for NNFW'
}

}
}
packagingOptions {
Expand All @@ -103,6 +112,7 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
Expand Down
5 changes: 1 addition & 4 deletions java/android/nnstreamer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nnsuite.nnstreamer" >
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:glEsVersion="0x00020000"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:extractNativeLibs="true"
Expand Down
4 changes: 2 additions & 2 deletions java/android/nnstreamer/src/main/jni/Android-nnstreamer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ LOCAL_C_INCLUDES += $(PAHO_MQTT_C_INCLUDES)
endif

LOCAL_EXPORT_C_INCLUDES := $(NNSTREAMER_CAPI_INCLUDES)
LOCAL_CFLAGS := -O3 -fPIC $(NNS_API_FLAGS)
LOCAL_CXXFLAGS := -O3 -fPIC -frtti -fexceptions $(NNS_API_FLAGS)
LOCAL_CFLAGS := -O3 -fPIC $(NNS_API_FLAGS) -Wno-deprecated-declarations
LOCAL_CXXFLAGS := -O3 -fPIC -frtti -fexceptions $(NNS_API_FLAGS) -Wno-c99-designator

ifeq ($(ENABLE_MQTT), true)
LOCAL_STATIC_LIBRARIES := paho-mqtt3a paho-mqtt3c
Expand Down
11 changes: 9 additions & 2 deletions java/android/nnstreamer/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,17 @@ include $(BUILD_SHARED_LIBRARY)
#------------------------------------------------------
# gstreamer for android
#------------------------------------------------------
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build
include $(LOCAL_PATH)/Android-gst-plugins.mk

GSTREAMER_PLUGINS := $(GST_REQUIRED_PLUGINS)
GST_BLOCKED_PLUGINS := \
fallbackswitch livesync rsinter rstracers \
threadshare togglerecord cdg claxon dav1d rsclosedcaption \
ffv1 fmp4 mp4 gif hsv lewton rav1e json rspng regex textwrap textahead \
aws hlssink3 ndi rsonvif raptorq reqwest rsrtp rsrtsp webrtchttp rswebrtc uriplaylistbin \
rsaudiofx rsvideofx

GSTREAMER_PLUGINS := $(filter-out $(GST_BLOCKED_PLUGINS), $(GST_REQUIRED_PLUGINS))
GSTREAMER_EXTRA_DEPS := $(GST_REQUIRED_DEPS) glib-2.0 gio-2.0 gmodule-2.0
GSTREAMER_EXTRA_LIBS := $(GST_REQUIRED_LIBS) -liconv

Expand Down
12 changes: 12 additions & 0 deletions java/android/nnstreamer/src/main/jni/nnstreamer-native-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ extern void init_filter_torch (void);
extern void init_filter_mxnet (void);
#endif


#if defined GST_VERSION_MINOR && GST_VERSION_MINOR >= 24
/**
* @brief External function from GStreamer Android. (Dummy function)
*/
static void gst_android_init (JNIEnv * env, jobject context) {
do {

} while(0);
}
#else
/**
* @brief External function from GStreamer Android.
*/
extern void gst_android_init (JNIEnv * env, jobject context);
#endif /* GST_VERSION_MINOR >= 24 */
#endif /* __ANDROID__ */

/**
Expand Down
1 change: 0 additions & 1 deletion java/android/settings.gradle

This file was deleted.

1 change: 0 additions & 1 deletion java/build-nnstreamer-android.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ sed -i "s|mlApiRoot=ml-api-path|mlApiRoot=$ml_api_dir|" gradle.properties
sed -i "s|nnstreamerEdgeRoot=nnstreamer-edge-path|nnstreamerEdgeRoot=$nnstreamer_edge_dir|" gradle.properties
sed -i "s|nnstreamerRoot=nnstreamer-path|nnstreamerRoot=$nnstreamer_dir|" gradle.properties
sed -i "s|gstAndroidRoot=gstreamer-path|gstAndroidRoot=$gstreamer_dir|" gradle.properties
sed -i "s|ndk.dir=ndk-path|ndk.dir=$android_ndk_dir|" local.properties
sed -i "s|sdk.dir=sdk-path|sdk.dir=$android_sdk_dir|" local.properties

# Update SNAP option
Expand Down
Empty file modified java/build-nnstreamer-ubuntu.sh
100644 → 100755
Empty file.

0 comments on commit d8e002e

Please sign in to comment.