Hi,
I use example from the internet and when I'm using glimagesink everything is ok, but when I use vaapisink the overlay does not work correct, only black screen. When I use gst-inspect with vaapisink it's ok, but Gtk overlay does not work. What's wrong? Thanks for all help. My code: #include <gst/gst.h> #include <gst/video/videooverlay.h> #include <gtk/gtk.h> #include <gdk/gdk.h> #if defined (GDK_WINDOWING_X11) #include <gdk/gdkx.h> #elif defined (GDK_WINDOWING_WIN32) #include <gdk/gdkwin32.h> #elif defined (GDK_WINDOWING_QUARTZ) #include <gdk/gdkquartz.h> #endif static void realize_cb (GtkWidget *widget, GstElement *sink) { 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 GstXOverlay!"); #if defined (GDK_WINDOWING_WIN32) window_handle = (guintptr)GDK_WINDOW_HWND (window); #elif defined (GDK_WINDOWING_QUARTZ) window_handle = gdk_quartz_window_get_nsview (window); #elif defined (GDK_WINDOWING_X11) window_handle = GDK_WINDOW_XID (window); #endif gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), window_handle); } int main (void) { gst_init (NULL, NULL); gtk_init (NULL, NULL); GError *error = NULL; GstElement *pipeline, *sink; GtkWidget *windowHead = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *video_window; pipeline = gst_parse_launch ("rtspsrc latency=5 drop-on-latency=true protocols=1 location=rtsp://x.x.x.x ! rtph264depay ! h264parse ! vaapidecodebin ! vaapisink name=sink", &error); sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); video_window = gtk_drawing_area_new (); g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), sink); gtk_container_add (GTK_CONTAINER (windowHead), video_window); gtk_window_set_default_size (GTK_WINDOW (windowHead), 800, 600); gtk_widget_show_all (windowHead); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_print ("Now playing...\n"); gtk_main(); return 0; } |
Hi,
On 08/05/16 at 11:54pm, imeshns wrote: > Hi, > > I use example from the internet and when I'm using glimagesink everything is > ok, but when I use vaapisink the overlay does not work correct, only black > screen. When I use gst-inspect with vaapisink it's ok, but Gtk overlay does > not work. > What's wrong? > Thanks for all help. > > My code: > > #include <gst/gst.h> > #include <gst/video/videooverlay.h> > #include <gtk/gtk.h> > #include <gdk/gdk.h> > > #if defined (GDK_WINDOWING_X11) > #include <gdk/gdkx.h> > #elif defined (GDK_WINDOWING_WIN32) > #include <gdk/gdkwin32.h> > #elif defined (GDK_WINDOWING_QUARTZ) > #include <gdk/gdkquartz.h> > #endif > > static void realize_cb (GtkWidget *widget, GstElement *sink) > { > 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 GstXOverlay!"); > > #if defined (GDK_WINDOWING_WIN32) > window_handle = (guintptr)GDK_WINDOW_HWND (window); > #elif defined (GDK_WINDOWING_QUARTZ) > window_handle = gdk_quartz_window_get_nsview (window); > #elif defined (GDK_WINDOWING_X11) > window_handle = GDK_WINDOW_XID (window); > #endif > > gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), > window_handle); > } > > int main (void) > { > gst_init (NULL, NULL); > gtk_init (NULL, NULL); > GError *error = NULL; > > GstElement *pipeline, *sink; > > GtkWidget *windowHead = gtk_window_new(GTK_WINDOW_TOPLEVEL); > GtkWidget *video_window; > > pipeline = gst_parse_launch ("rtspsrc latency=5 drop-on-latency=true > protocols=1 location=rtsp://x.x.x.x ! rtph264depay ! h264parse ! > vaapidecodebin ! vaapisink name=sink", &error); > sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); > > video_window = gtk_drawing_area_new (); > g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), sink); > > gtk_container_add (GTK_CONTAINER (windowHead), video_window); > gtk_window_set_default_size (GTK_WINDOW (windowHead), 800, 600); > > gtk_widget_show_all (windowHead); > gst_element_set_state (pipeline, GST_STATE_PLAYING); Here, the pipeline is launched, and the video overlay already has the window handle, but the window geometry is not set yet. A workaround would be to call gst_element_set_state() in g_idle_add(), which I think is a sane practice. Nonetheless it looks to me there's a bug in vaapisink for X11, since it is not catching the configure notifications. vmjl > > g_print ("Now playing...\n"); > > gtk_main(); > > return 0; > } > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/vaapisink-overlay-tp4678988.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Thanks for reply.
I called gst_element_set_state in g_idle_add() but nothing changed. In previous version of my code I had error: "CRITICAL **: gst_vaapi_window_new_internal: assertion 'width > 0' failed". What does it mean? Maybe I have to change manually size of vaapi window before I call PLAY. But where and how? Or maybe you're right. There is a bug in gstreamer-vaapi. Any sugestions? Thanks. |
On 08/07/16 at 04:11am, imeshns wrote:
> Thanks for reply. > I called gst_element_set_state in g_idle_add() but nothing changed. > In previous version of my code I had error: > > "CRITICAL **: gst_vaapi_window_new_internal: assertion 'width > 0' failed". > > What does it mean? Maybe I have to change manually size of vaapi window > before I call PLAY. But where and how? Or maybe you're right. There is a bug > in gstreamer-vaapi. > Any sugestions? > Thanks. Ah! The assignation of the vaapi window inside a drawing area is when you call gst_video_overlay_set_window_handle(). And you call it when you receive the realize callback. But in that moment, the widget, doesn't have a geometry, so vaapisink cannot be created because width == 0. What you have to do in your code is to save the XID in a temporal variable, and call gst_video_overlay_set_window_handle(), in play(), before gst_element_set_state(). A solution in vaapisink is to delay the window binding until it is going to be used for real. Can you file a bug in bugzilla for gstreamer-vaapi, please? vmjl > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/vaapisink-overlay-tp4678988p4679004.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by imeshns
For sake of completion, there is a closed bug regarding this issue:
https://bugzilla.gnome.org/show_bug.cgi?id=770877 vmjl On 08/05/16 at 11:54pm, imeshns wrote: > Hi, > > I use example from the internet and when I'm using glimagesink everything is > ok, but when I use vaapisink the overlay does not work correct, only black > screen. When I use gst-inspect with vaapisink it's ok, but Gtk overlay does > not work. > What's wrong? > Thanks for all help. > > My code: > > #include <gst/gst.h> > #include <gst/video/videooverlay.h> > #include <gtk/gtk.h> > #include <gdk/gdk.h> > > #if defined (GDK_WINDOWING_X11) > #include <gdk/gdkx.h> > #elif defined (GDK_WINDOWING_WIN32) > #include <gdk/gdkwin32.h> > #elif defined (GDK_WINDOWING_QUARTZ) > #include <gdk/gdkquartz.h> > #endif > > static void realize_cb (GtkWidget *widget, GstElement *sink) > { > 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 GstXOverlay!"); > > #if defined (GDK_WINDOWING_WIN32) > window_handle = (guintptr)GDK_WINDOW_HWND (window); > #elif defined (GDK_WINDOWING_QUARTZ) > window_handle = gdk_quartz_window_get_nsview (window); > #elif defined (GDK_WINDOWING_X11) > window_handle = GDK_WINDOW_XID (window); > #endif > > gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), > window_handle); > } > > int main (void) > { > gst_init (NULL, NULL); > gtk_init (NULL, NULL); > GError *error = NULL; > > GstElement *pipeline, *sink; > > GtkWidget *windowHead = gtk_window_new(GTK_WINDOW_TOPLEVEL); > GtkWidget *video_window; > > pipeline = gst_parse_launch ("rtspsrc latency=5 drop-on-latency=true > protocols=1 location=rtsp://x.x.x.x ! rtph264depay ! h264parse ! > vaapidecodebin ! vaapisink name=sink", &error); > sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); > > video_window = gtk_drawing_area_new (); > g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), sink); > > gtk_container_add (GTK_CONTAINER (windowHead), video_window); > gtk_window_set_default_size (GTK_WINDOW (windowHead), 800, 600); > > gtk_widget_show_all (windowHead); > gst_element_set_state (pipeline, GST_STATE_PLAYING); > > g_print ("Now playing...\n"); > > gtk_main(); > > return 0; > } > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/vaapisink-overlay-tp4678988.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |