2013-09-13 21:15:21 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
*
|
|
|
|
* Copyright (C) <2013> Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ges-validate.h"
|
2014-02-18 16:25:05 +00:00
|
|
|
#include <ges/ges.h>
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_GST_VALIDATE
|
|
|
|
#include <gst/validate/gst-validate-scenario.h>
|
|
|
|
#include <gst/validate/validate.h>
|
2014-02-18 16:25:05 +00:00
|
|
|
#include <gst/validate/gst-validate-utils.h>
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
#define MONITOR_ON_PIPELINE "validate-monitor"
|
|
|
|
#define RUNNER_ON_PIPELINE "runner-monitor"
|
|
|
|
|
|
|
|
static void
|
|
|
|
_validate_report_added_cb (GstValidateRunner * runner,
|
|
|
|
GstValidateReport * report, GstPipeline * pipeline)
|
|
|
|
{
|
|
|
|
if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch--validate-error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 16:23:06 +00:00
|
|
|
static GESTimeline *
|
|
|
|
get_timeline (GstValidateScenario * scenario)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
|
|
|
|
g_object_get (scenario->pipeline, "timeline", &timeline, NULL);
|
|
|
|
|
|
|
|
return timeline;
|
|
|
|
}
|
|
|
|
|
2014-03-14 11:10:53 +00:00
|
|
|
static gboolean
|
|
|
|
_set_child_property (GstValidateScenario * scenario, GstValidateAction * action)
|
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESTimelineElement *element;
|
|
|
|
const gchar *property_name, *element_name;
|
|
|
|
|
|
|
|
element_name = gst_structure_get_string (action->structure, "element-name");
|
|
|
|
|
2014-04-25 16:23:06 +00:00
|
|
|
timeline = get_timeline (scenario);
|
2014-03-14 11:10:53 +00:00
|
|
|
g_return_val_if_fail (timeline, FALSE);
|
|
|
|
|
|
|
|
element = ges_timeline_get_element (timeline, element_name);
|
|
|
|
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (element), FALSE);
|
|
|
|
|
|
|
|
property_name = gst_structure_get_string (action->structure, "property");
|
|
|
|
value = gst_structure_get_value (action->structure, "value");
|
|
|
|
|
|
|
|
GST_DEBUG ("%s Setting %s property to %p",
|
|
|
|
element->name, property_name, value);
|
|
|
|
ges_track_element_set_child_property (GES_TRACK_ELEMENT (element),
|
|
|
|
property_name, (GValue *) value);
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
|
2014-03-14 11:10:53 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-02 14:43:42 +00:00
|
|
|
static gboolean
|
|
|
|
_serialize_project (GstValidateScenario * scenario, GstValidateAction * action)
|
|
|
|
{
|
|
|
|
const gchar *uri = gst_structure_get_string (action->structure, "uri");
|
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
2014-05-07 23:38:26 +00:00
|
|
|
gboolean res;
|
2014-05-02 14:43:42 +00:00
|
|
|
|
|
|
|
gst_validate_printf (action, "Saving project to %s", uri);
|
|
|
|
|
2014-05-07 23:38:26 +00:00
|
|
|
res = ges_timeline_save_to_uri (timeline, uri, NULL, TRUE, NULL);
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
return res;
|
2014-05-02 14:43:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 23:13:02 +00:00
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_remove_asset (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-07 23:13:02 +00:00
|
|
|
{
|
|
|
|
const gchar *id = NULL;
|
|
|
|
const gchar *type_string = NULL;
|
|
|
|
GType type;
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
|
|
|
GESProject *project = ges_timeline_get_project (timeline);
|
2014-05-07 23:13:02 +00:00
|
|
|
GESAsset *asset;
|
2014-05-07 23:38:26 +00:00
|
|
|
gboolean res = FALSE;
|
2014-05-07 23:13:02 +00:00
|
|
|
|
|
|
|
id = gst_structure_get_string (action->structure, "id");
|
|
|
|
type_string = gst_structure_get_string (action->structure, "type");
|
|
|
|
|
|
|
|
if (!type_string || !id) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("Missing parameters, we got type %s and id %s", type_string, id);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-07 23:13:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!(type = g_type_from_name (type_string))) {
|
|
|
|
GST_ERROR ("This type doesn't exist : %s", type_string);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-07 23:13:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
asset = ges_project_get_asset (project, id, type);
|
2014-05-07 23:13:02 +00:00
|
|
|
|
|
|
|
if (!asset) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("No asset with id %s and type %s", id, type_string);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-07 23:13:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
res = ges_project_remove_asset (project, asset);
|
2014-05-07 23:38:26 +00:00
|
|
|
|
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
return res;
|
2014-05-07 23:13:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-01 15:02:05 +00:00
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_add_asset (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-01 15:02:05 +00:00
|
|
|
{
|
|
|
|
const gchar *id = NULL;
|
|
|
|
const gchar *type_string = NULL;
|
|
|
|
GType type;
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
|
|
|
GESProject *project = ges_timeline_get_project (timeline);
|
2014-05-01 15:02:05 +00:00
|
|
|
GESAsset *asset;
|
|
|
|
GError *error = NULL;
|
2014-05-07 23:38:26 +00:00
|
|
|
gboolean res = FALSE;
|
2014-05-01 15:02:05 +00:00
|
|
|
|
|
|
|
id = gst_structure_get_string (action->structure, "id");
|
|
|
|
type_string = gst_structure_get_string (action->structure, "type");
|
|
|
|
|
|
|
|
if (!type_string || !id) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("Missing parameters, we got type %s and id %s", type_string, id);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-01 15:02:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!(type = g_type_from_name (type_string))) {
|
|
|
|
GST_ERROR ("This type doesn't exist : %s", type_string);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-01 15:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (type == GES_TYPE_URI_CLIP)
|
2014-05-18 16:34:26 +00:00
|
|
|
asset = (GESAsset *) ges_uri_clip_asset_request_sync (id, &error);
|
2014-05-01 15:02:05 +00:00
|
|
|
else
|
2014-05-18 16:34:26 +00:00
|
|
|
asset = ges_asset_request (type, id, &error);
|
2014-05-01 15:02:05 +00:00
|
|
|
|
|
|
|
if (!asset || error) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("There was an error requesting the asset with id %s and type %s",
|
|
|
|
id, type_string);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-01 15:02:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
res = ges_project_add_asset (project, asset);
|
2014-05-07 23:38:26 +00:00
|
|
|
|
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
return res;
|
2014-05-01 15:02:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-02 15:11:24 +00:00
|
|
|
/* Unref after usage */
|
|
|
|
static GESLayer *
|
2014-05-18 16:34:26 +00:00
|
|
|
_get_layer_by_priority (GESTimeline * timeline, gint priority)
|
2014-05-02 11:37:04 +00:00
|
|
|
{
|
|
|
|
GList *layers, *tmp;
|
2014-05-02 15:11:24 +00:00
|
|
|
GESLayer *layer = NULL;
|
2014-05-02 11:37:04 +00:00
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
layers = ges_timeline_get_layers (timeline);
|
2014-05-02 11:37:04 +00:00
|
|
|
for (tmp = layers; tmp; tmp = tmp->next) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GESLayer *tmp_layer = GES_LAYER (tmp->data);
|
2014-05-02 11:37:04 +00:00
|
|
|
guint tmp_priority;
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_get (tmp_layer, "priority", &tmp_priority, NULL);
|
2014-05-02 11:37:04 +00:00
|
|
|
if ((gint) tmp_priority == priority) {
|
2014-05-18 16:34:26 +00:00
|
|
|
layer = gst_object_ref (tmp_layer);
|
2014-05-02 11:37:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
g_list_free_full (layers, gst_object_unref);
|
2014-05-02 15:11:24 +00:00
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
2014-05-07 23:15:42 +00:00
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_add_layer (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-07 23:15:42 +00:00
|
|
|
{
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
2014-05-07 23:15:42 +00:00
|
|
|
GESLayer *layer;
|
|
|
|
gint priority;
|
2014-05-07 23:38:26 +00:00
|
|
|
gboolean res = FALSE;
|
2014-05-07 23:15:42 +00:00
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!gst_structure_get_int (action->structure, "priority", &priority)) {
|
|
|
|
GST_ERROR ("priority is needed when adding a layer");
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-07 23:15:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
layer = _get_layer_by_priority (timeline, priority);
|
2014-05-07 23:15:42 +00:00
|
|
|
|
|
|
|
if (layer != NULL) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR
|
|
|
|
("A layer with priority %d already exists, not creating a new one",
|
|
|
|
priority);
|
|
|
|
gst_object_unref (layer);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-07 23:15:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
layer = ges_layer_new ();
|
|
|
|
g_object_set (layer, "priority", priority, NULL);
|
|
|
|
res = ges_timeline_add_layer (timeline, layer);
|
2014-05-07 23:38:26 +00:00
|
|
|
|
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
return res;
|
2014-05-07 23:15:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-02 15:11:24 +00:00
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_remove_layer (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-02 15:11:24 +00:00
|
|
|
{
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
2014-05-02 15:11:24 +00:00
|
|
|
GESLayer *layer;
|
|
|
|
gint priority;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!gst_structure_get_int (action->structure, "priority", &priority)) {
|
|
|
|
GST_ERROR ("priority is needed when removing a layer");
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
layer = _get_layer_by_priority (timeline, priority);
|
2014-05-02 15:11:24 +00:00
|
|
|
|
2014-05-02 11:37:04 +00:00
|
|
|
if (layer) {
|
2014-05-18 16:34:26 +00:00
|
|
|
res = ges_timeline_remove_layer (timeline, layer);
|
|
|
|
gst_object_unref (layer);
|
2014-05-02 11:37:04 +00:00
|
|
|
} else {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("No layer with priority %d", priority);
|
2014-05-02 11:37:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 23:38:26 +00:00
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-02 15:11:24 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_remove_clip (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-02 15:11:24 +00:00
|
|
|
{
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
2014-05-02 15:11:24 +00:00
|
|
|
GESTimelineElement *clip;
|
|
|
|
GESLayer *layer;
|
|
|
|
const gchar *name;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
|
|
|
name = gst_structure_get_string (action->structure, "name");
|
|
|
|
clip = ges_timeline_get_element (timeline, name);
|
|
|
|
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
|
2014-05-18 16:34:26 +00:00
|
|
|
|
|
|
|
layer = ges_clip_get_layer (GES_CLIP (clip));
|
2014-05-02 15:11:24 +00:00
|
|
|
|
|
|
|
if (layer) {
|
2014-05-18 16:34:26 +00:00
|
|
|
res = ges_layer_remove_clip (layer, GES_CLIP (clip));
|
|
|
|
gst_object_unref (layer);
|
2014-05-02 15:11:24 +00:00
|
|
|
} else {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("No layer for clip %s", ges_timeline_element_get_name (clip));
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-02 15:11:24 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
_add_clip (GstValidateScenario * scenario, GstValidateAction * action)
|
2014-05-02 15:11:24 +00:00
|
|
|
{
|
2014-05-18 16:34:26 +00:00
|
|
|
GESTimeline *timeline = get_timeline (scenario);
|
2014-05-02 15:11:24 +00:00
|
|
|
GESAsset *asset;
|
|
|
|
GESLayer *layer;
|
|
|
|
GESClip *clip;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint layer_priority;
|
|
|
|
const gchar *name;
|
|
|
|
const gchar *asset_id;
|
|
|
|
const gchar *type_string;
|
|
|
|
GType type;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
GstClockTime duration = 1 * GST_SECOND;
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
gst_structure_get_int (action->structure, "layer-priority", &layer_priority);
|
|
|
|
name = gst_structure_get_string (action->structure, "name");
|
|
|
|
asset_id = gst_structure_get_string (action->structure, "asset-id");
|
|
|
|
type_string = gst_structure_get_string (action->structure, "type");
|
2014-05-02 15:11:24 +00:00
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!(type = g_type_from_name (type_string))) {
|
|
|
|
GST_ERROR ("This type doesn't exist : %s", type_string);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
asset = ges_asset_request (type, asset_id, &error);
|
2014-05-02 15:11:24 +00:00
|
|
|
|
|
|
|
if (!asset || error) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR
|
|
|
|
("There was an error requesting the asset with id %s and type %s (%s)",
|
2014-05-02 15:11:24 +00:00
|
|
|
asset_id, type_string, error->message);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
layer = _get_layer_by_priority (timeline, layer_priority);
|
2014-05-02 15:11:24 +00:00
|
|
|
|
|
|
|
if (!layer) {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("No layer with priority %d", layer_priority);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (type == GES_TYPE_URI_CLIP) {
|
|
|
|
duration = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
clip = ges_layer_add_asset (layer, asset, GST_CLOCK_TIME_NONE, 0, duration,
|
2014-05-02 15:11:24 +00:00
|
|
|
GES_TRACK_TYPE_UNKNOWN);
|
|
|
|
|
|
|
|
if (clip) {
|
|
|
|
res = TRUE;
|
2014-05-18 16:34:26 +00:00
|
|
|
if (!ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip), name)) {
|
2014-05-02 15:11:24 +00:00
|
|
|
res = FALSE;
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("couldn't set name %s on clip with id %s", name, asset_id);
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-05-18 16:34:26 +00:00
|
|
|
GST_ERROR ("Couldn't add clip with id %s to layer with priority %d",
|
|
|
|
asset_id, layer_priority);
|
2014-05-02 15:11:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
gst_object_unref (layer);
|
2014-05-02 15:11:24 +00:00
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
ges_timeline_commit (timeline);
|
2014-05-02 15:11:24 +00:00
|
|
|
|
2014-05-07 23:38:26 +00:00
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-02 11:37:04 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-02-18 16:25:05 +00:00
|
|
|
static gboolean
|
|
|
|
_edit_clip (GstValidateScenario * scenario, GstValidateAction * action)
|
|
|
|
{
|
2014-04-25 16:23:06 +00:00
|
|
|
gint64 cpos;
|
|
|
|
gdouble rate;
|
2014-02-18 16:25:05 +00:00
|
|
|
GList *layers = NULL;
|
|
|
|
GESTimeline *timeline;
|
2014-04-25 16:23:06 +00:00
|
|
|
GstQuery *query_segment;
|
2014-02-18 16:25:05 +00:00
|
|
|
GESTimelineElement *clip;
|
2014-04-25 16:23:06 +00:00
|
|
|
GstClockTime position;
|
|
|
|
gint64 stop_value;
|
2014-05-07 23:38:26 +00:00
|
|
|
gboolean res = FALSE;
|
2014-02-18 16:25:05 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2014-04-25 16:23:06 +00:00
|
|
|
timeline = get_timeline (scenario);
|
2014-02-18 16:25:05 +00:00
|
|
|
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");
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-02-18 16:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((edit_mode_str =
|
|
|
|
gst_structure_get_string (action->structure, "edit-mode")))
|
2014-04-25 16:23:06 +00:00
|
|
|
g_return_val_if_fail (gst_validate_utils_enum_from_str (GES_TYPE_EDIT_MODE,
|
|
|
|
edit_mode_str, &mode), FALSE);
|
2014-02-18 16:25:05 +00:00
|
|
|
|
|
|
|
if ((edge_str = gst_structure_get_string (action->structure, "edge")))
|
2014-04-25 16:23:06 +00:00
|
|
|
g_return_val_if_fail (gst_validate_utils_enum_from_str (GES_TYPE_EDGE,
|
|
|
|
edge_str, &edge), FALSE);
|
2014-02-18 16:25:05 +00:00
|
|
|
|
|
|
|
gst_structure_get_int (action->structure, "new-layer-priority",
|
|
|
|
&new_layer_priority);
|
|
|
|
|
2014-04-25 16:23:06 +00:00
|
|
|
gst_validate_printf (action, "Editing %s to %" GST_TIME_FORMAT
|
|
|
|
" in %s mode, edge: %s "
|
2014-02-18 16:25:05 +00:00
|
|
|
"with new layer prio: %d \n\n",
|
|
|
|
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);
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-02-18 16:25:05 +00:00
|
|
|
}
|
|
|
|
gst_object_unref (clip);
|
|
|
|
|
2014-04-25 16:23:06 +00:00
|
|
|
query_segment = gst_query_new_segment (GST_FORMAT_TIME);
|
|
|
|
if (!gst_element_query (scenario->pipeline, query_segment)) {
|
|
|
|
GST_ERROR_OBJECT (scenario, "Could not query segment");
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-04-25 16:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gst_element_query_position (scenario->pipeline, GST_FORMAT_TIME, &cpos)) {
|
|
|
|
GST_ERROR_OBJECT (scenario, "Could not query position");
|
2014-05-07 23:38:26 +00:00
|
|
|
goto beach;
|
2014-04-25 16:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ges_timeline_commit (timeline)) {
|
|
|
|
GST_DEBUG_OBJECT (scenario, "nothing changed, no need to seek");
|
2014-05-07 23:38:26 +00:00
|
|
|
res = TRUE;
|
|
|
|
goto beach;
|
2014-04-25 16:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gst_query_parse_segment (query_segment, &rate, NULL, NULL, &stop_value);
|
|
|
|
|
2014-05-07 23:38:26 +00:00
|
|
|
res = gst_validate_scenario_execute_seek (scenario, action,
|
2014-04-25 16:23:06 +00:00
|
|
|
rate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
|
|
|
GST_SEEK_TYPE_SET, cpos, GST_SEEK_TYPE_SET, stop_value);
|
2014-05-07 23:38:26 +00:00
|
|
|
|
|
|
|
beach:
|
2014-05-18 16:34:26 +00:00
|
|
|
g_object_unref (timeline);
|
2014-05-07 23:38:26 +00:00
|
|
|
return res;
|
2014-02-18 16:25:05 +00:00
|
|
|
}
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
ges_validate_activate (GstPipeline * pipeline, const gchar * scenario,
|
2014-07-27 13:42:42 +00:00
|
|
|
gboolean * needs_setting_state)
|
2013-09-13 21:15:21 +00:00
|
|
|
{
|
|
|
|
GstValidateRunner *runner = NULL;
|
|
|
|
GstValidateMonitor *monitor = NULL;
|
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
const gchar *move_clip_mandatory_fields[] = { "clip-name", "position",
|
|
|
|
NULL
|
|
|
|
};
|
2014-02-18 16:25:05 +00:00
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
const gchar *set_child_property_mandatory_fields[] =
|
|
|
|
{ "element-name", "property", "value", NULL };
|
2014-03-14 11:10:53 +00:00
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
const gchar *serialize_project_mandatory_fields[] = { "uri",
|
|
|
|
NULL
|
|
|
|
};
|
2014-05-02 14:43:42 +00:00
|
|
|
|
2014-05-01 15:02:05 +00:00
|
|
|
const gchar *add_asset_mandatory_fields[] = { "id", "type",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2014-05-07 23:13:02 +00:00
|
|
|
const gchar *remove_asset_mandatory_fields[] = { "id", "type",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2014-05-02 11:37:04 +00:00
|
|
|
const gchar *add_layer_mandatory_fields[] = { "priority",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const gchar *remove_layer_mandatory_fields[] = { "priority",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2014-05-02 15:11:24 +00:00
|
|
|
const gchar *add_clip_mandatory_fields[] = { "name", "layer-priority",
|
|
|
|
"asset-id", "type",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const gchar *remove_clip_mandatory_fields[] = { "name",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
gst_validate_init ();
|
2013-09-13 21:15:21 +00:00
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
if (scenario) {
|
2013-09-13 21:15:21 +00:00
|
|
|
if (g_strcmp0 (scenario, "none")) {
|
|
|
|
gchar *scenario_name = g_strconcat (scenario, "->gespipeline*", NULL);
|
|
|
|
g_setenv ("GST_VALIDATE_SCENARIO", scenario_name, TRUE);
|
|
|
|
g_free (scenario_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
gst_validate_add_action_type ("edit-clip", _edit_clip,
|
|
|
|
move_clip_mandatory_fields, "Allows to seek into the files", FALSE);
|
2014-05-01 15:02:05 +00:00
|
|
|
gst_validate_add_action_type ("add-asset", _add_asset,
|
2014-05-18 16:34:26 +00:00
|
|
|
add_asset_mandatory_fields,
|
|
|
|
"Allows to add an asset to the current project", FALSE);
|
2014-05-07 23:13:02 +00:00
|
|
|
gst_validate_add_action_type ("remove-asset", _remove_asset,
|
2014-05-18 16:34:26 +00:00
|
|
|
remove_asset_mandatory_fields,
|
|
|
|
"Allows to remove an asset from the current project", FALSE);
|
2014-05-02 11:37:04 +00:00
|
|
|
gst_validate_add_action_type ("add-layer", _add_layer,
|
2014-05-18 16:34:26 +00:00
|
|
|
add_layer_mandatory_fields,
|
|
|
|
"Allows to add a layer to the current timeline", FALSE);
|
2014-05-02 11:37:04 +00:00
|
|
|
gst_validate_add_action_type ("remove-layer", _remove_layer,
|
2014-05-18 16:34:26 +00:00
|
|
|
remove_layer_mandatory_fields,
|
|
|
|
"Allows to remove a layer from the current timeline", FALSE);
|
2014-05-02 15:11:24 +00:00
|
|
|
gst_validate_add_action_type ("add-clip", _add_clip,
|
2014-05-18 16:34:26 +00:00
|
|
|
add_clip_mandatory_fields, "Allows to add a clip to a given layer",
|
|
|
|
FALSE);
|
2014-05-02 15:11:24 +00:00
|
|
|
gst_validate_add_action_type ("remove-clip", _remove_clip,
|
2014-05-18 16:34:26 +00:00
|
|
|
remove_clip_mandatory_fields,
|
|
|
|
"Allows to remove a clip from a given layer", FALSE);
|
2014-05-02 14:49:10 +00:00
|
|
|
gst_validate_add_action_type ("serialize-project", _serialize_project,
|
|
|
|
serialize_project_mandatory_fields, "serializes a project", FALSE);
|
|
|
|
|
|
|
|
gst_validate_add_action_type ("set-child-property", _set_child_property,
|
|
|
|
set_child_property_mandatory_fields,
|
|
|
|
"Allows to change child property of an object", FALSE);
|
|
|
|
|
|
|
|
runner = gst_validate_runner_new ();
|
|
|
|
g_signal_connect (runner, "report-added",
|
|
|
|
G_CALLBACK (_validate_report_added_cb), pipeline);
|
|
|
|
monitor =
|
|
|
|
gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner,
|
|
|
|
NULL);
|
|
|
|
|
2014-07-27 13:42:42 +00:00
|
|
|
g_object_get (monitor, "handles-states", needs_setting_state, NULL);
|
|
|
|
*needs_setting_state = !*needs_setting_state;
|
2013-09-13 21:15:21 +00:00
|
|
|
g_object_set_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE, monitor);
|
|
|
|
g_object_set_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE, runner);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
ges_validate_clean (GstPipeline * pipeline)
|
|
|
|
{
|
|
|
|
gint res = 0;
|
|
|
|
GstValidateMonitor *monitor =
|
|
|
|
g_object_get_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE);
|
|
|
|
GstValidateRunner *runner =
|
|
|
|
g_object_get_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE);
|
|
|
|
|
|
|
|
if (runner)
|
|
|
|
res = gst_validate_runner_printf (runner);
|
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
if (runner) {
|
|
|
|
gst_object_unref (runner);
|
|
|
|
if (monitor)
|
|
|
|
gst_object_unref (monitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
void
|
|
|
|
ges_validate_handle_request_state_change (GstMessage * message,
|
|
|
|
GMainLoop * mainloop)
|
|
|
|
{
|
|
|
|
GstState state;
|
|
|
|
|
|
|
|
gst_message_parse_request_state (message, &state);
|
|
|
|
|
|
|
|
if (GST_IS_VALIDATE_SCENARIO (GST_MESSAGE_SRC (message))
|
|
|
|
&& state == GST_STATE_NULL) {
|
|
|
|
gst_validate_printf (GST_MESSAGE_SRC (message),
|
|
|
|
"State change request NULL, " "quiting mainloop\n");
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
#else
|
2014-04-23 09:28:20 +00:00
|
|
|
static gboolean
|
|
|
|
_print_position (GstElement * pipeline)
|
|
|
|
{
|
|
|
|
gint64 position, duration;
|
|
|
|
|
|
|
|
if (pipeline) {
|
|
|
|
gst_element_query_position (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
|
|
&position);
|
|
|
|
gst_element_query_duration (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
|
|
&duration);
|
|
|
|
|
|
|
|
g_print ("<position: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
|
|
|
"/>\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
gboolean
|
2014-05-18 16:34:26 +00:00
|
|
|
ges_validate_activate (GstPipeline * pipeline, const gchar * scenario,
|
2014-07-27 13:42:42 +00:00
|
|
|
gboolean * needs_setting_state)
|
2013-09-13 21:15:21 +00:00
|
|
|
{
|
2014-04-23 09:28:20 +00:00
|
|
|
if (scenario) {
|
2013-09-13 21:15:21 +00:00
|
|
|
GST_WARNING ("Trying to run scenario %s, but gst-validate not supported",
|
|
|
|
scenario);
|
|
|
|
|
2014-04-23 09:28:20 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (pipeline), "pposition-id",
|
|
|
|
GUINT_TO_POINTER (g_timeout_add (200,
|
|
|
|
(GSourceFunc) _print_position, pipeline)));
|
|
|
|
|
2014-07-27 13:42:42 +00:00
|
|
|
*needs_setting_state = TRUE;
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
ges_validate_clean (GstPipeline * pipeline)
|
|
|
|
{
|
2014-04-23 09:28:20 +00:00
|
|
|
g_source_remove (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pipeline),
|
|
|
|
"pposition-id")));
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
gst_object_unref (pipeline);
|
2014-04-23 09:28:20 +00:00
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
void
|
|
|
|
ges_validate_handle_request_state_change (GstMessage * message,
|
|
|
|
GMainLoop * mainloop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
#endif
|