Problem initializing androidmedia plugin on an android build

Matthew Waters ystreet00 at gmail.com
Mon Jul 17 04:03:39 UTC 2023


Hi,

I am not currently aware of any public examples of using a native 
Activity with GStreamer on Android.

As far as I know, you are in uncharted territory.

androidmedia does have some code to retrieve the relevant JavaVM object 
(and other Jave related objects) using some dlopen() dlsym() magic 
(search for g_module_ in 
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gst-plugins-bad/sys/androidmedia/gstjniutils.c) 
which is exposed in this file 
(https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gstreamer/gst/gstandroid.c) 
and to the best of my knowledge requires a relevant GStreamer.java (or 
equivalent) in the application.  GStreamer.java is available from 
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gstreamer/data/android/GStreamer.java 
but if you are using GStreamer's ndk-build, then it will be copied into 
the application source directly automatically.

My guess is that you need to somehow convert that GStreamer.java file to 
a native file or call the relevant gst_android_init_jni() manually 
yourself. 
https://github.com/ystreet/qt-gstreamer-android/blob/master/gstreamer_android-1.0.c 
is an example of the latter as used in a Qt context from a while ago.

Cheers
-Matt

On 15/7/23 05:46, George George via gstreamer-devel wrote:
> Hello
>
> I have a problem using the androidmedia plugin. Here is my setup:
>
> I have a Native Activity android project.
> The project does not have any java and is C/C++ only.
> The project was setup following this blog 
> post: https://medium.com/androiddevelopers/getting-started-with-c-and-android-native-activities-2213b402ffff
> (Note: the code in the blog post references struct android_app, which 
> can be viewed at the <ndk_directory>/sources/android/native_app_glue/)
>
> I build gstreamer_android.so as a separate project.
> The separate project's setup is similar to the android examples in 
> gstreamer's repository.
> The only difference is that my makefile builds only the 
> gstreamer_android target, instead of building the entire C/C++ code base.
> Once the .so is built, it is linked in the cmake of my Native Activity 
> project.
>
> Upon calling gst_init, (the gstreamer_android was built with the 
> androidmedia plugin), I get the following error:
> ../sys/androidmedia/gstjniutils.c,load_java_module: Failed to load 
> Java module 'libdvm': dlopen failed: library "libdvm.so" not found
> I don't get any other androidmedia related errors.
>
> I've also copied gstreamer and androidmedia java code (GStreamer.java, 
> GstAhs(c)Callback.java, GstAmcOnFrameAvailableListener.java) to my 
> project.
> However, since there is no java code, I am not sure that these will 
> end up being part of the project at all.
>
> Any help or clarification on what is going wrong would be greatly 
> appreciated.
>
> Thanks,
> George
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230717/979bfbb1/attachment.sig>


More information about the gstreamer-devel mailing list