Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include GStreamer in android ndk project that uses CMake (CMakeLists.txt) and not ndk-build (Android.mk)

I have an android project that currently uses Cmake for including all .cpp /.c code. Now I want to add the GStreamer native libraries such that I can use them in my native code. But the gstreamer docs https://gstreamer.freedesktop.org/documentation/installing/for-android-development.html only document using ndk-build to use gstreamer on android.

Now I don't want to totally refactor my project to use ndk-build and Android.mk because

  1. CMake does its job and i never had problems with it

  2. as stated here cmake is the default for android ndk https://developer.android.com/studio/projects/add-native-code

  3. I also need to include the googlevr ndk library that uses cmake.

So I need to figure out a workaround and therefore need your help. Here are some ideas I came up with

  1. Each module can have ether cmake or ndk-build support. Therefore, I probably could add a new module using ndk-build and include gstreamer there (but then gstreamer is only available in this module)
  2. Compile gstreamer for android using cmake inside android studio - but I don't see evidence that has been done before or is possible for someone without strong cmake knowledge.

Any other ideas/ improvements ? thanks

like image 953
Constantin Geier Avatar asked Oct 19 '25 13:10

Constantin Geier


1 Answers

Even though you have already moved away from GStreamer but in case someone else is facing this issue please have a look at following github repository

https://github.com/henkeldi/gstreamer-android

For myself, I had to make two modifications

  1. I modified the definition of GSTREAMER_ROOT to include ANDROID_ABI so it looks like following

    #GStreamer set(GSTREAMER_ROOT $ENV{GSTREAMER_ROOT_ANDROID}/${ANDROID_ABI})

  2. I had to rename the folders in GStreamer pre-built binaries to be according to ANDROID_ABI. So, my Gstreamer pre-built binaries folder look like following

    enter code here

After the above changes, I am able to successfully build with APK with GStreamer using CMake

like image 106
Mustafa Avatar answered Oct 21 '25 03:10

Mustafa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!