examples: Port Android examples to CMake

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7861>
This commit is contained in:
L. E. Segovia 2024-11-09 21:57:38 -03:00 committed by GStreamer Marge Bot
parent da0e6c62ac
commit 5154f43b58
9 changed files with 158 additions and 16 deletions

View file

@ -1,5 +1,7 @@
.cxx/
.externalNativeBuild/
assets/
gst-android-build/
src/main/java/org/freedesktop/gstreamer/GStreamer.java
src/main/java/org/freedesktop/gstreamer/Gst*.java
src/main/java/org/freedesktop/gstreamer/androidmedia/

View file

@ -11,7 +11,7 @@ android {
versionName "1.0"
externalNativeBuild {
ndkBuild {
cmake {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
@ -22,13 +22,12 @@ android {
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/main/assets"
arguments "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_STL=c++_shared", "-DGStreamer_JAVA_SRC_DIR=java", "-DGSTREAMER_ROOT_ANDROID=$gstRoot", "-DGStreamer_ASSETS_DIR=assets"
targets "gstplayer"
// All archs except MIPS and MIPS64 are supported
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
// x86_64 abis disabled because of https://bugzilla.gnome.org/show_bug.cgi?id=795454
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
@ -41,8 +40,8 @@ android {
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
cmake {
path 'src/main/jni/CMakeLists.txt'
}
}
ndkVersion '25.2.9519653'

View file

@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.18.1)
project("android-player" LANGUAGES C CXX)
if(NOT DEFINED GSTREAMER_ROOT_ANDROID)
message(FATAL_ERROR "GSTREAMER_ROOT_ANDROID is not defined!")
endif()
if(ANDROID_ABI STREQUAL "armeabi")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm")
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/armv7")
elseif(ANDROID_ABI STREQUAL "arm64-v8a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm64")
elseif(ANDROID_ABI STREQUAL "x86")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86")
elseif(ANDROID_ABI STREQUAL "x86_64")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86_64")
else()
message(FATAL_ERROR "Target arch ABI not supported: ${ANDROID_ABI}")
endif()
list(APPEND CMAKE_MODULE_PATH "${GSTREAMER_ROOT}/share/cmake")
set(GSTREAMER_NDK_BUILD_PATH "${GSTREAMER_ROOT}/share/gst-android/ndk-build/")
include("${GSTREAMER_NDK_BUILD_PATH}/plugins.cmake")
set(GSTREAMER_PLUGINS ${GSTREAMER_PLUGINS_CORE} ${GSTREAMER_PLUGINS_PLAYBACK} ${GSTREAMER_PLUGINS_CODECS} ${GSTREAMER_PLUGINS_NET} ${GSTREAMER_PLUGINS_SYS} ${GSTREAMER_PLUGINS_CODECS_RESTRICTED} ${GSTREAMER_CODECS_GPL} ${GSTREAMER_PLUGINS_ENCODING} ${GSTREAMER_PLUGINS_VIS} ${GSTREAMER_PLUGINS_EFFECTS} ${GSTREAMER_PLUGINS_NET_RESTRICTED})
set(GStreamer_EXTRA_DEPS gstreamer-play-1.0 gstreamer-player-1.0 gstreamer-video-1.0 glib-2.0)
find_library(ANDROID_LIB android REQUIRED)
find_library(LOG_LIB log REQUIRED)
find_package(GStreamerMobile COMPONENTS ${GSTREAMER_PLUGINS} fonts REQUIRED)
add_library(gstplayer SHARED player.c dummy.cpp)
target_link_libraries(gstplayer
PUBLIC
GStreamer::mobile
${ANDROID_LIB}
${LOG_LIB}
)
set_target_properties(gstplayer
PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)

View file

@ -6,5 +6,7 @@ assets/
build/
gst-android-build/
local.properties
src/org/freedesktop/gstreamer/Gst*.java
src/org/freedesktop/gstreamer/GStreamer.java
!src/org/freedesktop/gstreamer/vulkan
*.iml

View file

@ -12,7 +12,7 @@ android {
archivesBaseName = "$applicationId-v$versionCode"
externalNativeBuild {
ndkBuild {
cmake {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
@ -23,7 +23,7 @@ android {
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/assets"
arguments "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_STL=c++_shared", "-DGSTREAMER_ROOT_ANDROID=$gstRoot"
targets "vulkan-1"
@ -52,8 +52,8 @@ android {
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
cmake {
path 'jni/CMakeLists.txt'
}
}
ndkVersion '25.2.9519653'

View file

@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.18.1)
project("android-vulkan-1" LANGUAGES C CXX)
if(NOT DEFINED GSTREAMER_ROOT_ANDROID)
message(FATAL_ERROR "GSTREAMER_ROOT_ANDROID is not defined!")
endif()
if(ANDROID_ABI STREQUAL "armeabi")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm")
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/armv7")
elseif(ANDROID_ABI STREQUAL "arm64-v8a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm64")
elseif(ANDROID_ABI STREQUAL "x86")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86")
elseif(ANDROID_ABI STREQUAL "x86_64")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86_64")
else()
message(FATAL_ERROR "Target arch ABI not supported: ${ANDROID_ABI}")
endif()
list(APPEND CMAKE_MODULE_PATH "${GSTREAMER_ROOT}/share/cmake")
set(GSTREAMER_NDK_BUILD_PATH "${GSTREAMER_ROOT}/share/gst-android/ndk-build/")
include("${GSTREAMER_NDK_BUILD_PATH}/plugins.cmake")
set(GSTREAMER_PLUGINS ${GSTREAMER_PLUGINS_CORE} ${GSTREAMER_PLUGINS_SYS} ${GSTREAMER_PLUGINS_EFFECTS} vulkan androidmedia)
set(GStreamer_EXTRA_DEPS gstreamer-video-1.0 gobject-2.0)
find_library(ANDROID_LIB android REQUIRED)
find_library(LOG_LIB log REQUIRED)
find_package(GStreamerMobile COMPONENTS ${GSTREAMER_PLUGINS} fonts ca_certificates REQUIRED)
add_library(vulkan-1 SHARED vulkan-1.c dummy.cpp)
target_link_libraries(vulkan-1
PUBLIC
GStreamer::mobile
${ANDROID_LIB}
${LOG_LIB}
)
set_target_properties(vulkan-1
PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)

View file

@ -1,5 +1,7 @@
.cxx/
.externalNativeBuild/
assets/
gst-android-build/
src/main/java/org/freedesktop/gstreamer/Gst*.java
src/main/java/org/freedesktop/gstreamer/GStreamer.java
src/main/java/org/freedesktop/gstreamer/androidmedia/

View file

@ -12,7 +12,7 @@ android {
archivesBaseName = "$applicationId-v$versionCode"
externalNativeBuild {
ndkBuild {
cmake {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
@ -23,7 +23,7 @@ android {
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/main/assets", "V=1"
arguments "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_STL=c++_shared", "-DGStreamer_JAVA_SRC_DIR=java", "-DGSTREAMER_ROOT_ANDROID=$gstRoot", "-DGStreamer_ASSETS_DIR=assets"
targets "gstwebrtc"
@ -41,8 +41,8 @@ android {
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
cmake {
path 'src/main/jni/CMakeLists.txt'
}
}

View file

@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.18.1)
project("android-webrtc" LANGUAGES C CXX)
if(NOT DEFINED GSTREAMER_ROOT_ANDROID)
message(FATAL_ERROR "GSTREAMER_ROOT_ANDROID is not defined!")
endif()
if(ANDROID_ABI STREQUAL "armeabi")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm")
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/armv7")
elseif(ANDROID_ABI STREQUAL "arm64-v8a")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/arm64")
elseif(ANDROID_ABI STREQUAL "x86")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86")
elseif(ANDROID_ABI STREQUAL "x86_64")
set(GSTREAMER_ROOT "${GSTREAMER_ROOT_ANDROID}/x86_64")
else()
message(FATAL_ERROR "Target arch ABI not supported: ${ANDROID_ABI}")
endif()
list(APPEND CMAKE_MODULE_PATH "${GSTREAMER_ROOT}/share/cmake")
set(GSTREAMER_NDK_BUILD_PATH "${GSTREAMER_ROOT}/share/gst-android/ndk-build/")
include("${GSTREAMER_NDK_BUILD_PATH}/plugins.cmake")
set(GSTREAMER_PLUGINS_CORE_CUSTOM coreelements app audioconvert audiorate audioresample videorate videoconvertscale videotestsrc audiotestsrc volume autodetect)
set(GSTREAMER_PLUGINS_CODECS_CUSTOM videoparsersbad vpx opus audioparsers opusparse androidmedia)
set(GSTREAMER_PLUGINS_NET_CUSTOM soup tcp rtsp rtp rtpmanager udp srtp webrtc dtls nice)
set(GSTREAMER_PLUGINS ${GSTREAMER_PLUGINS_CORE_CUSTOM} ${GSTREAMER_PLUGINS_CODECS_CUSTOM} ${GSTREAMER_PLUGINS_NET_CUSTOM} ${GSTREAMER_PLUGINS_ENCODING} ${GSTREAMER_PLUGINS_SYS} ${GSTREAMER_PLUGINS_PLAYBACK})
set(GStreamer_EXTRA_DEPS gstreamer-webrtc-1.0 gstreamer-sdp-1.0 gstreamer-video-1.0 libsoup-3.0 json-glib-1.0 glib-2.0)
set(G_IO_MODULES openssl)
find_library(ANDROID_LIB android REQUIRED)
find_library(LOG_LIB log REQUIRED)
find_package(GStreamerMobile COMPONENTS ${GSTREAMER_PLUGINS} fonts ca_certificates REQUIRED)
add_library(gstwebrtc SHARED webrtc.c dummy.cpp)
target_link_libraries(gstwebrtc
PUBLIC
GStreamer::mobile
${ANDROID_LIB}
${LOG_LIB}
)
set_target_properties(gstwebrtc
PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)