gBroutin / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

Feature - Heavyweight components #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Gstreamer provides a generic interface GstXOverlay (
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/h
tml/gst-plugins-base-libs-gstxoverlay.html
) to set the native window where Gstreamer should show the videos. It'd
great to have a heavyweight GstVideoComponent version to compare
performance. I'm sure that most of the times the lightweight solution is
better, but this may have a better performance (less JNI calls). If you
don't think that this solution can have better performance just delete this
Issue.

I changed the Player example to use this interface and it works (at least
in Windows). It's a pity that the jna library doesn't provide a method to
get the window handle of a Canvas (I submitted an Issue asking for this
feature https://jna.dev.java.net/issues/show_bug.cgi?id=25).

I show you below the changed/included code (It's only a quick & dirty
example). It works but it has a lot of problems. I couldn't get the
VideoSink of the PlayBin, so I had to set the videsink by hand, and in the
documentation of the gstoverlay it says that the window_id should be set
inside a SyncHandler, but I couldn't change the SyncHandler of the PlayBin.

Player.java
...
        player.setInputFile(new File(args[0]));
        final Element videoSink = ElementFactory.make("directdrawsink",
"VideoSinkProba");
        player.setVideoSink(videoSink);
        {
            Pointer overlay =
GstAPI.gst.gst_implements_interface_cast(videoSink.handle(),GstInterfaces.gst.gs
t_x_overlay_get_type());
            GstInterfaces.gst.gst_x_overlay_set_xwindow_id(overlay,
Native.getWindowID(frame));
        }
...

GstInterfaces.java
...
public interface GstInterfaces extends Library{
    GstInterfaces gst = (GstInterfaces)
GNative.loadLibrary("gstinterfaces-0.10", GstInterfaces.class, new
HashMap<String, Object>() {{
        put(Library.OPTION_TYPE_MAPPER, new GTypeMapper());
    }});

    void gst_x_overlay_set_xwindow_id(Pointer overlay, long xwindow_id);
    NativeLong gst_x_overlay_get_type();
}
...

GstAPI.java
...
    Pointer gst_implements_interface_cast(Pointer obj, NativeLong gtype);
...

Original issue reported on code.google.com by dcondev...@gmail.com on 17 Aug 2007 at 7:31

GoogleCodeExporter commented 8 years ago
Ok, I've implemented this capability.  Have a look at 
src/example/OverlayPlayer.java
for how to use it.

It seems to work well on both linux and windows, apart from the window 
flickering a
lot when resizing.

Original comment by wmeiss...@gmail.com on 18 Aug 2007 at 8:23

GoogleCodeExporter commented 8 years ago
The example works on Windows without problems. Thanks.

Original comment by dcondev...@gmail.com on 20 Aug 2007 at 3:17

GoogleCodeExporter commented 8 years ago

Original comment by wmeiss...@gmail.com on 22 Aug 2007 at 1:46