Hello
I am trying build simple app with GStreamer 1.26.1 in pure C. I need to display video source in gtk window. Trying rewrite Python example from gitlab. Python script works great but my C-code going to blackscreen when window is displayed.
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gst/gst.h>
typedef struct _StreamData {
GstElement *pipeline;
gpointer paintable_ptr;
} StreamData;
static void activate(GtkApplication *app, StreamData *data) {
GtkWidget *window, *picture;
GstStateChangeReturn ret;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "VID");
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
picture = gtk_picture_new_for_paintable(data->paintable_ptr);
gtk_window_set_child(GTK_WINDOW(window), picture);
gtk_application_add_window(app, GTK_WINDOW(window));
gtk_window_present(GTK_WINDOW(window));
gst_element_set_state(data->pipeline, GST_STATE_PLAYING);
}
int main(int argc, char *argv[]) {
StreamData data;
GtkApplication *app;
GstElement *gtksink, *glsink, *src;
GstBus *bus;
gint status;
gst_init(&argc, &argv);
gtksink = gst_element_factory_make("gtk4paintablesink", NULL);
g_assert(gtksink != NULL);
g_object_get(gtksink, "paintable", &data.paintable_ptr, NULL);
glsink = gst_element_factory_make("glsinkbin", NULL);
g_assert(glsink != NULL);
g_object_set(glsink, "sink", gtksink, NULL);
src = gst_element_factory_make("gltestsrc", NULL);
g_assert(src != NULL);
data.pipeline = gst_pipeline_new("main-pipeline");
g_assert(data.pipeline != NULL);
gst_bin_add_many(GST_BIN(data.pipeline), src, glsink, NULL);
g_assert(gst_element_link(src, glsink) == TRUE);
app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), &data);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
g_object_unref(data.pipeline);
return status;
}
Can somebody help me with this issue
PS. Python script says that GL is supported