va: Return default device from device-path property getter

Otherwise application would not be able to know matching element
for wanted device. Typical use case of the read-only device path
(DXGI Adapter LUID, CUDA device index, etc) property is that
application enumerates physical devices and then selects matching
GStreamer element (in null state) via device path property.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4220>
This commit is contained in:
Seungha Yang 2023-03-18 20:23:10 +09:00 committed by GStreamer Marge Bot
parent 47b8618b2d
commit 3bbfab1cf3
4 changed files with 32 additions and 20 deletions

View file

@ -34,14 +34,17 @@ gst_va_base_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaBaseDec *self = GST_VA_BASE_DEC (object);
GstVaBaseDecClass *klass = GST_VA_BASE_DEC_GET_CLASS (self);
switch (prop_id) {
case GST_VA_DEC_PROP_DEVICE_PATH:{
if (!(self->display && GST_IS_VA_DISPLAY_PLATFORM (self->display))) {
g_value_set_string (value, NULL);
return;
}
if (!self->display)
g_value_set_string (value, klass->render_device_path);
else if (GST_IS_VA_DISPLAY_PLATFORM (self->display))
g_object_get_property (G_OBJECT (self->display), "path", value);
else
g_value_set_string (value, NULL);
break;
}
default:
@ -748,7 +751,7 @@ gst_va_base_dec_class_init (GstVaBaseDecClass * klass, GstVaCodecs codec,
g_object_class_install_property (object_class, GST_VA_DEC_PROP_DEVICE_PATH,
g_param_spec_string ("device-path", "Device Path",
GST_VA_DEVICE_PATH_PROP_DESC, NULL,
GST_VA_DEVICE_PATH_PROP_DESC, NULL, GST_PARAM_DOC_SHOW_DEFAULT |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}

View file

@ -849,14 +849,17 @@ gst_va_base_enc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaBaseEnc *base = GST_VA_BASE_ENC (object);
GstVaBaseEncClass *klass = GST_VA_BASE_ENC_GET_CLASS (base);
switch (prop_id) {
case PROP_DEVICE_PATH:{
if (!(base->display && GST_IS_VA_DISPLAY_PLATFORM (base->display))) {
g_value_set_string (value, NULL);
return;
}
if (!base->display)
g_value_set_string (value, klass->render_device_path);
else if (GST_IS_VA_DISPLAY_PLATFORM (base->display))
g_object_get_property (G_OBJECT (base->display), "path", value);
else
g_value_set_string (value, NULL);
break;
}
default:
@ -919,7 +922,7 @@ gst_va_base_enc_class_init (GstVaBaseEncClass * klass)
*/
properties[PROP_DEVICE_PATH] = g_param_spec_string ("device-path",
"Device Path", GST_VA_DEVICE_PATH_PROP_DESC, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
GST_PARAM_DOC_SHOW_DEFAULT | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPERTIES, properties);

View file

@ -74,14 +74,17 @@ gst_va_base_transform_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaBaseTransform *self = GST_VA_BASE_TRANSFORM (object);
GstVaBaseTransformClass *klass = GST_VA_BASE_TRANSFORM_GET_CLASS (self);
switch (prop_id) {
case PROP_DEVICE_PATH:{
if (!(self->display && GST_IS_VA_DISPLAY_PLATFORM (self->display))) {
g_value_set_string (value, NULL);
return;
}
if (!self->display)
g_value_set_string (value, klass->render_device_path);
else if (GST_IS_VA_DISPLAY_PLATFORM (self->display))
g_object_get_property (G_OBJECT (self->display), "path", value);
else
g_value_set_string (value, NULL);
break;
}
default:
@ -649,7 +652,7 @@ gst_va_base_transform_class_init (GstVaBaseTransformClass * klass)
*/
properties[PROP_DEVICE_PATH] = g_param_spec_string ("device-path",
"Device Path", GST_VA_DEVICE_PATH_PROP_DESC, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
GST_PARAM_DOC_SHOW_DEFAULT | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPERTIES, properties);

View file

@ -288,15 +288,18 @@ gst_va_compositor_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaCompositor *self = GST_VA_COMPOSITOR (object);
GstVaCompositorClass *klass = GST_VA_COMPOSITOR_GET_CLASS (self);
switch (prop_id) {
case PROP_DEVICE_PATH:
{
if (!(self->display && GST_IS_VA_DISPLAY_PLATFORM (self->display))) {
g_value_set_string (value, NULL);
return;
}
if (!self->display)
g_value_set_string (value, klass->render_device_path);
else if (GST_IS_VA_DISPLAY_PLATFORM (self->display))
g_object_get_property (G_OBJECT (self->display), "path", value);
else
g_value_set_string (value, NULL);
break;
}
case PROP_SCALE_METHOD:
@ -1408,7 +1411,7 @@ gst_va_compositor_class_init (gpointer g_class, gpointer class_data)
*/
properties[PROP_DEVICE_PATH] = g_param_spec_string ("device-path",
"Device Path", GST_VA_DEVICE_PATH_PROP_DESC, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
GST_PARAM_DOC_SHOW_DEFAULT | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* GstVaCompositor:scale-method: