mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
qa-runner: simplify runner to not hold refs to monitor/pipeline
The GstQaRunner is now a simple aggregator of reports that it receives from monitors and filechecker. This allows it to be used in both scenarios without APIs that expect GstElement or Monitors, that are only used on the pipeline monitoring QA tests.
This commit is contained in:
parent
61d39d6e74
commit
08aae8336b
8 changed files with 28 additions and 71 deletions
|
@ -22,10 +22,13 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gst-qa-runner.h"
|
#include "gst-qa-runner.h"
|
||||||
|
#include "gst-qa-monitor-factory.h"
|
||||||
|
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
static GstQaRunner *runner = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions that wrap object creation so gst-qa can be used
|
* Functions that wrap object creation so gst-qa can be used
|
||||||
* to monitor 'standard' applications
|
* to monitor 'standard' applications
|
||||||
|
@ -34,15 +37,11 @@
|
||||||
static void
|
static void
|
||||||
gst_qa_preload_wrap (GstElement * element)
|
gst_qa_preload_wrap (GstElement * element)
|
||||||
{
|
{
|
||||||
GstQaRunner *runner;
|
if (runner == NULL)
|
||||||
|
runner = gst_qa_runner_new ();
|
||||||
|
|
||||||
runner = gst_qa_runner_new (element);
|
/* the reference to the monitor is lost */
|
||||||
|
gst_qa_monitor_factory_create (GST_OBJECT_CAST (element), runner, NULL);
|
||||||
/* TODO this will actually never unref the runner as it holds a ref
|
|
||||||
* to the element */
|
|
||||||
if (runner)
|
|
||||||
g_object_set_data_full ((GObject *) element, "qa-runner", runner,
|
|
||||||
g_object_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstElement *
|
GstElement *
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "gst-qa-runner.h"
|
#include "gst-qa-runner.h"
|
||||||
#include "gst-qa-report.h"
|
#include "gst-qa-report.h"
|
||||||
#include "gst-qa-monitor-factory.h"
|
#include "gst-qa-monitor-factory.h"
|
||||||
#include "gst-qa-element-monitor.h"
|
|
||||||
#include "gst-qa-override-registry.h"
|
#include "gst-qa-override-registry.h"
|
||||||
#include "gst-qa-scenario.h"
|
#include "gst-qa-scenario.h"
|
||||||
|
|
||||||
|
@ -51,20 +50,13 @@ enum
|
||||||
|
|
||||||
static guint _signals[LAST_SIGNAL] = { 0 };
|
static guint _signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static gboolean gst_qa_runner_setup (GstQaRunner * runner);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_qa_runner_dispose (GObject * object)
|
gst_qa_runner_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstQaRunner *runner = GST_QA_RUNNER_CAST (object);
|
GstQaRunner *runner = GST_QA_RUNNER_CAST (object);
|
||||||
if (runner->pipeline)
|
|
||||||
gst_object_unref (runner->pipeline);
|
|
||||||
|
|
||||||
g_slist_free_full (runner->reports, (GDestroyNotify) gst_qa_report_unref);
|
g_slist_free_full (runner->reports, (GDestroyNotify) gst_qa_report_unref);
|
||||||
|
|
||||||
if (runner->monitor)
|
|
||||||
g_object_unref (runner->monitor);
|
|
||||||
|
|
||||||
if (runner->scenario)
|
if (runner->scenario)
|
||||||
g_object_unref (runner->scenario);
|
g_object_unref (runner->scenario);
|
||||||
|
|
||||||
|
@ -100,54 +92,11 @@ gst_qa_runner_init (GstQaRunner * runner)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_qa_runner_new:
|
* gst_qa_runner_new:
|
||||||
* @pipeline: (transfer-none): a #GstElement to run QA on
|
|
||||||
*/
|
*/
|
||||||
GstQaRunner *
|
GstQaRunner *
|
||||||
gst_qa_runner_new (GstElement * pipeline)
|
gst_qa_runner_new (void)
|
||||||
{
|
{
|
||||||
const gchar *scenario_name;
|
return g_object_new (GST_TYPE_QA_RUNNER, NULL);
|
||||||
GstQaRunner *runner;
|
|
||||||
|
|
||||||
g_return_val_if_fail (pipeline != NULL, NULL);
|
|
||||||
|
|
||||||
runner = g_object_get_data ((GObject *) pipeline, "qa-runner");
|
|
||||||
if (runner) {
|
|
||||||
GST_WARNING_OBJECT (pipeline,
|
|
||||||
"Pipeline already has a qa-runner associated, returning it");
|
|
||||||
|
|
||||||
return gst_object_ref (runner);
|
|
||||||
}
|
|
||||||
|
|
||||||
runner = g_object_new (GST_TYPE_QA_RUNNER, NULL);
|
|
||||||
runner->pipeline = gst_object_ref (pipeline);
|
|
||||||
|
|
||||||
if ((scenario_name = g_getenv ("GST_QA_SCENARIO")))
|
|
||||||
runner->scenario = gst_qa_scenario_factory_create (runner, scenario_name);
|
|
||||||
|
|
||||||
g_object_set_data ((GObject *) pipeline, "qa-runner", runner);
|
|
||||||
|
|
||||||
if (!gst_qa_runner_setup (runner)) {
|
|
||||||
gst_object_unref (runner);
|
|
||||||
runner = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return runner;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_qa_runner_setup (GstQaRunner * runner)
|
|
||||||
{
|
|
||||||
GST_INFO_OBJECT (runner, "Starting QA Runner setup");
|
|
||||||
runner->monitor =
|
|
||||||
gst_qa_monitor_factory_create (GST_OBJECT_CAST (runner->pipeline), runner,
|
|
||||||
NULL);
|
|
||||||
if (runner->monitor == NULL) {
|
|
||||||
GST_WARNING_OBJECT (runner, "Setup failed");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (runner, "Setup successful");
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -161,6 +110,7 @@ gst_qa_runner_add_report (GstQaRunner * runner, GstQaReport * report)
|
||||||
guint
|
guint
|
||||||
gst_qa_runner_get_reports_count (GstQaRunner * runner)
|
gst_qa_runner_get_reports_count (GstQaRunner * runner)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (runner != NULL, 0);
|
||||||
return g_slist_length (runner->reports);
|
return g_slist_length (runner->reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
typedef struct _GstQaMonitor GstQaMonitor;
|
|
||||||
typedef struct _GstQaScenario GstQaScenario;
|
typedef struct _GstQaScenario GstQaScenario;
|
||||||
|
|
||||||
#define GST_TYPE_QA_RUNNER (gst_qa_runner_get_type ())
|
#define GST_TYPE_QA_RUNNER (gst_qa_runner_get_type ())
|
||||||
|
@ -59,8 +58,6 @@ struct _GstQaRunner {
|
||||||
gboolean setup;
|
gboolean setup;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstElement *pipeline;
|
|
||||||
GstQaMonitor *monitor;
|
|
||||||
GstQaScenario *scenario;
|
GstQaScenario *scenario;
|
||||||
|
|
||||||
GSList *reports;
|
GSList *reports;
|
||||||
|
@ -79,7 +76,7 @@ struct _GstQaRunnerClass {
|
||||||
/* normal GObject stuff */
|
/* normal GObject stuff */
|
||||||
GType gst_qa_runner_get_type (void);
|
GType gst_qa_runner_get_type (void);
|
||||||
|
|
||||||
GstQaRunner * gst_qa_runner_new (GstElement * pipeline);
|
GstQaRunner * gst_qa_runner_new (void);
|
||||||
|
|
||||||
void gst_qa_runner_add_report (GstQaRunner * runner, GstQaReport * report);
|
void gst_qa_runner_add_report (GstQaRunner * runner, GstQaReport * report);
|
||||||
|
|
||||||
|
|
|
@ -695,7 +695,7 @@ gst_qa_scenario_finalize (GObject * object)
|
||||||
}
|
}
|
||||||
|
|
||||||
GstQaScenario *
|
GstQaScenario *
|
||||||
gst_qa_scenario_factory_create (GstQaRunner * runner,
|
gst_qa_scenario_factory_create (GstQaRunner * runner, GstElement * pipeline,
|
||||||
const gchar * scenario_name)
|
const gchar * scenario_name)
|
||||||
{
|
{
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
@ -709,11 +709,11 @@ gst_qa_scenario_factory_create (GstQaRunner * runner,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
scenario->priv->pipeline = gst_object_ref (runner->pipeline);
|
scenario->priv->pipeline = gst_object_ref (pipeline);
|
||||||
gst_qa_reporter_set_name (GST_QA_REPORTER (scenario),
|
gst_qa_reporter_set_name (GST_QA_REPORTER (scenario),
|
||||||
g_strdup (scenario_name));
|
g_strdup (scenario_name));
|
||||||
|
|
||||||
bus = gst_element_get_bus (runner->pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
gst_bus_add_signal_watch (bus);
|
gst_bus_add_signal_watch (bus);
|
||||||
g_signal_connect (bus, "message::async-done", (GCallback) async_done_cb,
|
g_signal_connect (bus, "message::async-done", (GCallback) async_done_cb,
|
||||||
scenario);
|
scenario);
|
||||||
|
@ -724,7 +724,7 @@ gst_qa_scenario_factory_create (GstQaRunner * runner,
|
||||||
g_print ("\n=========================================\n"
|
g_print ("\n=========================================\n"
|
||||||
"Running scenario %s on pipeline %s"
|
"Running scenario %s on pipeline %s"
|
||||||
"\n=========================================\n", scenario_name,
|
"\n=========================================\n", scenario_name,
|
||||||
GST_OBJECT_NAME (runner->pipeline));
|
GST_OBJECT_NAME (pipeline));
|
||||||
|
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct _GstQaScenario
|
||||||
GType gst_qa_scenario_get_type (void);
|
GType gst_qa_scenario_get_type (void);
|
||||||
|
|
||||||
GstQaScenario * gst_qa_scenario_factory_create (GstQaRunner *runner,
|
GstQaScenario * gst_qa_scenario_factory_create (GstQaRunner *runner,
|
||||||
|
GstElement *pipeline,
|
||||||
const gchar *scenario_name);
|
const gchar *scenario_name);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -244,6 +244,7 @@ main (int argc, gchar ** argv)
|
||||||
{
|
{
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstQaRunner *runner;
|
GstQaRunner *runner;
|
||||||
|
GstQaMonitor *monitor;
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
|
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
@ -304,7 +305,9 @@ main (int argc, gchar ** argv)
|
||||||
/* Create the pipeline */
|
/* Create the pipeline */
|
||||||
create_transcoding_pipeline (argv[1], argv[2]);
|
create_transcoding_pipeline (argv[1], argv[2]);
|
||||||
|
|
||||||
runner = gst_qa_runner_new (pipeline);
|
runner = gst_qa_runner_new ();
|
||||||
|
monitor =
|
||||||
|
gst_qa_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL);
|
||||||
mainloop = g_main_loop_new (NULL, FALSE);
|
mainloop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
if (!runner) {
|
if (!runner) {
|
||||||
|
@ -328,6 +331,7 @@ main (int argc, gchar ** argv)
|
||||||
exit:
|
exit:
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
g_main_loop_unref (mainloop);
|
g_main_loop_unref (mainloop);
|
||||||
|
g_object_unref (monitor);
|
||||||
g_object_unref (runner);
|
g_object_unref (runner);
|
||||||
g_object_unref (pipeline);
|
g_object_unref (pipeline);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ main (int argc, gchar ** argv)
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
gchar **argvn;
|
gchar **argvn;
|
||||||
GstQaRunner *runner;
|
GstQaRunner *runner;
|
||||||
|
GstQaMonitor *monitor;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
ctx = g_option_context_new ("- runs QA tests for a pipeline.");
|
ctx = g_option_context_new ("- runs QA tests for a pipeline.");
|
||||||
|
@ -87,7 +88,9 @@ main (int argc, gchar ** argv)
|
||||||
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &err);
|
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &err);
|
||||||
g_free (argvn);
|
g_free (argvn);
|
||||||
|
|
||||||
runner = gst_qa_runner_new (pipeline);
|
runner = gst_qa_runner_new ();
|
||||||
|
monitor =
|
||||||
|
gst_qa_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL);
|
||||||
mainloop = g_main_loop_new (NULL, FALSE);
|
mainloop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
if (!runner) {
|
if (!runner) {
|
||||||
|
@ -111,6 +114,7 @@ main (int argc, gchar ** argv)
|
||||||
exit:
|
exit:
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
g_main_loop_unref (mainloop);
|
g_main_loop_unref (mainloop);
|
||||||
|
g_object_unref (monitor);
|
||||||
g_object_unref (runner);
|
g_object_unref (runner);
|
||||||
g_object_unref (pipeline);
|
g_object_unref (pipeline);
|
||||||
if (count)
|
if (count)
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gst/qa/gst-qa-runner.h>
|
#include <gst/qa/gst-qa-runner.h>
|
||||||
|
#include <gst/qa/gst-qa-file-checker.h>
|
||||||
|
#include <gst/qa/gst-qa-monitor-factory.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue