diff --git a/validate/gst/qa/Makefile.am b/validate/gst/qa/Makefile.am index 68cb1137ae..3815dd9028 100644 --- a/validate/gst/qa/Makefile.am +++ b/validate/gst/qa/Makefile.am @@ -19,7 +19,8 @@ noinst_HEADERS = gst-qa-i18n-lib.h lib_LTLIBRARIES = \ - libgstqa-@GST_API_VERSION@.la + libgstqa-@GST_API_VERSION@.la \ + libgstqa-default-overrides-@GST_API_VERSION@.la libgstqa_@GST_API_VERSION@_la_SOURCES = \ $(c_sources) @@ -34,6 +35,19 @@ libgstqa_@GST_API_VERSION@_la_LIBADD = \ libgstqa_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/qa libgstqa_@GST_API_VERSION@include_HEADERS = $(public_headers) +libgstqa_default_overrides_@GST_API_VERSION@_la_SOURCES = \ + gst-qa-default-overrides.c + +libgstqa_default_overrides_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) +libgstqa_default_overrides_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) \ + $(GST_LT_LDFLAGS) $(GIO_LDFLAGS) +libgstqa_default_overrides_@GST_API_VERSION@_la_LIBADD = \ + $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \ + $(GST_LIBS) $(GIO_LIBS) + +libgstqa_default_overrides_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/qa +libgstqa_default_overrides_@GST_API_VERSION@include_HEADERS = + bin_PROGRAMS = gst-qa-@GST_API_VERSION@ gst-qa-transcoding-@GST_API_VERSION@ AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) LDADD = $(top_builddir)/gst/qa/libgstqa-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) diff --git a/validate/gst/qa/gst-qa-default-overrides.c b/validate/gst/qa/gst-qa-default-overrides.c new file mode 100644 index 0000000000..eafb9e7e7b --- /dev/null +++ b/validate/gst/qa/gst-qa-default-overrides.c @@ -0,0 +1,42 @@ +/* GStreamer + * Copyright (C) 2013 Vincent Penquerc'h + * + * gst-qa-default-overrides.c - Test overrides + * + * 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.1 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 +#include "gst-qa-override.h" +#include "gst-qa-override-registry.h" +#include "gst-qa-report.h" + +int +gst_qa_create_overrides (void) +{ + GstQaOverride *o; + + /* Some random test override. Will moan on: + gst-launch videotestsrc num-buffers=10 ! video/x-raw-yuv ! fakesink */ + o = gst_qa_override_new (); + gst_qa_override_change_severity (o, GST_QA_ISSUE_ID_CAPS_IS_MISSING_FIELD, + GST_QA_REPORT_LEVEL_CRITICAL); + gst_qa_override_register_by_name ("capsfilter0", o); + return 1; +} diff --git a/validate/gst/qa/gst-qa-override-registry.c b/validate/gst/qa/gst-qa-override-registry.c index 8c13188482..3d029b09bf 100644 --- a/validate/gst/qa/gst-qa-override-registry.c +++ b/validate/gst/qa/gst-qa-override-registry.c @@ -21,6 +21,9 @@ #include +#define __USE_GNU +#include + #include "gst-qa-override-registry.h" typedef struct @@ -41,6 +44,8 @@ static GstQaOverrideRegistry *_registry_default; #define GST_QA_OVERRIDE_REGISTRY_LOCK(r) g_mutex_lock (&r->mutex) #define GST_QA_OVERRIDE_REGISTRY_UNLOCK(r) g_mutex_unlock (&r->mutex) +#define GST_QA_OVERRIDE_INIT_SYMBOL "gst_qa_create_overrides" + static GstQaOverrideRegistry * gst_qa_override_registry_new (void) { @@ -181,3 +186,46 @@ gst_qa_override_registry_attach_overrides (GstQaMonitor * monitor) gst_qa_override_registry_attach_klass_overrides_unlocked (reg, monitor); GST_QA_OVERRIDE_REGISTRY_UNLOCK (reg); } + +int +gst_qa_override_registry_preload (void) +{ + gchar **solist, *const *so; + const char *sos, *soerr; + void *sol; + int ret, (*entry) (void), nloaded = 0; + + sos = g_getenv ("GST_QA_OVERRIDE"); + if (!sos) { + GST_INFO ("No GST_QA_OVERRIDE found, no overrides to load"); + return 0; + } + solist = g_strsplit (sos, ",", 0); + for (so = solist; *so; ++so) { + GST_INFO ("Loading overrides from %s", *so); + sol = dlopen (*so, RTLD_LAZY); + if (!sol) { + soerr = dlerror (); + GST_ERROR ("Failed to load %s %s", *so, soerr ? soerr : "no idea why"); + continue; + } + entry = dlsym (sol, GST_QA_OVERRIDE_INIT_SYMBOL); + if (entry) { + ret = (*entry) (); + if (ret > 0) { + GST_INFO ("Loaded %d overrides from %s", ret, *so); + nloaded += ret; + } else if (ret < 0) { + GST_WARNING ("Error loading overrides from %s", *so); + } else { + GST_INFO ("Loaded no overrides from %s", *so); + } + } else { + GST_WARNING (GST_QA_OVERRIDE_INIT_SYMBOL " not found in %s", *so); + } + dlclose (sol); + } + g_strfreev (solist); + GST_INFO ("%d overrides loaded", nloaded); + return nloaded; +} diff --git a/validate/gst/qa/gst-qa-override-registry.h b/validate/gst/qa/gst-qa-override-registry.h index 6401ff3ef1..f4911fd816 100644 --- a/validate/gst/qa/gst-qa-override-registry.h +++ b/validate/gst/qa/gst-qa-override-registry.h @@ -46,6 +46,8 @@ void gst_qa_override_register_by_klass (const gchar * klass, GstQaOverride * ove void gst_qa_override_registry_attach_overrides (GstQaMonitor * monitor); +int gst_qa_override_registry_preload (void); + G_END_DECLS #endif /* __GST_QA_OVERRIDE_REGISTRY_H__ */ diff --git a/validate/gst/qa/gst-qa-runner.c b/validate/gst/qa/gst-qa-runner.c index 377164a144..ed995e02b7 100644 --- a/validate/gst/qa/gst-qa-runner.c +++ b/validate/gst/qa/gst-qa-runner.c @@ -23,6 +23,7 @@ #include "gst-qa-report.h" #include "gst-qa-monitor-factory.h" #include "gst-qa-element-monitor.h" +#include "gst-qa-override-registry.h" #include "gst-qa-scenario.h" /** @@ -80,6 +81,9 @@ gst_qa_runner_class_init (GstQaRunnerClass * klass) /* init the report system (can be called multiple times) */ gst_qa_report_init (); + /* Ensure we load overrides before any use of a monitor */ + gst_qa_override_registry_preload (); + _signals[REPORT_ADDED_SIGNAL] = g_signal_new ("report-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,