5

I was trying to port GUI integration tutorial of gstreamer(https://gstreamer.freedesktop.org/documentation/tutorials/basic/toolkit-integration.html?gi-language=c) from gtk3 to gtk4. I am hitting an issue with getting the X window belonging to GtkDrawingArea. In gtk3, to get the XID and to pass it to GstVideoOverlay following approach is used:

static void realize_cb (GtkWidget *widget, CustomData *data) {
  GdkWindow *window = gtk_widget_get_window (widget);
  guintptr window_handle;

  if (!gdk_window_ensure_native (window))
    g_error ("Couldn't create native window needed for GstVideoOverlay!");

  /* Retrieve window handler from GDK */
  window_handle = GDK_WINDOW_XID (window);

  /* Pass it to playbin, which implements VideoOverlay and will forward it to the video sink */
  gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->playbin), window_handle);
}

I'm not able to figure out how to do the same in Gtk4. Since Gtk4 is using Wayland terminology, the function in gdk to get XID is GDK_SURFACE_XID() which takes a GdkSurface* as an argument and there is no direct function in GtkWidget to get the pointer to the GdkSurface similar to gtk_widget_get_window in Gtk3.

I tried getting GtkNative using gtk_widget_get_native of the GtkDrawingArea and getting GdkSurface attached to it but that is returning the surface of the GtkWindow.

I am looking for a way to get XID to pass to gst_video_overlay_set_window_handle to be able to play video in the widget.

I am fairly new to both Gtk and Gstreamer so apologies for gaps in my understanding.

1
  • 1
    Random guess: Gtk does not create an extra X11 window for the drawing area. Hence, there is no XID that it could give you. This would also explain why you get the surface from the GtkWindow: This is the surface that the drawing area would draw to. Commented Jul 1, 2021 at 14:05

1 Answer 1

0

From what I've found this way of embedding GStreamer video in GTK4 GUI is no longer correct.

Your options are:

  1. gst-plugin-gtk4
    But that is an additional dependency

  2. GtkVideo
    But I've seen someone complaining about performance

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.