Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Display Gstreamer video on Android
QtWS25 Last Chance

Display Gstreamer video on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
gstreamergstreamer videoandroidopengl
36 Posts 4 Posters 21.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D don-prog
    4 May 2016, 22:35

    @LuJoRi understood, via JNI :)
    But I still don't understand what I need to put in the ANativeWindow_fromSurface() function as first(JNIEnv * env) and second(jobject surface) argument?

    L Offline
    L Offline
    LuJoRi
    wrote on 4 May 2016, 22:55 last edited by LuJoRi 5 Apr 2016, 22:56
    #27

    @don-prog
    The first agrument requires something like a pointer on the Java environment which is needed because on Android even a Qt application is based on a JVM respectively ART (Android Runtime).
    The second one is the C++/Qt handle of the Java surface. Once you've retrieved it after your JNI calls, you can cast it to jobject type and then put it to the ANativeWindow_fromSurface function :)

    Unfortunately I'm short of time the next days (till sunday). Regardless I'd really like to help you! Feel free to ask if there are any questions :)

    D 1 Reply Last reply 4 May 2016, 23:05
    0
    • L LuJoRi
      4 May 2016, 22:55

      @don-prog
      The first agrument requires something like a pointer on the Java environment which is needed because on Android even a Qt application is based on a JVM respectively ART (Android Runtime).
      The second one is the C++/Qt handle of the Java surface. Once you've retrieved it after your JNI calls, you can cast it to jobject type and then put it to the ANativeWindow_fromSurface function :)

      Unfortunately I'm short of time the next days (till sunday). Regardless I'd really like to help you! Feel free to ask if there are any questions :)

      D Offline
      D Offline
      don-prog
      wrote on 4 May 2016, 23:05 last edited by
      #28

      @LuJoRi excuse for troubling! And what is the second argument in Qt exactly? I think it's not qwidget->winId(), so what?

      L 1 Reply Last reply 5 May 2016, 15:16
      0
      • D don-prog
        4 May 2016, 23:05

        @LuJoRi excuse for troubling! And what is the second argument in Qt exactly? I think it's not qwidget->winId(), so what?

        L Offline
        L Offline
        LuJoRi
        wrote on 5 May 2016, 15:16 last edited by LuJoRi 5 May 2016, 15:55
        #29

        @don-prog
        Sorry for the late response!

        No, forget winId() respectively the returned WId on Android for your purposes :)

        The second argument for ANativeWindow_fromSurface is the pure JNI object of a Java surface which you'll retrieve from the Java/Android world! The ANativeWindow_fromSurface function will return a pointer to the display which is managed by the Java surface. With this pointer you are able to access this display area within C++/Qt...since Qt's winId() function doesn't return proper values on Android the pointer you retrieve via ANativeWindow_fromSurface will be something like a replacement for the "missing" WId.

        Are you familiar with the Android-API and how to get a surface in standard Android way? --> you need a SurfaceView and with its SurfaceHolder you can get access to the corresponding Surface. Since you are working with Qt, you have to try doing this stuff via JNI respectively QAndroidJNIObject :) When you get the JNI object of a Java surface this will be your second argument for the function ANativeWindow_fromSurface.

        For my thesis I've created a clear view of the whole procedure...I hope you understand I have first to go in conversation with my professor before I'll post things (diagrams, figures) which I created for my thesis. These days I'm doing the final cut for my thesis document which I'll deliver after the weekend. I'd like to do the delivery of the thesis first and then help you out with detailed description :) I hope it's okay for you?

        Nevertheless I'll try to answer your questions in the meantime :)

        Lukas

        D 1 Reply Last reply 5 May 2016, 21:55
        0
        • L LuJoRi
          5 May 2016, 15:16

          @don-prog
          Sorry for the late response!

          No, forget winId() respectively the returned WId on Android for your purposes :)

          The second argument for ANativeWindow_fromSurface is the pure JNI object of a Java surface which you'll retrieve from the Java/Android world! The ANativeWindow_fromSurface function will return a pointer to the display which is managed by the Java surface. With this pointer you are able to access this display area within C++/Qt...since Qt's winId() function doesn't return proper values on Android the pointer you retrieve via ANativeWindow_fromSurface will be something like a replacement for the "missing" WId.

          Are you familiar with the Android-API and how to get a surface in standard Android way? --> you need a SurfaceView and with its SurfaceHolder you can get access to the corresponding Surface. Since you are working with Qt, you have to try doing this stuff via JNI respectively QAndroidJNIObject :) When you get the JNI object of a Java surface this will be your second argument for the function ANativeWindow_fromSurface.

          For my thesis I've created a clear view of the whole procedure...I hope you understand I have first to go in conversation with my professor before I'll post things (diagrams, figures) which I created for my thesis. These days I'm doing the final cut for my thesis document which I'll deliver after the weekend. I'd like to do the delivery of the thesis first and then help you out with detailed description :) I hope it's okay for you?

          Nevertheless I'll try to answer your questions in the meantime :)

          Lukas

          D Offline
          D Offline
          don-prog
          wrote on 5 May 2016, 21:55 last edited by
          #30

          @LuJoRi of course, it's absolutely ok! I'm student too and I understand you fully :)
          I just have two questions:

          1. Can I display video in NOT full screen(display video in some child widget of my application)? Or I can display video ONLY in full screen? Of course I mean via Qt and GStreamer.
          2. How can I get SurfaceView of the widget(if I can display video in not full screen) or of the full window(if I can display video only in full screen)?
            Regards.
          L 1 Reply Last reply 7 May 2016, 23:13
          0
          • D don-prog
            5 May 2016, 21:55

            @LuJoRi of course, it's absolutely ok! I'm student too and I understand you fully :)
            I just have two questions:

            1. Can I display video in NOT full screen(display video in some child widget of my application)? Or I can display video ONLY in full screen? Of course I mean via Qt and GStreamer.
            2. How can I get SurfaceView of the widget(if I can display video in not full screen) or of the full window(if I can display video only in full screen)?
              Regards.
            L Offline
            L Offline
            LuJoRi
            wrote on 7 May 2016, 23:13 last edited by LuJoRi 5 Jul 2016, 23:15
            #31

            Okay, good to know :)

            @don-prog said:

            1. Can I display video in NOT full screen(display video in some child widget of my application)? Or I can display video ONLY in full screen? Of course I mean via Qt and GStreamer.
            2. How can I get SurfaceView of the widget(if I can display video in not full screen) or of the full window(if I can display video only in full screen)?
              Regards.
            1. Yes, you can display a video wherever you want and in every size you want
            2. In fact the surface isn't part of your Qt-GUI --> you'll get something like a "mixed GUI" with a Qt part and a Java part. All of your GUI will be drawn by Qt except the part where your video will be rendered because this will happen inside the display area which is hold by the Java surface. If you create a Java surface with size 100x100 px via JNI there will be an area with this size ontop of your Qt-GUI which has nothing to do with Qt itself. To describe how you can get it is a longer term which I'll show you after my delivery :))
            D C 2 Replies Last reply 8 May 2016, 00:21
            0
            • L LuJoRi
              7 May 2016, 23:13

              Okay, good to know :)

              @don-prog said:

              1. Can I display video in NOT full screen(display video in some child widget of my application)? Or I can display video ONLY in full screen? Of course I mean via Qt and GStreamer.
              2. How can I get SurfaceView of the widget(if I can display video in not full screen) or of the full window(if I can display video only in full screen)?
                Regards.
              1. Yes, you can display a video wherever you want and in every size you want
              2. In fact the surface isn't part of your Qt-GUI --> you'll get something like a "mixed GUI" with a Qt part and a Java part. All of your GUI will be drawn by Qt except the part where your video will be rendered because this will happen inside the display area which is hold by the Java surface. If you create a Java surface with size 100x100 px via JNI there will be an area with this size ontop of your Qt-GUI which has nothing to do with Qt itself. To describe how you can get it is a longer term which I'll show you after my delivery :))
              D Offline
              D Offline
              don-prog
              wrote on 8 May 2016, 00:21 last edited by
              #32

              @LuJoRi understood, that is a very good news! I will wait when you can share your information about this subject. By the way, good luck :)

              1 Reply Last reply
              0
              • L LuJoRi
                7 May 2016, 23:13

                Okay, good to know :)

                @don-prog said:

                1. Can I display video in NOT full screen(display video in some child widget of my application)? Or I can display video ONLY in full screen? Of course I mean via Qt and GStreamer.
                2. How can I get SurfaceView of the widget(if I can display video in not full screen) or of the full window(if I can display video only in full screen)?
                  Regards.
                1. Yes, you can display a video wherever you want and in every size you want
                2. In fact the surface isn't part of your Qt-GUI --> you'll get something like a "mixed GUI" with a Qt part and a Java part. All of your GUI will be drawn by Qt except the part where your video will be rendered because this will happen inside the display area which is hold by the Java surface. If you create a Java surface with size 100x100 px via JNI there will be an area with this size ontop of your Qt-GUI which has nothing to do with Qt itself. To describe how you can get it is a longer term which I'll show you after my delivery :))
                C Offline
                C Offline
                chaudhry
                wrote on 10 May 2016, 09:31 last edited by
                #33

                @LuJoRi I also have exactly the same requirement that is to render video inside a Qt application on Android using gstreamer. It would be really helpful if you could explain the steps for building gstreamer for a qt application with Android as a target.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  LuJoRi
                  wrote on 12 May 2016, 10:37 last edited by
                  #34

                  Hey guys ... my thesis is done :)

                  I will explain you the procedure step by step this evening or tomorrow in the afternoon.

                  Greetz Lukas

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    LuJoRi
                    wrote on 13 May 2016, 19:10 last edited by LuJoRi
                    #35

                    A rough overview to get an idea how it works:

                    First you should take a general look on the dependencies between SurfaceView, SurfaceHolder, Surface in the documentation of the Android API. This is essential to understand what you have to do to get access to an Android Surface.

                    If you know how it works you can do the creation of the needed objects (of SurfaceView, SurfaceHolder, ...) via JNI calls respective QAndroidJniObject! For all of this you should create a QRunnable --> in its run()-method you do the creation of the objects you need --> QAndroidJniObject is your friend here :)

                    void QRunnable::run()
                    {
                         //create your needed objects of SurfaceView, SurfaceHolder, ... via QAndroidJniObject
                    }
                    

                    Later you have to take care about executing this run()-method in context of the Android UI thread! The created instance of Surface is your second parameter for the ANativeWindow_fromSurface function :)

                    D 1 Reply Last reply 18 May 2017, 15:07
                    0
                    • L LuJoRi
                      13 May 2016, 19:10

                      A rough overview to get an idea how it works:

                      First you should take a general look on the dependencies between SurfaceView, SurfaceHolder, Surface in the documentation of the Android API. This is essential to understand what you have to do to get access to an Android Surface.

                      If you know how it works you can do the creation of the needed objects (of SurfaceView, SurfaceHolder, ...) via JNI calls respective QAndroidJniObject! For all of this you should create a QRunnable --> in its run()-method you do the creation of the objects you need --> QAndroidJniObject is your friend here :)

                      void QRunnable::run()
                      {
                           //create your needed objects of SurfaceView, SurfaceHolder, ... via QAndroidJniObject
                      }
                      

                      Later you have to take care about executing this run()-method in context of the Android UI thread! The created instance of Surface is your second parameter for the ANativeWindow_fromSurface function :)

                      D Offline
                      D Offline
                      don-prog
                      wrote on 18 May 2017, 15:07 last edited by
                      #36

                      @LuJoRi hello!
                      I'm very sorry for the so late reply, but I just had some urgent problems, and I had to leave this forum and work with another things.
                      I see that you shared your advice and sample for this issue as you promised.
                      So I want to thank you for this!
                      Unfortunately, I had to do other things, but I think that you helped other users (including chaudhry) to solve this not simple task! :)
                      Sorry and thank you one more time!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved