mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
structure-interface: Convert fields type as much as possible
Since 60922c0288
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>
This commit is contained in:
parent
c761711a7a
commit
a5a590ba17
4 changed files with 54 additions and 2 deletions
|
@ -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},
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
11
tests/check/scenarios/set-layer-on-command-line.validatetest
Normal file
11
tests/check/scenarios/set-layer-on-command-line.validatetest
Normal file
|
@ -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
|
Loading…
Reference in a new issue