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
|
|
|
|
|
2019-06-28 21:35:40 +00:00
|
|
|
#include "utils.h"
|
2013-09-13 21:15:21 +00:00
|
|
|
#include "ges-validate.h"
|
2016-07-26 18:05:06 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
2013-09-13 21:15:21 +00:00
|
|
|
|
2020-07-08 12:02:27 +00:00
|
|
|
static gboolean
|
|
|
|
_print_position (GstElement * pipeline)
|
|
|
|
{
|
|
|
|
gint64 position = 0, duration = -1;
|
|
|
|
|
|
|
|
if (pipeline) {
|
|
|
|
gst_element_query_position (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
|
|
&position);
|
|
|
|
gst_element_query_duration (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
|
|
&duration);
|
|
|
|
|
2021-04-27 15:57:35 +00:00
|
|
|
gst_print ("<position: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
2020-07-08 12:02:27 +00:00
|
|
|
"/>\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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>
|
2016-07-26 18:05:06 +00:00
|
|
|
#include <gst/validate/gst-validate-element-monitor.h>
|
2019-06-28 21:35:40 +00:00
|
|
|
#include <gst/validate/gst-validate-bin-monitor.h>
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
#define MONITOR_ON_PIPELINE "validate-monitor"
|
|
|
|
#define RUNNER_ON_PIPELINE "runner-monitor"
|
2016-07-26 18:05:06 +00:00
|
|
|
#define WRONG_DECODER_ADDED g_quark_from_static_string ("ges::wrong-decoder-added")
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 18:05:06 +00:00
|
|
|
static void
|
|
|
|
bin_element_added (GstTracer * runner, GstClockTime ts,
|
|
|
|
GstBin * bin, GstElement * element, gboolean result)
|
|
|
|
{
|
|
|
|
GstObject *parent;
|
|
|
|
GstValidateElementMonitor *monitor =
|
|
|
|
g_object_get_data (G_OBJECT (element), "validate-monitor");
|
|
|
|
|
|
|
|
if (!monitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!monitor->is_decoder)
|
|
|
|
return;
|
|
|
|
|
|
|
|
parent = gst_object_get_parent (GST_OBJECT (element));
|
|
|
|
do {
|
|
|
|
if (GES_IS_TRACK (parent)) {
|
|
|
|
GstElementClass *klass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
|
|
|
|
const gchar *klassname =
|
|
|
|
gst_element_class_get_metadata (klass, GST_ELEMENT_METADATA_KLASS);
|
|
|
|
|
|
|
|
if (GES_IS_AUDIO_TRACK (parent) && strstr (klassname, "Audio") == NULL) {
|
|
|
|
GST_VALIDATE_REPORT (monitor, WRONG_DECODER_ADDED,
|
|
|
|
"Adding non audio decoder %s in audio track %s.",
|
|
|
|
GST_OBJECT_NAME (element), GST_OBJECT_NAME (parent));
|
|
|
|
} else if (GES_IS_VIDEO_TRACK (parent)
|
|
|
|
&& strstr (klassname, "Video") == NULL
|
|
|
|
&& strstr (klassname, "Image") == NULL) {
|
|
|
|
GST_VALIDATE_REPORT (monitor, WRONG_DECODER_ADDED,
|
|
|
|
"Adding non video decoder %s in video track %s.",
|
|
|
|
GST_OBJECT_NAME (element), GST_OBJECT_NAME (parent));
|
|
|
|
|
|
|
|
}
|
|
|
|
gst_object_unref (parent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (parent);
|
|
|
|
parent = gst_object_get_parent (parent);
|
|
|
|
} while (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_validate_register_issues (void)
|
|
|
|
{
|
|
|
|
gst_validate_issue_register (gst_validate_issue_new (WRONG_DECODER_ADDED,
|
|
|
|
"Wrong decoder type added to track.",
|
|
|
|
"In a specific track type we should never create decoders"
|
|
|
|
" for some other types (No audio decoder should be added"
|
|
|
|
" in a Video track).", GST_VALIDATE_REPORT_LEVEL_CRITICAL));
|
|
|
|
}
|
|
|
|
|
2014-08-22 19:01:07 +00:00
|
|
|
gboolean
|
2020-02-24 11:50:04 +00:00
|
|
|
ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
|
|
|
|
GESLauncherParsedOptions * opts)
|
2014-08-22 19:01:07 +00:00
|
|
|
{
|
|
|
|
GstValidateRunner *runner = NULL;
|
|
|
|
GstValidateMonitor *monitor = NULL;
|
|
|
|
|
2021-08-10 21:10:43 +00:00
|
|
|
if (!opts->enable_validate) {
|
2020-03-10 19:10:12 +00:00
|
|
|
opts->needs_set_state = TRUE;
|
2020-07-08 12:02:27 +00:00
|
|
|
g_object_set_data (G_OBJECT (pipeline), "pposition-id",
|
|
|
|
GUINT_TO_POINTER (g_timeout_add (200,
|
|
|
|
(GSourceFunc) _print_position, pipeline)));
|
2020-03-10 19:10:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-04-24 21:15:16 +00:00
|
|
|
gst_validate_init_debug ();
|
2013-09-13 21:15:21 +00:00
|
|
|
|
2020-04-24 21:15:16 +00:00
|
|
|
if (opts->testfile) {
|
|
|
|
if (opts->scenario)
|
|
|
|
g_error ("Can not specify scenario and testfile at the same time");
|
|
|
|
gst_validate_setup_test_file (opts->testfile, opts->mute);
|
|
|
|
} else if (opts->scenario) {
|
2020-02-04 20:07:39 +00:00
|
|
|
if (g_strcmp0 (opts->scenario, "none")) {
|
|
|
|
gchar *scenario_name =
|
|
|
|
g_strconcat (opts->scenario, "->gespipeline*", NULL);
|
2013-09-13 21:15:21 +00:00
|
|
|
g_setenv ("GST_VALIDATE_SCENARIO", scenario_name, TRUE);
|
|
|
|
g_free (scenario_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 21:15:16 +00:00
|
|
|
ges_validate_register_action_types ();
|
|
|
|
ges_validate_register_issues ();
|
|
|
|
|
2014-05-02 14:49:10 +00:00
|
|
|
runner = gst_validate_runner_new ();
|
2016-07-26 18:05:06 +00:00
|
|
|
gst_tracing_register_hook (GST_TRACER (runner), "bin-add-post",
|
|
|
|
G_CALLBACK (bin_element_added));
|
2014-05-02 14:49:10 +00:00
|
|
|
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);
|
2019-06-28 21:35:40 +00:00
|
|
|
if (GST_VALIDATE_BIN_MONITOR (monitor)->scenario) {
|
|
|
|
GstStructure *metas =
|
|
|
|
GST_VALIDATE_BIN_MONITOR (monitor)->scenario->description;
|
|
|
|
|
|
|
|
if (metas) {
|
2020-02-04 20:07:39 +00:00
|
|
|
gchar **ges_options = gst_validate_utils_get_strv (metas, "ges-options");
|
2020-04-24 21:15:16 +00:00
|
|
|
if (!ges_options)
|
|
|
|
ges_options = gst_validate_utils_get_strv (metas, "args");
|
2020-02-04 20:07:39 +00:00
|
|
|
|
2020-04-21 20:22:31 +00:00
|
|
|
gst_structure_get_boolean (metas, "ignore-eos", &opts->ignore_eos);
|
2020-02-04 20:07:39 +00:00
|
|
|
if (ges_options) {
|
|
|
|
gint i;
|
|
|
|
gchar **ges_options_full =
|
|
|
|
g_new0 (gchar *, g_strv_length (ges_options) + 2);
|
|
|
|
|
|
|
|
ges_options_full[0] = g_strdup ("something");
|
|
|
|
for (i = 0; ges_options[i]; i++)
|
2020-02-20 20:13:46 +00:00
|
|
|
ges_options_full[i + 1] = g_strdup (ges_options[i]);
|
2020-02-04 20:07:39 +00:00
|
|
|
|
2020-02-24 11:50:04 +00:00
|
|
|
ges_launcher_parse_options (launcher, &ges_options_full, NULL, NULL,
|
|
|
|
NULL);
|
2021-01-15 18:26:36 +00:00
|
|
|
opts->sanitized_timeline =
|
|
|
|
sanitize_timeline_description (ges_options_full, opts);
|
2020-02-04 20:07:39 +00:00
|
|
|
g_strfreev (ges_options_full);
|
2020-02-20 20:13:46 +00:00
|
|
|
g_strfreev (ges_options);
|
2019-06-28 21:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-02 14:49:10 +00:00
|
|
|
|
2014-08-08 08:41:48 +00:00
|
|
|
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
|
|
|
|
|
2020-02-04 20:07:39 +00:00
|
|
|
g_object_get (monitor, "handles-states", &opts->needs_set_state, NULL);
|
|
|
|
opts->needs_set_state = !opts->needs_set_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)
|
2015-06-03 12:56:11 +00:00
|
|
|
res = gst_validate_runner_exit (runner, TRUE);
|
2020-07-08 12:02:27 +00:00
|
|
|
else
|
|
|
|
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);
|
2020-03-09 18:38:58 +00:00
|
|
|
if (runner)
|
2013-09-13 21:15:21 +00:00
|
|
|
gst_object_unref (runner);
|
2020-03-09 18:38:58 +00:00
|
|
|
if (monitor)
|
|
|
|
gst_object_unref (monitor);
|
2013-09-13 21:15:21 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:34:26 +00:00
|
|
|
void
|
|
|
|
ges_validate_handle_request_state_change (GstMessage * message,
|
2015-03-24 13:13:54 +00:00
|
|
|
GApplication * application)
|
2014-05-18 16:34:26 +00:00
|
|
|
{
|
|
|
|
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),
|
2020-02-04 20:07:39 +00:00
|
|
|
"State change request NULL, " "quitting application\n");
|
2015-06-03 12:56:11 +00:00
|
|
|
g_application_quit (application);
|
2014-05-18 16:34:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-22 19:01:07 +00:00
|
|
|
gint
|
2014-09-05 21:14:10 +00:00
|
|
|
ges_validate_print_action_types (const gchar ** types, gint num_types)
|
2014-08-22 19:01:07 +00:00
|
|
|
{
|
|
|
|
ges_validate_register_action_types ();
|
|
|
|
|
|
|
|
if (!gst_validate_print_action_types (types, num_types)) {
|
|
|
|
GST_ERROR ("Could not print all wanted types");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
#else
|
|
|
|
gboolean
|
2020-02-24 11:50:04 +00:00
|
|
|
ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
|
|
|
|
GESLauncherParsedOptions * opts)
|
2013-09-13 21:15:21 +00:00
|
|
|
{
|
2020-04-24 21:15:16 +00:00
|
|
|
if (opts->testfile) {
|
|
|
|
GST_WARNING ("Trying to run testfile %s, but gst-validate not supported",
|
|
|
|
opts->testfile);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-04 20:07:39 +00:00
|
|
|
if (opts->scenario) {
|
2013-09-13 21:15:21 +00:00
|
|
|
GST_WARNING ("Trying to run scenario %s, but gst-validate not supported",
|
2020-02-04 20:07:39 +00:00
|
|
|
opts->scenario);
|
2013-09-13 21:15:21 +00:00
|
|
|
|
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)));
|
|
|
|
|
2020-02-04 20:07:39 +00:00
|
|
|
opts->needs_set_state = TRUE;
|
2014-07-27 13:42:42 +00:00
|
|
|
|
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,
|
2015-03-24 13:13:54 +00:00
|
|
|
GApplication * application)
|
2014-05-18 16:34:26 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-22 19:01:07 +00:00
|
|
|
gint
|
|
|
|
ges_validate_print_action_types (const gchar ** types, gint num_types)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
#endif
|