I am trying to write an application for Android with Qt/C++...and GStreamer ;)
I've read that it is necessary to initialize each plugin manually, when I'd like to run the application on Android or IOS. Are there any functions like gst_init() for the single plugins or does anybody have an instruction how to get started with GStreamer on Android with Qt/C++?
> Heyho GStreamers :)
> I am trying to write an application for Android with Qt/C++...and
> I've read that it is necessary to initialize each plugin manually,
> when I'd
> like to run the application on Android or IOS. Are there any
> functions like
> gst_init for the single plugins or does anybody have a instruction
> how to
> get started with GStreamer on Android with Qt/C++?
Best would be to start with looking at some code that uses GStreamer on
Android with the normal Java platform. You'll see than that the ndk
-build build system shipped by GStreamer generates a big shared library
with GStreamer, all the selected plugins and their dependencies. And
that library contains a gst_android_init() function, which you can also
call from C++ (it takes the android.context.Context as parameter
though!), and it will initialize GStreamer and all static plugins for
I already know this function which is part of "gstreamer_android.c" in the ndk-build (and is also used in the android-tutorials). But I'm not sure how to get all the initialization stuff integrated in my C++ project in QtCreator.
If I understand right, than I have to take care that "gst_android_init(...)" and all the functions called from it have to be available in my Qt-project. But I don't really know how to get the parameters for gst_android_init(...)? In the android-tutorials the parameters information comes from the makefile where is set which plugins should be integrated. Right?
For the last parameter I take "android.content.Context". But I have no idea from where I get the instances of JNIEnv* and jclass? Because I can't figure out where gst_android_init is called with this parameters in the android-tutorials.
> Hello Sebastian!
> Thx for your answer :-)
> I already know this function which is part of "gstreamer_android.c"
> in the
> android tutorials. But I'm not sure how to get all the initialization
> integrated in my C++ project in QtCreator.
> If I understand right, than I have to take care that
> and all the functions called from it have to be available in my Qt
> But I don't really know how to get the parameters for
> In the java environment the parameters information comes from the
> where is set which plugins should be integrated. Right?
> --> gst_android_init (*JNIEnv * env, jclass klass, jobject context*)
> For the last parameter I take "android.content.Context". But I have
> no idea
> from where I get the instances of JNIEnv* and jclass? Because I can't
> out where gst_android_init ist called with this parameters.
You have to get those values from somewhere, I don't know how this
works with Qt. You somehow need to be able to get a JNIEnv*, you will
also need that for any other Android specific Java API (and you
probably can't create a non-trivial application without).
I think (or hope) that my last problem is that I don't really know how "libgstreamer_android.so" will be generated. Which makefile is responsible for that? It seems to be "gstreamer-1.0.mk" for me...
So all what I have to do is to set inside of "Android.mk" the correct paths and which plugins I'd like to have enabled and then "make" it. This will generate "libgstreamer_android.so" ... is that right?
...mhh if that should be the right way I have to think about how to integrate the existing make-file in my Qt-project ^^
Le mardi 23 juin 2015 à 11:58 +0200, Sebastian Dröge a écrit :
> But note that the new signature of that function is a bit different:
> http://cgit.freedesktop.org/gstreamer/cerbero/tree/data/ndk > -build/gstreamer_android-1.0.c.in#n417
> You only need the JNIEnv* and the android.context.Context instance of
> your application.
For the env, see QAndroidJniEnvironment() (* operator). And for the
jobject I believe this is the activity, see androidActivity(). Getting
the activity is asynchronous, so that new API is still very
In a internal project (non-public sorry), I've rewritten this init
function in plane C, using GResource instead of Java equivalent, and
passing the path manually (instead of using JNI to figure-it-out).
Imho, I believe we need gst_static_init() somewhere that would deal
with the non-Android bits in a friendlier way. gst_android_init() could
then we simplified a lot, and only deal with the Android specifics
(which are not needed when running Qt for Android).
I don't know if this is the right way? The compiler tells me " error: undefined reference to 'gst-android_init' " ...so it seems that I do some mistake while linking against libgstreamer_android.so? Or ist there any incorrect with this?