ges-launch: Play nicely with gst-validate if avalaible

This commit is contained in:
Thibault Saunier 2013-09-13 18:15:21 -03:00 committed by Thibault Saunier
parent 98e1977633
commit 95126cd0ef
5 changed files with 186 additions and 6 deletions

View file

@ -148,6 +148,19 @@ PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQ,
AM_CONDITIONAL(WITH_PYTHON, [test "x$HAVE_PYGOBJECT" = "xyes"])
dnl check for pygobject
PKG_CHECK_MODULES(GST_VALIDATE, gst-validate-1.0 >= 0.0.1.0,
[
HAVE_GST_VALIDATE=yes
AC_DEFINE(HAVE_GST_VALIDATE, 1, [Define if build with gst-validate support])
], HAVE_GST_VALIDATE=no)
AC_SUBST(GST_VALIDATE_CFLAGS)
AC_SUBST(GST_VALIDATE_LIBS)
AM_CONDITIONAL(HAVE_GST_VALIDATE, [test "x$HAVE_GST_VALIDATE" = "xyes"])
dnl *** checks for libraries ***
dnl check for libm, for sin() etc.

View file

@ -1,8 +1,11 @@
bin_PROGRAMS = ges-launch-@GST_API_VERSION@
AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS)
LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GIO_LIBS)
ges_launch_@GST_API_VERSION@_SOURCES = ges-launch.c
AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) $(GST_VALIDATE_CFLAGS)
LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GIO_LIBS) $(GST_VALIDATE_LIBS)
noinst_HEADERS = ges-validate.h
ges_launch_@GST_API_VERSION@_SOURCES = ges-validate.c ges-launch.c
Android.mk: Makefile.am $(BUILT_SOURCES)
androgenizer \

View file

@ -30,6 +30,7 @@
#include <gst/pbutils/encoding-profile.h>
#include <locale.h> /* for LC_ALL */
#include "ges-validate.h"
/* GLOBAL VARIABLE */
static guint repeat = 0;
@ -41,6 +42,7 @@ static gchar **new_paths = NULL;
static GMainLoop *mainloop;
static GHashTable *tried_uris;
static GESTrackType track_types = GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO;
static GESTimeline *timeline;
static gchar *
ensure_uri (gchar * location)
@ -450,7 +452,7 @@ bus_message_cb (GstBus * bus, GstMessage * message, GMainLoop * mainloop)
g_printerr ("Looping set\n");
repeat -= 1;
} else {
g_printerr ("Done\n");
g_printerr ("\nDone\n");
g_main_loop_quit (mainloop);
}
break;
@ -661,6 +663,7 @@ main (int argc, gchar ** argv)
static gdouble thumbinterval = 0;
static gboolean verbose = FALSE;
gchar *load_path = NULL;
const gchar *scenario = NULL;
GOptionEntry options[] = {
{"thumbnail", 'm', 0.0, G_OPTION_ARG_DOUBLE, &thumbinterval,
"Take thumbnails every n seconds (saved in current directory)", "N"},
@ -697,11 +700,14 @@ main (int argc, gchar ** argv)
"Defines the track types to be created"},
{"mute", 0, 0, G_OPTION_ARG_NONE, &mute,
"Mute playback output, which means that we use faksinks"},
{"set-scenario", 0, 0, G_OPTION_ARG_STRING, &scenario,
"Specify a GstValidate scenario to run, 'none' means load gst-validate"
" but run no scenario on it", "<scenario_name>"},
{NULL}
};
GOptionContext *ctx;
GstBus *bus;
GESTimeline *timeline;
setlocale (LC_ALL, "");
@ -762,6 +768,11 @@ main (int argc, gchar ** argv)
if (!pipeline)
exit (1);
if (ges_validate_activate (GST_PIPELINE (pipeline), scenario) == FALSE) {
g_error ("Could not activate scenario %s", scenario);
return 1;
}
/* Setup profile/encoding if needed */
if (smartrender || outputuri) {
GstEncodingProfile *prof = NULL;
@ -827,8 +838,11 @@ main (int argc, gchar ** argv)
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
gst_object_unref (pipeline);
validate_res = ges_validate_clean (GST_PIPELINE (pipeline));
if (seenerrors == FALSE)
seenerrors = validate_res;
g_hash_table_unref (tried_uris);
return (int) seenerrors;
}

114
tools/ges-validate.c Normal file
View file

@ -0,0 +1,114 @@
/* 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"
#ifdef HAVE_GST_VALIDATE
#include <gst/validate/gst-validate-scenario.h>
#include <gst/validate/validate.h>
#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");
}
}
gboolean
ges_validate_activate (GstPipeline * pipeline, const gchar * scenario)
{
GstValidateRunner *runner = NULL;
GstValidateMonitor *monitor = NULL;
if (scenario) {
gst_validate_init ();
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);
}
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);
}
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;
}
#else
gboolean
ges_validate_activate (GstPipeline * pipeline, const gchar * scenario)
{
if (scenario)
GST_WARNING ("Trying to run scenario %s, but gst-validate not supported",
scenario);
return TRUE;
}
gint
ges_validate_clean (GstPipeline * pipeline)
{
gst_object_unref (pipeline);
return 0;
}
#endif

36
tools/ges-validate.h Normal file
View file

@ -0,0 +1,36 @@
/* 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.
*/
#ifndef _GES_VALIDATE_
#define _GES_VALIDATE_
#include <glib.h>
#include <gst/gst.h>
G_BEGIN_DECLS
gboolean
ges_validate_activate (GstPipeline *pipeline, const gchar *scenario);
gint
ges_validate_clean (GstPipeline *pipeline);
G_END_DECLS
#endif /* _GES_VALIDATE */