diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2019-05-26 09:55:03 -0400 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-08-14 23:37:58 +0100 |
commit | 0cba445a7691216fe1e5503e93eb0fc8917e8899 (patch) | |
tree | 2cf5ad952d2a662a4e4a15d197f40c782d062db3 | |
parent | d5754aaed3455c229a481e945a4550023ee41a3a (diff) |
validate: Add action type to copy/paste clips
-rw-r--r-- | ges/ges-validate.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/ges/ges-validate.c b/ges/ges-validate.c index 5cd4e15b..4d17354f 100644 --- a/ges/ges-validate.c +++ b/ges/ges-validate.c @@ -495,6 +495,56 @@ _ungroup (GstValidateScenario * scenario, GstValidateAction * action) return res; } +static GstValidateExecuteActionReturn +_copy_element (GstValidateScenario * scenario, GstValidateAction * action) +{ + GESTimelineElement *element, *copied, *pasted; + gboolean recursive = FALSE; + const gchar *element_name, *paste_name; + GstClockTime position; + DECLARE_AND_GET_TIMELINE (scenario, action); + + + element_name = gst_structure_get_string (action->structure, "element-name"); + element = ges_timeline_get_element (timeline, element_name); + + g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (element), + GST_VALIDATE_EXECUTE_ACTION_ERROR); + + gst_validate_printf (action, "Copying element %s\n", + GES_TIMELINE_ELEMENT_NAME (element)); + + if (!gst_structure_get_boolean (action->structure, "recursive", &recursive)) + recursive = TRUE; + + g_return_val_if_fail (gst_validate_action_get_clocktime (scenario, action, + "position", &position), FALSE); + + copied = ges_timeline_element_copy (element, recursive); + pasted = ges_timeline_element_paste (copied, position); + gst_object_unref (timeline); + + if (!pasted) { + GST_VALIDATE_REPORT (scenario, + g_quark_from_string ("scenario::execution-error"), + "Could not paste clip %s", element_name); + return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + } + + paste_name = gst_structure_get_string (action->structure, "paste-name"); + if (paste_name) { + if (!ges_timeline_element_set_name (pasted, paste_name)) { + GST_VALIDATE_REPORT (scenario, + g_quark_from_string ("scenario::execution-error"), + "Could not set element name %s", paste_name); + + return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + } + } + + return GST_VALIDATE_EXECUTE_ACTION_OK; +} + static gboolean _set_control_source (GstValidateScenario * scenario, GstValidateAction * action) { @@ -1100,6 +1150,36 @@ ges_validate_register_action_types (void) {NULL} }, "Remove a child from @container-name.", GST_VALIDATE_ACTION_TYPE_NONE); + gst_validate_register_action_type ("copy-element", "ges", _copy_element, + (GstValidateActionParameter []) { + { + .name = "element-name", + .description = "The name of the GESTtimelineElement to copy", + .types = "string", + .mandatory = TRUE, + }, + { + .name = "recurse", + .description = "Copy recursively or not", + .types = "boolean", + .def = "true", + .mandatory = FALSE, + }, + { + .name = "position", + .description = "The time where to paste the element", + .types = "string or float", + .mandatory = TRUE, + }, + { + .name = "paste-name", + .description = "The name of the copied element", + .types = "string", + .mandatory = FALSE, + }, + {NULL} + }, "Remove a child from @container-name.", GST_VALIDATE_ACTION_TYPE_NONE); + gst_validate_register_action_type ("remove-keyframe", "ges", _validate_action_execute, (GstValidateActionParameter []) { { |