mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
gst-qa-override-registry: load overrides dynamically
Shared objects listed in GST_QA_OVERRIDE are loaded on startup, and the symbol gst_qa_create_overrides is run. It should create any override needed. While it can do anything it wants, this is discouraged. GST_QA_OVERRIDE should be a comma separated list of shared objects, any relative paths should be from the current working directory at the time they are loaded (ie, if the process to be traced changes cwd, use absolute paths). No attempt whatsoever is made at not running what was not meant. Includes a sample shared object for illustration purposes.
This commit is contained in:
parent
09fda8bbd2
commit
7fedf5a111
5 changed files with 111 additions and 1 deletions
|
@ -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)
|
||||
|
|
42
validate/gst/qa/gst-qa-default-overrides.c
Normal file
42
validate/gst/qa/gst-qa-default-overrides.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2013 Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#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;
|
||||
}
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#define __USE_GNU
|
||||
#include <dlfcn.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue