tools:validate: Add an action to allow editing clips

https://bugzilla.gnome.org/show_bug.cgi?id=729382
This commit is contained in:
Thibault Saunier 2014-02-18 17:25:05 +01:00 committed by Thibault Saunier
parent 1adb9a0030
commit 87e10c4478

View file

@ -23,10 +23,12 @@
#endif
#include "ges-validate.h"
#include <ges/ges.h>
#ifdef HAVE_GST_VALIDATE
#include <gst/validate/gst-validate-scenario.h>
#include <gst/validate/validate.h>
#include <gst/validate/gst-validate-utils.h>
#define MONITOR_ON_PIPELINE "validate-monitor"
#define RUNNER_ON_PIPELINE "runner-monitor"
@ -41,6 +43,64 @@ _validate_report_added_cb (GstValidateRunner * runner,
}
}
static gboolean
_edit_clip (GstValidateScenario * scenario, GstValidateAction * action)
{
GList *layers = NULL;
GstClockTime position;
GESTimeline *timeline;
GESTimelineElement *clip;
gint new_layer_priority = -1;
GESEditMode edge = GES_EDGE_NONE;
GESEditMode mode = GES_EDIT_MODE_NORMAL;
const gchar *edit_mode_str = NULL, *edge_str = NULL;
const gchar *clip_name;
clip_name = gst_structure_get_string (action->structure, "clip-name");
g_object_get (scenario->pipeline, "timeline", &timeline, NULL);
g_return_val_if_fail (timeline, FALSE);
clip = ges_timeline_get_element (timeline, clip_name);
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
if (!gst_validate_action_get_clocktime (scenario, action,
"position", &position)) {
GST_WARNING ("Could not get position");
return FALSE;
}
if ((edit_mode_str =
gst_structure_get_string (action->structure, "edit-mode")))
gst_validate_utils_enum_from_str (GES_TYPE_EDIT_MODE, edit_mode_str, &mode);
if ((edge_str = gst_structure_get_string (action->structure, "edge")))
gst_validate_utils_enum_from_str (GES_TYPE_EDGE, edge_str, &edge);
gst_structure_get_int (action->structure, "new-layer-priority",
&new_layer_priority);
g_print ("\n\n(position %" GST_TIME_FORMAT
"), %s (num %u, missing repeat: %i), "
"Editing %s to %" GST_TIME_FORMAT " in %s mode, edge: %s "
"with new layer prio: %d \n\n",
GST_TIME_ARGS (action->playback_time), action->name,
action->action_number, action->repeat,
clip_name, GST_TIME_ARGS (position),
edit_mode_str ? edit_mode_str : "normal",
edge_str ? edge_str : "None", new_layer_priority);
if (!ges_container_edit (GES_CONTAINER (clip), layers, new_layer_priority,
mode, edge, position)) {
gst_object_unref (clip);
return FALSE;
}
gst_object_unref (clip);
return ges_timeline_commit (timeline);
}
gboolean
ges_validate_activate (GstPipeline * pipeline, const gchar * scenario)
@ -49,6 +109,10 @@ ges_validate_activate (GstPipeline * pipeline, const gchar * scenario)
GstValidateMonitor *monitor = NULL;
if (scenario) {
const gchar *move_clip_mandatory_fields[] = { "clip-name", "position",
NULL
};
gst_validate_init ();
if (g_strcmp0 (scenario, "none")) {
@ -57,6 +121,9 @@ ges_validate_activate (GstPipeline * pipeline, const gchar * scenario)
g_free (scenario_name);
}
gst_validate_add_action_type ("edit-clip", _edit_clip,
move_clip_mandatory_fields, "Allows to seek into the files", FALSE);
runner = gst_validate_runner_new ();
g_signal_connect (runner, "report-added",
G_CALLBACK (_validate_report_added_cb), pipeline);