mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:28:32 +00:00
test: vaapicontext: process have-context bus message
This commit is contained in:
parent
4d29f4c8c4
commit
af0bf7212b
1 changed files with 40 additions and 0 deletions
|
@ -50,6 +50,7 @@ typedef struct _CustomData
|
||||||
VADisplay va_display;
|
VADisplay va_display;
|
||||||
GstElement *pipeline;
|
GstElement *pipeline;
|
||||||
guintptr videoarea_handle[2];
|
guintptr videoarea_handle[2];
|
||||||
|
GstObject *gstvaapidisplay;
|
||||||
} AppData;
|
} AppData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -133,6 +134,18 @@ bus_sync_handler (GstBus * bus, GstMessage * msg, gpointer data)
|
||||||
gst_println ("Got need context %s from %s", context_type,
|
gst_println ("Got need context %s from %s", context_type,
|
||||||
GST_MESSAGE_SRC_NAME (msg));
|
GST_MESSAGE_SRC_NAME (msg));
|
||||||
|
|
||||||
|
if (g_strcmp0 (context_type, "gst.vaapi.Display") == 0) {
|
||||||
|
if (app->gstvaapidisplay) {
|
||||||
|
GstStructure *s;
|
||||||
|
|
||||||
|
context = gst_context_new ("gst.vaapi.Display", FALSE);
|
||||||
|
s = gst_context_writable_structure (context);
|
||||||
|
gst_structure_set (s, "gst.vaapi.Display",
|
||||||
|
GST_TYPE_OBJECT, app->gstvaapidisplay, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (context_type, "gst.vaapi.app.Display") != 0)
|
if (g_strcmp0 (context_type, "gst.vaapi.app.Display") != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -156,6 +169,32 @@ bus_sync_handler (GstBus * bus, GstMessage * msg, gpointer data)
|
||||||
(GST_MESSAGE_SRC (msg)), app->videoarea_handle[0]);
|
(GST_MESSAGE_SRC (msg)), app->videoarea_handle[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GST_MESSAGE_HAVE_CONTEXT:{
|
||||||
|
const gchar *context_type;
|
||||||
|
const GstStructure *s;
|
||||||
|
GstContext *context = NULL;
|
||||||
|
const GValue *value;
|
||||||
|
|
||||||
|
gst_message_parse_have_context (msg, &context);
|
||||||
|
if (!context)
|
||||||
|
break;
|
||||||
|
|
||||||
|
context_type = gst_context_get_context_type (context);
|
||||||
|
gst_println ("Got have context %s from %s", context_type,
|
||||||
|
GST_MESSAGE_SRC_NAME (msg));
|
||||||
|
|
||||||
|
if (g_strcmp0 (context_type, "gst.vaapi.Display") != 0)
|
||||||
|
break;
|
||||||
|
s = gst_context_get_structure (context);
|
||||||
|
if (!s)
|
||||||
|
break;
|
||||||
|
value = gst_structure_get_value (s, "gst.vaapi.Display");
|
||||||
|
if (!value)
|
||||||
|
break;
|
||||||
|
app->gstvaapidisplay = g_value_dup_object (value);
|
||||||
|
gst_println ("found display %s", GST_OBJECT_NAME (app->gstvaapidisplay));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
@ -308,6 +347,7 @@ main (gint argc, gchar ** argv)
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
gst_object_unref (app.pipeline);
|
gst_object_unref (app.pipeline);
|
||||||
|
gst_object_unref (app.gstvaapidisplay);
|
||||||
/* there is no need to call vaTerminate() because it is done by the
|
/* there is no need to call vaTerminate() because it is done by the
|
||||||
* vaapi elements */
|
* vaapi elements */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue