summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2021-05-18 21:31:38 -0400
committerThibault Saunier <tsaunier@igalia.com>2021-05-18 22:16:47 -0400
commita5a590ba17830c9379c11bd51e6fde1f990e1aa9 (patch)
tree118ec81b91cfbcb36e8dec343fe135ad1c9646ea
parentc761711a7a0c9dbf9d2f3faeae1e51776f6d0678 (diff)
structure-interface: Convert fields type as much as possible
Since 60922c02889cf1ebcfaca4501936be689c342e01 we force string in the command line parser which broke setting layers on clips for example Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/253>
-rw-r--r--ges/ges-command-line-formatter.c2
-rw-r--r--ges/ges-structured-interface.c42
-rw-r--r--tests/check/meson.build1
-rw-r--r--tests/check/scenarios/set-layer-on-command-line.validatetest11
4 files changed, 54 insertions, 2 deletions
diff --git a/ges/ges-command-line-formatter.c b/ges/ges-command-line-formatter.c
index 30d1853b..823d9510 100644
--- a/ges/ges-command-line-formatter.c
+++ b/ges/ges-command-line-formatter.c
@@ -247,7 +247,7 @@ static GESCommandLineOption options[] = {
"The type of the tracks where the clip should be used (audio or video or audio+video)."
},
{
- "layer", "l", 0, NULL,
+ "layer", "l", G_TYPE_INT, NULL,
"The priority of the layer into which the clip should be added."
},
{NULL, 0, 0, NULL, FALSE},
diff --git a/ges/ges-structured-interface.c b/ges/ges-structured-interface.c
index 253b9b40..0ee9ab12 100644
--- a/ges/ges-structured-interface.c
+++ b/ges/ges-structured-interface.c
@@ -88,9 +88,49 @@
} \
} G_STMT_END
+static gboolean
+_get_structure_value (GstStructure * structure, const gchar * field, GType type,
+ gpointer v)
+{
+ gboolean res = TRUE;
+ const gchar *value_str;
+ const GValue *value;
+ GValue nvalue = G_VALUE_INIT;
+
+ if (gst_structure_get (structure, field, type, v, NULL))
+ return res;
+
+ g_value_init (&nvalue, type);
+ value = gst_structure_get_value (structure, field);
+ if (!value)
+ goto fail;
+
+ if (g_value_transform (value, &nvalue))
+ goto set_and_get_value;
+
+ if (!G_VALUE_HOLDS_STRING (value))
+ goto fail;
+
+ value_str = g_value_get_string (value);
+ if (!gst_value_deserialize (&nvalue, value_str))
+ goto done;
+
+set_and_get_value:
+ gst_structure_set_value (structure, field, &nvalue);
+ gst_structure_get (structure, field, type, v, NULL);
+
+done:
+ g_value_reset (&nvalue);
+ return res;
+
+fail:
+ res = FALSE;
+ goto done;
+}
+
#define TRY_GET(name, type, var, def) G_STMT_START {\
g_assert (type != GST_TYPE_CLOCK_TIME); \
- if (!gst_structure_get (structure, name, type, var, NULL))\
+ if (!_get_structure_value (structure, name, type, var))\
*var = def; \
} G_STMT_END
diff --git a/tests/check/meson.build b/tests/check/meson.build
index 6cdac7d1..9a6ada72 100644
--- a/tests/check/meson.build
+++ b/tests/check/meson.build
@@ -89,6 +89,7 @@ if gstvalidate_dep.found()
'complex_effect_bin_desc': true,
'check_keyframes_in_compositor_two_sources': true,
'check-clip-positioning': true,
+ 'set-layer-on-command-line': true,
}
foreach scenario, is_validatetest: scenarios
diff --git a/tests/check/scenarios/set-layer-on-command-line.validatetest b/tests/check/scenarios/set-layer-on-command-line.validatetest
new file mode 100644
index 00000000..d590bb81
--- /dev/null
+++ b/tests/check/scenarios/set-layer-on-command-line.validatetest
@@ -0,0 +1,11 @@
+meta, handles-states=true,
+ tool = "ges-launch-$(gst_api_version)",
+ handles-states=true,
+ args = {
+ +test-clip, blue, "d=0.5", "layer=0", "name=blue",
+ +test-clip, green, "d=0.5", "layer=1", "name=green",
+ }
+
+check-ges-properties, element-name=blue, layer::priority=0
+check-ges-properties, element-name=green, layer::priority=1
+stop \ No newline at end of file