Initialize single plugins?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Initialize single plugins?

Liru7
This post was updated on .
Heyho GStreamers :)

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++?

Best regards
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Sebastian Dröge-3
On Mo, 2015-06-22 at 06:03 -0700, Liru7 wrote:

> Heyho GStreamers :)
>
> 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 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
you.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Liru7
This post was updated on .
Hello Sebastian!

Thx for your answer :-)

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?

--> 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 figure out where gst_android_init is called with this parameters in the android-tutorials.

Best regards
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Liru7
This post was updated on .
I've read something about the Qt-classes QAndroidJniObject and QAndroidJniEnvironment...I hope I'm on the right way with my thoughts ^^
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Sebastian Dröge-3
On Di, 2015-06-23 at 02:17 -0700, Liru7 wrote:
> I've read something about the Qt-classes *QAndroidJniObject *and
> *QAndroidJniEnvironment*...I hope I'm on the right way with my
> thoghts ^^

http://doc.qt.io/qt-5/qandroidjnienvironment.html

Yes, that's exactly what you need :)

http://doc.qt.io/qt-5/qandroidjniobject.html
is some convenience API around JNI, that will be useful for you if you
later need to call some other Android APIs.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Sebastian Dröge-3
In reply to this post by Liru7
On Di, 2015-06-23 at 00:21 -0700, Liru7 wrote:

> 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
> 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 java environment the parameters information comes from the
> makefile
> 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
> figure
> 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).

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 being able to call that, just declare that function somewhere in
your code and then just call it. As long as you make sure the
libgstreamer_android.so is linked in your application it will work.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Liru7
Okay, many thanks!

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 ^^

Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Nicolas Dufresne-3
In reply to this post by Sebastian Dröge-3
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
inconvenient.

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).

http://doc.qt.io/qt-5/qandroidjnienvironment.html
http://doc.qt.io/qt-5/qtandroid.html
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Liru7
Hey guys...thx for your hints!

What I tried is this:

---------------
---------------
extern "C" void gst_android_init (JNIEnv * env, jobject context);
...
QAndroidJniEnvironment* qjniEnv = new QAndroidJniEnvironment();

QPlatformNativeInterface *interface = QApplication::platformNativeInterface();
QAndroidJniObject activity = (jobject)interface->nativeResourceForIntegration("QtActivity");

gst_init(&argc, &argv);

gst_android_init(qjniEnv->operator JNIEnv *(), (jobject)interface->nativeResourceForIntegration("QtActivity") );
---------------
---------------

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?

--> extern "C" void gst_android_init (JNIEnv * env, jobject context);

:-/
Reply | Threaded
Open this post in threaded view
|

Re: Application for Android with Qt/C++

Liru7
Additional information - what I did is following:

I have a running project of android-tutorial-3 in eclipse which works fine.
http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video

After successful compilation of this project I take the generated libgstreamer_android.so to link it against my Qt-project. Then the problem I described above shows up...