qa-monitor: add runner property

runner stores the GstQaRunner that will receive the error reports
from the monitors
This commit is contained in:
Thiago Santos 2013-07-12 00:41:43 -03:00
parent 08180f3a4c
commit aeacc4270b
12 changed files with 46 additions and 18 deletions

View File

@ -86,10 +86,10 @@ gst_qa_bin_monitor_init (GstQaBinMonitor * bin_monitor)
* @bin: (transfer-none): a #GstBin to run QA on * @bin: (transfer-none): a #GstBin to run QA on
*/ */
GstQaBinMonitor * GstQaBinMonitor *
gst_qa_bin_monitor_new (GstBin * bin) gst_qa_bin_monitor_new (GstBin * bin, GstQaRunner * runner)
{ {
GstQaBinMonitor *monitor = g_object_new (GST_TYPE_QA_BIN_MONITOR, "object", GstQaBinMonitor *monitor = g_object_new (GST_TYPE_QA_BIN_MONITOR, "object",
bin, NULL); bin, "qa-runner", runner, NULL);
if (GST_QA_MONITOR_GET_OBJECT (monitor) == NULL) { if (GST_QA_MONITOR_GET_OBJECT (monitor) == NULL) {
g_object_unref (monitor); g_object_unref (monitor);
@ -152,7 +152,9 @@ gst_qa_bin_monitor_wrap_element (GstQaBinMonitor * monitor,
GstQaElementMonitor *element_monitor; GstQaElementMonitor *element_monitor;
GST_DEBUG_OBJECT (monitor, "Wrapping element %s", GST_ELEMENT_NAME (element)); GST_DEBUG_OBJECT (monitor, "Wrapping element %s", GST_ELEMENT_NAME (element));
element_monitor = gst_qa_monitor_factory_create (element); element_monitor =
gst_qa_monitor_factory_create (element,
GST_QA_MONITOR_GET_RUNNER (monitor));
g_return_if_fail (element_monitor != NULL); g_return_if_fail (element_monitor != NULL);
GST_QA_MONITOR_LOCK (monitor); GST_QA_MONITOR_LOCK (monitor);

View File

@ -25,6 +25,7 @@
#include <glib-object.h> #include <glib-object.h>
#include <gst/gst.h> #include <gst/gst.h>
#include "gst-qa-element-monitor.h" #include "gst-qa-element-monitor.h"
#include "gst-qa-runner.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -71,7 +72,7 @@ struct _GstQaBinMonitorClass {
/* normal GObject stuff */ /* normal GObject stuff */
GType gst_qa_bin_monitor_get_type (void); GType gst_qa_bin_monitor_get_type (void);
GstQaBinMonitor * gst_qa_bin_monitor_new (GstBin * bin); GstQaBinMonitor * gst_qa_bin_monitor_new (GstBin * bin, GstQaRunner * runner);
G_END_DECLS G_END_DECLS

View File

@ -85,13 +85,14 @@ gst_qa_element_monitor_init (GstQaElementMonitor * element_monitor)
* @element: (transfer-none): a #GstElement to run QA on * @element: (transfer-none): a #GstElement to run QA on
*/ */
GstQaElementMonitor * GstQaElementMonitor *
gst_qa_element_monitor_new (GstElement * element) gst_qa_element_monitor_new (GstElement * element, GstQaRunner * runner)
{ {
GstQaElementMonitor *monitor; GstQaElementMonitor *monitor;
g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (element != NULL, NULL);
monitor = g_object_new (GST_TYPE_QA_ELEMENT_MONITOR, "object", element, NULL); monitor = g_object_new (GST_TYPE_QA_ELEMENT_MONITOR, "object", element,
"qa-runner", runner, NULL);
if (GST_QA_ELEMENT_MONITOR_GET_ELEMENT (monitor) == NULL) { if (GST_QA_ELEMENT_MONITOR_GET_ELEMENT (monitor) == NULL) {
g_object_unref (monitor); g_object_unref (monitor);
@ -155,7 +156,8 @@ gst_qa_element_monitor_wrap_pad (GstQaElementMonitor * monitor, GstPad * pad)
GstQaPadMonitor *pad_monitor; GstQaPadMonitor *pad_monitor;
GST_DEBUG_OBJECT (monitor, "Wrapping pad %s:%s", GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_OBJECT (monitor, "Wrapping pad %s:%s", GST_DEBUG_PAD_NAME (pad));
pad_monitor = gst_qa_pad_monitor_new (pad); pad_monitor =
gst_qa_pad_monitor_new (pad, GST_QA_MONITOR_GET_RUNNER (monitor));
g_return_if_fail (pad_monitor != NULL); g_return_if_fail (pad_monitor != NULL);
GST_QA_MONITOR_LOCK (monitor); GST_QA_MONITOR_LOCK (monitor);

View File

@ -71,7 +71,7 @@ struct _GstQaElementMonitorClass {
/* normal GObject stuff */ /* normal GObject stuff */
GType gst_qa_element_monitor_get_type (void); GType gst_qa_element_monitor_get_type (void);
GstQaElementMonitor * gst_qa_element_monitor_new (GstElement * element); GstQaElementMonitor * gst_qa_element_monitor_new (GstElement * element, GstQaRunner * runner);
G_END_DECLS G_END_DECLS

View File

@ -23,15 +23,15 @@
#include "gst-qa-bin-monitor.h" #include "gst-qa-bin-monitor.h"
GstQaElementMonitor * GstQaElementMonitor *
gst_qa_monitor_factory_create (GstElement * element) gst_qa_monitor_factory_create (GstElement * element, GstQaRunner * runner)
{ {
g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (element != NULL, NULL);
if (GST_IS_BIN (element)) { if (GST_IS_BIN (element)) {
return return
GST_QA_ELEMENT_MONITOR_CAST (gst_qa_bin_monitor_new (GST_BIN_CAST GST_QA_ELEMENT_MONITOR_CAST (gst_qa_bin_monitor_new (GST_BIN_CAST
(element))); (element), runner));
} }
return gst_qa_element_monitor_new (element); return gst_qa_element_monitor_new (element, runner);
} }

View File

@ -25,10 +25,11 @@
#include <glib-object.h> #include <glib-object.h>
#include <gst/gst.h> #include <gst/gst.h>
#include "gst-qa-element-monitor.h" #include "gst-qa-element-monitor.h"
#include "gst-qa-runner.h"
G_BEGIN_DECLS G_BEGIN_DECLS
GstQaElementMonitor * gst_qa_monitor_factory_create (GstElement * element); GstQaElementMonitor * gst_qa_monitor_factory_create (GstElement * element, GstQaRunner * runner);
G_END_DECLS G_END_DECLS

View File

@ -32,6 +32,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_OBJECT, PROP_OBJECT,
PROP_RUNNER,
PROP_LAST PROP_LAST
}; };
@ -81,6 +82,10 @@ gst_qa_monitor_class_init (GstQaMonitorClass * klass)
g_object_class_install_property (gobject_class, PROP_OBJECT, g_object_class_install_property (gobject_class, PROP_OBJECT,
g_param_spec_object ("object", "Object", "The object to be monitored", g_param_spec_object ("object", "Object", "The object to be monitored",
G_TYPE_OBJECT, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); G_TYPE_OBJECT, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_RUNNER,
g_param_spec_object ("qa-runner", "QA Runner", "The QA runner to "
"report errors to", GST_TYPE_QA_RUNNER, G_PARAM_READWRITE));
} }
static void static void
@ -118,6 +123,7 @@ gst_qa_monitor_do_setup (GstQaMonitor * monitor)
gboolean gboolean
gst_qa_monitor_setup (GstQaMonitor * monitor) gst_qa_monitor_setup (GstQaMonitor * monitor)
{ {
GST_DEBUG_OBJECT (monitor, "Starting monitor setup");
return GST_QA_MONITOR_GET_CLASS (monitor)->setup (monitor); return GST_QA_MONITOR_GET_CLASS (monitor)->setup (monitor);
} }
@ -135,6 +141,11 @@ gst_qa_monitor_set_property (GObject * object, guint prop_id,
monitor->object = g_value_dup_object (value); monitor->object = g_value_dup_object (value);
gst_qa_monitor_setup (monitor); gst_qa_monitor_setup (monitor);
break; break;
case PROP_RUNNER:
/* we assume the runner is valid as long as this monitor is,
* no ref taken */
monitor->runner = g_value_get_object (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -153,6 +164,12 @@ gst_qa_monitor_get_property (GObject * object, guint prop_id,
case PROP_OBJECT: case PROP_OBJECT:
g_value_set_object (value, GST_QA_MONITOR_GET_OBJECT (monitor)); g_value_set_object (value, GST_QA_MONITOR_GET_OBJECT (monitor));
break; break;
case PROP_RUNNER:
if (GST_QA_MONITOR_GET_RUNNER (monitor))
g_value_set_object (value, GST_QA_MONITOR_GET_RUNNER (monitor));
else
g_value_set_object (value, NULL);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View File

@ -24,6 +24,7 @@
#include <glib-object.h> #include <glib-object.h>
#include <gst/gst.h> #include <gst/gst.h>
#include "gst-qa-runner.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -37,6 +38,7 @@ G_BEGIN_DECLS
#define GST_QA_MONITOR_CLASS_CAST(klass) ((GstQaMonitorClass*)(klass)) #define GST_QA_MONITOR_CLASS_CAST(klass) ((GstQaMonitorClass*)(klass))
#define GST_QA_MONITOR_GET_OBJECT(m) (GST_QA_MONITOR_CAST (m)->object) #define GST_QA_MONITOR_GET_OBJECT(m) (GST_QA_MONITOR_CAST (m)->object)
#define GST_QA_MONITOR_GET_RUNNER(m) (GST_QA_MONITOR_CAST (m)->runner)
#define GST_QA_MONITOR_LOCK(m) (g_mutex_lock (&GST_QA_MONITOR_CAST(m)->mutex)) #define GST_QA_MONITOR_LOCK(m) (g_mutex_lock (&GST_QA_MONITOR_CAST(m)->mutex))
#define GST_QA_MONITOR_UNLOCK(m) (g_mutex_unlock (&GST_QA_MONITOR_CAST(m)->mutex)) #define GST_QA_MONITOR_UNLOCK(m) (g_mutex_unlock (&GST_QA_MONITOR_CAST(m)->mutex))
@ -56,6 +58,8 @@ struct _GstQaMonitor {
GObject *object; GObject *object;
GMutex mutex; GMutex mutex;
GstQaRunner *runner;
/*< private >*/ /*< private >*/
}; };

View File

@ -70,10 +70,10 @@ gst_qa_pad_monitor_init (GstQaPadMonitor * pad_monitor)
* @pad: (transfer-none): a #GstPad to run QA on * @pad: (transfer-none): a #GstPad to run QA on
*/ */
GstQaPadMonitor * GstQaPadMonitor *
gst_qa_pad_monitor_new (GstPad * pad) gst_qa_pad_monitor_new (GstPad * pad, GstQaRunner * runner)
{ {
GstQaPadMonitor *monitor = g_object_new (GST_TYPE_QA_PAD_MONITOR, GstQaPadMonitor *monitor = g_object_new (GST_TYPE_QA_PAD_MONITOR,
"object", pad, NULL); "object", pad, "qa-runner", runner, NULL);
if (GST_QA_PAD_MONITOR_GET_PAD (monitor) == NULL) { if (GST_QA_PAD_MONITOR_GET_PAD (monitor) == NULL) {
g_object_unref (monitor); g_object_unref (monitor);

View File

@ -85,7 +85,7 @@ struct _GstQaPadMonitorClass {
/* normal GObject stuff */ /* normal GObject stuff */
GType gst_qa_pad_monitor_get_type (void); GType gst_qa_pad_monitor_get_type (void);
GstQaPadMonitor * gst_qa_pad_monitor_new (GstPad * pad); GstQaPadMonitor * gst_qa_pad_monitor_new (GstPad * pad, GstQaRunner * runner);
G_END_DECLS G_END_DECLS

View File

@ -88,7 +88,7 @@ gst_qa_runner_setup (GstQaRunner * runner)
return TRUE; return TRUE;
GST_INFO_OBJECT (runner, "Starting QA Runner setup"); GST_INFO_OBJECT (runner, "Starting QA Runner setup");
runner->monitor = gst_qa_monitor_factory_create (runner->pipeline); runner->monitor = gst_qa_monitor_factory_create (runner->pipeline, runner);
if (runner->monitor == NULL) { if (runner->monitor == NULL) {
GST_WARNING_OBJECT (runner, "Setup failed"); GST_WARNING_OBJECT (runner, "Setup failed");
return FALSE; return FALSE;

View File

@ -25,10 +25,11 @@
#include <glib-object.h> #include <glib-object.h>
#include <gst/gst.h> #include <gst/gst.h>
#include "gst-qa-element-monitor.h"
G_BEGIN_DECLS G_BEGIN_DECLS
/* forward declaration */
typedef struct _GstQaElementMonitor GstQaElementMonitor;
#define GST_TYPE_QA_RUNNER (gst_qa_runner_get_type ()) #define GST_TYPE_QA_RUNNER (gst_qa_runner_get_type ())
#define GST_IS_QA_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QA_RUNNER)) #define GST_IS_QA_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QA_RUNNER))
#define GST_IS_QA_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QA_RUNNER)) #define GST_IS_QA_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QA_RUNNER))