validate: Handle absolute control binding support when setting keyframes

And minor fix in set-control-source
This commit is contained in:
Thibault Saunier 2020-02-24 08:47:11 -03:00
parent 53637ad749
commit 32dae5e3da
3 changed files with 60 additions and 10 deletions

View file

@ -82,7 +82,7 @@ _get_clocktime (GstStructure * structure, const gchar * name, gpointer var)
gchar *struct_str = gst_structure_to_string (structure); \
*error = g_error_new (GES_ERROR, 0, \
"Could not get the mandatory field '%s'" \
" fields in %s", name, struct_str); \
" of type %s - fields in %s", name, g_type_name (type), struct_str); \
g_free (struct_str); \
goto label;\
} \
@ -181,6 +181,7 @@ _ges_add_remove_keyframe_from_struct (GESTimeline * timeline,
{
GESTrackElement *element;
gboolean absolute;
gdouble value;
GstClockTime timestamp;
GstControlBinding *binding = NULL;
@ -201,7 +202,6 @@ _ges_add_remove_keyframe_from_struct (GESTimeline * timeline,
GET_AND_CHECK ("element-name", G_TYPE_STRING, &element_name, done);
GET_AND_CHECK ("property-name", G_TYPE_STRING, &property_name, done);
GET_AND_CHECK ("value", G_TYPE_DOUBLE, &value, done);
GET_AND_CHECK ("timestamp", GST_TYPE_CLOCK_TIME, &timestamp, done);
element =
@ -242,6 +242,48 @@ _ges_add_remove_keyframe_from_struct (GESTimeline * timeline,
goto done;
}
g_object_get (binding, "absolute", &absolute, NULL);
if (absolute) {
GParamSpec *pspec;
const GValue *v;
GValue v2 = G_VALUE_INIT;
if (!ges_timeline_element_lookup_child (GES_TIMELINE_ELEMENT (element),
property_name, NULL, &pspec)) {
*error =
g_error_new (GES_ERROR, 0, "Could not get property %s for %s",
property_name, GES_TIMELINE_ELEMENT_NAME (element));
goto done;
}
v = gst_structure_get_value (structure, "value");
if (!v) {
gchar *struct_str = gst_structure_to_string (structure);
*error = g_error_new (GES_ERROR, 0,
"Could not get the mandatory field 'value'"
" of type %s - fields in %s", g_type_name (pspec->value_type),
struct_str);
g_free (struct_str);
goto done;
}
g_value_init (&v2, G_TYPE_DOUBLE);
if (!g_value_transform (v, &v2)) {
gchar *struct_str = gst_structure_to_string (structure);
*error = g_error_new (GES_ERROR, 0,
"Could not get the mandatory field 'value'"
" of type %s - fields in %s", g_type_name (pspec->value_type),
struct_str);
g_free (struct_str);
goto done;
}
value = g_value_get_double (&v2);
g_value_reset (&v2);
} else
GET_AND_CHECK ("value", G_TYPE_DOUBLE, &value, done);
if (!g_strcmp0 (gst_structure_get_name (structure), "add-keyframe"))
ret = gst_timed_value_control_source_set (source, timestamp, value);
else {

View file

@ -1294,10 +1294,13 @@ ges_track_element_copy_bindings (GESTrackElement * element,
if (!binding)
continue;
/* FIXME : this should work as well with other types of control sources */
g_object_get (binding, "control_source", &source, NULL);
if (!GST_IS_TIMED_VALUE_CONTROL_SOURCE (source))
if (!GST_IS_TIMED_VALUE_CONTROL_SOURCE (source)) {
GST_FIXME_OBJECT (element,
"Implement support for control source type: %s",
G_OBJECT_TYPE_NAME (source));
continue;
}
g_object_get (binding, "absolute", &absolute, NULL);
g_object_get (source, "mode", &mode, NULL);

View file

@ -127,6 +127,12 @@ done:
} \
}
#define TRY_GET(name,type,var,def) G_STMT_START {\
if (!gst_structure_get (action->structure, name, type, var, NULL)) {\
*var = def; \
} \
} G_STMT_END
static gboolean
_serialize_project (GstValidateScenario * scenario, GstValidateAction * action)
{
@ -837,15 +843,14 @@ _set_control_source (GstValidateScenario * scenario, GstValidateAction * action)
g_return_val_if_fail (gst_structure_get (action->structure,
"element-name", G_TYPE_STRING, &element_name,
"property-name", G_TYPE_STRING, &property_name,
"binding-type", G_TYPE_STRING, &binding_type,
"source-type", G_TYPE_STRING, &source_type,
"interpolation-mode", G_TYPE_STRING, &interpolation_mode, NULL),
FALSE);
"property-name", G_TYPE_STRING, &property_name, NULL), FALSE);
TRY_GET ("binding-type", G_TYPE_STRING, &binding_type, NULL);
TRY_GET ("source-type", G_TYPE_STRING, &source_type, NULL);
TRY_GET ("interpolation-mode", G_TYPE_STRING, &interpolation_mode, NULL);
element =
GES_TRACK_ELEMENT (ges_timeline_get_element (timeline, element_name));
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (element), FALSE);
if (!binding_type)