vadisplay: Add description readonly property

Expose description of vendor for user information, similar to
the description property of d3d11device.
Also, set description and DRM device path on GstContext structure
so that user can read them and it will be printed on terminal
when gst-launch-1.0 is used

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2064>
This commit is contained in:
Seungha Yang 2022-03-30 02:49:40 +09:00 committed by GStreamer Marge Bot
parent f465156bf9
commit 6451a13b0b
2 changed files with 40 additions and 6 deletions

View file

@ -55,6 +55,7 @@ struct _GstVaDisplayPrivate
gboolean foreign;
gboolean init;
GstVaImplementation impl;
gchar *vendor_desc;
};
#define gst_va_display_parent_class parent_class
@ -65,6 +66,7 @@ G_DEFINE_TYPE_WITH_CODE (GstVaDisplay, gst_va_display, GST_TYPE_OBJECT,
enum
{
PROP_VA_DISPLAY = 1,
PROP_DESC,
N_PROPERTIES
};
@ -105,6 +107,7 @@ _gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
priv->foreign = TRUE;
}
priv->impl = _get_implementation (vendor);
priv->vendor_desc = g_strdup (vendor);
return TRUE;
}
@ -157,6 +160,9 @@ gst_va_display_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_VA_DISPLAY:
g_value_set_pointer (value, priv->display);
break;
case PROP_DESC:
g_value_set_string (value, priv->vendor_desc);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -191,6 +197,10 @@ gst_va_display_dispose (GObject * object)
static void
gst_va_display_finalize (GObject * object)
{
GstVaDisplayPrivate *priv = GET_PRIV (object);
g_free (priv->vendor_desc);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -209,6 +219,11 @@ gst_va_display_class_init (GstVaDisplayClass * klass)
g_param_spec_pointer ("va-display", "VADisplay", "VA Display handler",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_properties[PROP_DESC] =
g_param_spec_string ("description", "Description",
"Vendor specific VA implementation description", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPERTIES, g_properties);
}

View file

@ -423,12 +423,31 @@ gst_context_set_va_display (GstContext * context, GstVaDisplay * display)
g_return_if_fail (context != NULL);
if (display) {
GST_CAT_LOG (GST_CAT_CONTEXT,
"setting GstVaDisplay (%" GST_PTR_FORMAT ") on context (%"
GST_PTR_FORMAT ")", display, context);
}
s = gst_context_writable_structure (context);
gst_structure_set (s, "gst-display", GST_TYPE_OBJECT, display, NULL);
if (display) {
GObjectClass *klass = G_OBJECT_GET_CLASS (display);
gchar *vendor_desc = NULL;
gchar *path = NULL;
g_object_get (display, "description", &vendor_desc, NULL);
if (g_object_class_find_property (klass, "path"))
g_object_get (display, "path", &path, NULL);
GST_CAT_LOG (GST_CAT_CONTEXT,
"setting GstVaDisplay (%" GST_PTR_FORMAT ") on context (%"
GST_PTR_FORMAT "), description: \"%s\", path: %s", display, context,
GST_STR_NULL (vendor_desc), GST_STR_NULL (path));
if (vendor_desc) {
gst_structure_set (s, "description", G_TYPE_STRING, vendor_desc, NULL);
g_free (vendor_desc);
}
if (path) {
gst_structure_set (s, "path", G_TYPE_STRING, path, NULL);
g_free (path);
}
}
}