mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 07:28:53 +00:00
videooverlay: add convenience API to check if a message is a prepare-window-handle message
API: gst_is_video_overlay_prepare_window_handle_message()
This commit is contained in:
parent
d5f44ec6ea
commit
301bd8b0bf
5 changed files with 61 additions and 42 deletions
|
@ -64,10 +64,7 @@
|
||||||
* create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
* create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||||
* {
|
* {
|
||||||
* // ignore anything but 'prepare-window-handle' element messages
|
* // ignore anything but 'prepare-window-handle' element messages
|
||||||
* if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
|
* if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
||||||
* return GST_BUS_PASS;
|
|
||||||
*
|
|
||||||
* if (!gst_structure_has_name (message->structure, "prepare-window-handle"))
|
|
||||||
* return GST_BUS_PASS;
|
* return GST_BUS_PASS;
|
||||||
*
|
*
|
||||||
* win = XCreateSimpleWindow (disp, root, 0, 0, 320, 240, 0, 0, 0);
|
* win = XCreateSimpleWindow (disp, root, 0, 0, 320, 240, 0, 0, 0);
|
||||||
|
@ -154,9 +151,7 @@
|
||||||
* bus_sync_handler (GstBus * bus, GstMessage * message, gpointer user_data)
|
* bus_sync_handler (GstBus * bus, GstMessage * message, gpointer user_data)
|
||||||
* {
|
* {
|
||||||
* // ignore anything but 'prepare-window-handle' element messages
|
* // ignore anything but 'prepare-window-handle' element messages
|
||||||
* if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
|
* if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
||||||
* return GST_BUS_PASS;
|
|
||||||
* if (!gst_structure_has_name (message->structure, "prepare-window-handle"))
|
|
||||||
* return GST_BUS_PASS;
|
* return GST_BUS_PASS;
|
||||||
*
|
*
|
||||||
* if (video_window_xid != 0) {
|
* if (video_window_xid != 0) {
|
||||||
|
@ -493,3 +488,25 @@ gst_video_overlay_set_render_rectangle (GstVideoOverlay * overlay,
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_is_video_overlay_prepare_window_handle_message:
|
||||||
|
* @msg: a #GstMessage
|
||||||
|
*
|
||||||
|
* Convenience function to check if the given message is a
|
||||||
|
* "prepare-window-handle" message from a #GstVideoOverlay.
|
||||||
|
*
|
||||||
|
* Since: 0.11.2
|
||||||
|
*
|
||||||
|
* Returns: whether @msg is a "prepare-window-handle" message
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_is_video_overlay_prepare_window_handle_message (GstMessage * msg)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (msg != NULL, FALSE);
|
||||||
|
|
||||||
|
if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return gst_message_has_name (msg, "prepare-window-handle");
|
||||||
|
}
|
||||||
|
|
|
@ -92,6 +92,8 @@ void gst_video_overlay_got_window_handle (GstVideoOverlay * overlay,
|
||||||
|
|
||||||
void gst_video_overlay_prepare_window_handle (GstVideoOverlay * overlay);
|
void gst_video_overlay_prepare_window_handle (GstVideoOverlay * overlay);
|
||||||
|
|
||||||
|
gboolean gst_is_video_overlay_prepare_window_handle_message (GstMessage * msg);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_VIDEO_OVERLAY_H__ */
|
#endif /* __GST_VIDEO_OVERLAY_H__ */
|
||||||
|
|
|
@ -2446,27 +2446,28 @@ static gulong embed_xid = 0;
|
||||||
static GstBusSyncReply
|
static GstBusSyncReply
|
||||||
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
|
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
|
||||||
{
|
{
|
||||||
if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) &&
|
GstElement *element;
|
||||||
gst_message_has_name (message, "prepare-window-handle")) {
|
|
||||||
GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
|
|
||||||
|
|
||||||
g_print ("got prepare-window-handle, setting XID %lu\n", embed_xid);
|
if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
||||||
|
return GST_BUS_PASS;
|
||||||
|
|
||||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
element = GST_ELEMENT (GST_MESSAGE_SRC (message));
|
||||||
"force-aspect-ratio")) {
|
|
||||||
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Should have been initialised from main thread before (can't use
|
g_print ("got prepare-window-handle, setting XID %lu\n", embed_xid);
|
||||||
* GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
|
|
||||||
* be called from a streaming thread and GDK_WINDOW_XID maps to more than
|
|
||||||
* a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
|
|
||||||
* shouldn't be done from a non-GUI thread without explicit locking). */
|
|
||||||
g_assert (embed_xid != 0);
|
|
||||||
|
|
||||||
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element),
|
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
||||||
embed_xid);
|
"force-aspect-ratio")) {
|
||||||
|
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Should have been initialised from main thread before (can't use
|
||||||
|
* GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
|
||||||
|
* be called from a streaming thread and GDK_WINDOW_XID maps to more than
|
||||||
|
* a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
|
||||||
|
* shouldn't be done from a non-GUI thread without explicit locking). */
|
||||||
|
g_assert (embed_xid != 0);
|
||||||
|
|
||||||
|
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element), embed_xid);
|
||||||
return GST_BUS_PASS;
|
return GST_BUS_PASS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1583,27 +1583,28 @@ static gulong embed_xid = 0;
|
||||||
static GstBusSyncReply
|
static GstBusSyncReply
|
||||||
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
|
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
|
||||||
{
|
{
|
||||||
if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) &&
|
GstElement *element;
|
||||||
gst_message_has_name (message, "prepare-window-handle")) {
|
|
||||||
GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
|
|
||||||
|
|
||||||
g_print ("got prepare-window-handle, setting XID %lu\n", embed_xid);
|
if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
||||||
|
return GST_BUS_PASS;
|
||||||
|
|
||||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
element = GST_ELEMENT (GST_MESSAGE_SRC (message));
|
||||||
"force-aspect-ratio")) {
|
|
||||||
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Should have been initialised from main thread before (can't use
|
g_print ("got prepare-window-handle, setting XID %lu\n", embed_xid);
|
||||||
* GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
|
|
||||||
* be called from a streaming thread and GDK_WINDOW_XID maps to more than
|
|
||||||
* a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
|
|
||||||
* shouldn't be done from a non-GUI thread without explicit locking). */
|
|
||||||
g_assert (embed_xid != 0);
|
|
||||||
|
|
||||||
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element),
|
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
||||||
embed_xid);
|
"force-aspect-ratio")) {
|
||||||
|
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Should have been initialised from main thread before (can't use
|
||||||
|
* GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
|
||||||
|
* be called from a streaming thread and GDK_WINDOW_XID maps to more than
|
||||||
|
* a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
|
||||||
|
* shouldn't be done from a non-GUI thread without explicit locking). */
|
||||||
|
g_assert (embed_xid != 0);
|
||||||
|
|
||||||
|
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element), embed_xid);
|
||||||
return GST_BUS_PASS;
|
return GST_BUS_PASS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -145,10 +145,8 @@ create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||||
const GstStructure *s;
|
const GstStructure *s;
|
||||||
GstVideoOverlay *ov = NULL;
|
GstVideoOverlay *ov = NULL;
|
||||||
|
|
||||||
s = gst_message_get_structure (message);
|
if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
||||||
if (s == NULL || !gst_structure_has_name (s, "prepare-window-handle")) {
|
|
||||||
return GST_BUS_PASS;
|
return GST_BUS_PASS;
|
||||||
}
|
|
||||||
|
|
||||||
ov = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
|
ov = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue