mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-12 09:15:29 +00:00
qa-bin-monitor: adds a bin monitor
Extends element-monitor to also wrap child elements
This commit is contained in:
parent
339ce21a86
commit
e04fe10eab
6 changed files with 258 additions and 7 deletions
|
@ -4,6 +4,7 @@ public_headers = \
|
||||||
c_sources = \
|
c_sources = \
|
||||||
gst-qa-runner.c \
|
gst-qa-runner.c \
|
||||||
gst-qa-element-monitor.c \
|
gst-qa-element-monitor.c \
|
||||||
|
gst-qa-bin-monitor.c \
|
||||||
gst-qa-pad-monitor.c \
|
gst-qa-pad-monitor.c \
|
||||||
gst-qa-monitor-factory.c
|
gst-qa-monitor-factory.c
|
||||||
|
|
||||||
|
|
155
validate/gst/qa/gst-qa-bin-monitor.c
Normal file
155
validate/gst/qa/gst-qa-bin-monitor.c
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
|
||||||
|
*
|
||||||
|
* gst-qa-bin-monitor.c - QA BinMonitor class
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gst-qa-bin-monitor.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gst-qa-bin-monitor
|
||||||
|
* @short_description: Class that wraps a #GstBin for QA checks
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_STATIC (gst_qa_bin_monitor_debug);
|
||||||
|
#define GST_CAT_DEFAULT gst_qa_bin_monitor_debug
|
||||||
|
|
||||||
|
#define _do_init \
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_qa_bin_monitor_debug, "qa_bin_monitor", 0, "QA BinMonitor");
|
||||||
|
#define gst_qa_bin_monitor_parent_class parent_class
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GstQaBinMonitor, gst_qa_bin_monitor,
|
||||||
|
G_TYPE_OBJECT, _do_init);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_qa_bin_monitor_wrap_element (GstQaBinMonitor * monitor,
|
||||||
|
GstElement * element);
|
||||||
|
static gboolean gst_qa_bin_monitor_setup (GstQaElementMonitor * monitor);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_qa_bin_element_added (GstBin * bin, GstElement * pad,
|
||||||
|
GstQaBinMonitor * monitor);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_qa_bin_monitor_dispose (GObject * object)
|
||||||
|
{
|
||||||
|
GstQaBinMonitor *monitor = GST_QA_BIN_MONITOR_CAST (object);
|
||||||
|
GstQaElementMonitor *element_monitor = GST_QA_ELEMENT_MONITOR_CAST (object);
|
||||||
|
GstElement *bin = element_monitor->element;
|
||||||
|
|
||||||
|
if (monitor->element_added_id)
|
||||||
|
g_signal_handler_disconnect (bin, monitor->element_added_id);
|
||||||
|
|
||||||
|
g_list_free_full (monitor->element_monitors, g_object_unref);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_qa_bin_monitor_class_init (GstQaBinMonitorClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class;
|
||||||
|
GstQaElementMonitorClass *gstqaelementmonitor_class;
|
||||||
|
|
||||||
|
gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
gstqaelementmonitor_class = GST_QA_ELEMENT_MONITOR_CLASS_CAST (klass);
|
||||||
|
|
||||||
|
gobject_class->dispose = gst_qa_bin_monitor_dispose;
|
||||||
|
|
||||||
|
gstqaelementmonitor_class->setup = gst_qa_bin_monitor_setup;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_qa_bin_monitor_init (GstQaBinMonitor * bin_monitor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_qa_bin_monitor_new:
|
||||||
|
* @bin: (transfer-none): a #GstBin to run QA on
|
||||||
|
*/
|
||||||
|
GstQaBinMonitor *
|
||||||
|
gst_qa_bin_monitor_new (GstBin * bin)
|
||||||
|
{
|
||||||
|
GstQaBinMonitor *monitor = g_object_new (GST_TYPE_QA_BIN_MONITOR, NULL);
|
||||||
|
GstQaElementMonitor *element_monitor = GST_QA_ELEMENT_MONITOR_CAST (bin);
|
||||||
|
|
||||||
|
g_return_val_if_fail (bin != NULL, NULL);
|
||||||
|
|
||||||
|
element_monitor->element = gst_object_ref (bin);
|
||||||
|
return monitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_qa_bin_monitor_setup (GstQaElementMonitor * element_monitor)
|
||||||
|
{
|
||||||
|
GstIterator *iterator;
|
||||||
|
gboolean done;
|
||||||
|
GstElement *element;
|
||||||
|
GstQaBinMonitor *monitor = GST_QA_BIN_MONITOR_CAST (element_monitor);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (monitor, "Setting up monitor for bin %" GST_PTR_FORMAT,
|
||||||
|
element_monitor->element);
|
||||||
|
|
||||||
|
monitor->element_added_id =
|
||||||
|
g_signal_connect (GST_BIN_CAST (element_monitor->element),
|
||||||
|
"element-added", G_CALLBACK (_qa_bin_element_added), monitor);
|
||||||
|
|
||||||
|
iterator = gst_bin_iterate_elements (GST_BIN_CAST (element_monitor->element));
|
||||||
|
done = FALSE;
|
||||||
|
while (!done) {
|
||||||
|
switch (gst_iterator_next (iterator, (gpointer *) & element)) {
|
||||||
|
case GST_ITERATOR_OK:
|
||||||
|
gst_qa_bin_monitor_wrap_element (monitor, element);
|
||||||
|
gst_object_unref (element);
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_RESYNC:
|
||||||
|
/* TODO how to handle this? */
|
||||||
|
gst_iterator_resync (iterator);
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_ERROR:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_DONE:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gst_iterator_free (iterator);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_qa_bin_monitor_wrap_element (GstQaBinMonitor * monitor,
|
||||||
|
GstElement * element)
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (monitor, "Wrapping element %s", GST_ELEMENT_NAME (element));
|
||||||
|
/* TODO */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_qa_bin_element_added (GstBin * bin, GstElement * element,
|
||||||
|
GstQaBinMonitor * monitor)
|
||||||
|
{
|
||||||
|
GstQaElementMonitor *element_monitor = GST_QA_ELEMENT_MONITOR_CAST (monitor);
|
||||||
|
g_return_if_fail (element_monitor->element == GST_ELEMENT_CAST (bin));
|
||||||
|
gst_qa_bin_monitor_wrap_element (monitor, element);
|
||||||
|
}
|
77
validate/gst/qa/gst-qa-bin-monitor.h
Normal file
77
validate/gst/qa/gst-qa-bin-monitor.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
|
||||||
|
*
|
||||||
|
* gst-qa-bin-monitor.h - QA BinMonitor class
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GST_QA_BIN_MONITOR_H__
|
||||||
|
#define __GST_QA_BIN_MONITOR_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include "gst-qa-element-monitor.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_QA_BIN_MONITOR (gst_qa_bin_monitor_get_type ())
|
||||||
|
#define GST_IS_QA_BIN_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QA_BIN_MONITOR))
|
||||||
|
#define GST_IS_QA_BIN_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QA_BIN_MONITOR))
|
||||||
|
#define GST_QA_BIN_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QA_BIN_MONITOR, GstQaBinMonitorClass))
|
||||||
|
#define GST_QA_BIN_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QA_BIN_MONITOR, GstQaBinMonitor))
|
||||||
|
#define GST_QA_BIN_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QA_BIN_MONITOR, GstQaBinMonitorClass))
|
||||||
|
#define GST_QA_BIN_MONITOR_CAST(obj) ((GstQaBinMonitor*)(obj))
|
||||||
|
#define GST_QA_BIN_MONITOR_CLASS_CAST(klass) ((GstQaBinMonitorClass*)(klass))
|
||||||
|
|
||||||
|
typedef struct _GstQaBinMonitor GstQaBinMonitor;
|
||||||
|
typedef struct _GstQaBinMonitorClass GstQaBinMonitorClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstQaBinMonitor:
|
||||||
|
*
|
||||||
|
* GStreamer QA BinMonitor class.
|
||||||
|
*
|
||||||
|
* Class that wraps a #GstBin for QA checks
|
||||||
|
*/
|
||||||
|
struct _GstQaBinMonitor {
|
||||||
|
GstQaElementMonitor parent;
|
||||||
|
|
||||||
|
GList *element_monitors;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
gulong element_added_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstQaBinMonitorClass:
|
||||||
|
* @parent_class: parent
|
||||||
|
*
|
||||||
|
* GStreamer QA BinMonitor object class.
|
||||||
|
*/
|
||||||
|
struct _GstQaBinMonitorClass {
|
||||||
|
GstQaElementMonitorClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* normal GObject stuff */
|
||||||
|
GType gst_qa_bin_monitor_get_type (void);
|
||||||
|
|
||||||
|
GstQaBinMonitor * gst_qa_bin_monitor_new (GstBin * bin);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_QA_BIN_MONITOR_H__ */
|
||||||
|
|
|
@ -39,6 +39,7 @@ G_DEFINE_TYPE_WITH_CODE (GstQaElementMonitor, gst_qa_element_monitor,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_qa_element_monitor_wrap_pad (GstQaElementMonitor * monitor, GstPad * pad);
|
gst_qa_element_monitor_wrap_pad (GstQaElementMonitor * monitor, GstPad * pad);
|
||||||
|
static gboolean gst_qa_element_monitor_do_setup (GstQaElementMonitor * monitor);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_qa_element_pad_added (GstElement * element, GstPad * pad,
|
_qa_element_pad_added (GstElement * element, GstPad * pad,
|
||||||
|
@ -69,6 +70,8 @@ gst_qa_element_monitor_class_init (GstQaElementMonitorClass * klass)
|
||||||
gobject_class = G_OBJECT_CLASS (klass);
|
gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->dispose = gst_qa_element_monitor_dispose;
|
gobject_class->dispose = gst_qa_element_monitor_dispose;
|
||||||
|
|
||||||
|
klass->setup = gst_qa_element_monitor_do_setup;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -93,16 +96,13 @@ gst_qa_element_monitor_new (GstElement * element)
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
gst_qa_element_monitor_setup (GstQaElementMonitor * monitor)
|
gst_qa_element_monitor_do_setup (GstQaElementMonitor * monitor)
|
||||||
{
|
{
|
||||||
GstIterator *iterator;
|
GstIterator *iterator;
|
||||||
gboolean done;
|
gboolean done;
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
if (monitor->setup)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (monitor, "Setting up monitor for element %" GST_PTR_FORMAT,
|
GST_DEBUG_OBJECT (monitor, "Setting up monitor for element %" GST_PTR_FORMAT,
|
||||||
monitor->element);
|
monitor->element);
|
||||||
|
|
||||||
|
@ -130,11 +130,22 @@ gst_qa_element_monitor_setup (GstQaElementMonitor * monitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_iterator_free (iterator);
|
gst_iterator_free (iterator);
|
||||||
|
|
||||||
monitor->setup = TRUE;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_qa_element_monitor_setup (GstQaElementMonitor * monitor)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
if (monitor->setup)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
ret = GST_QA_ELEMENT_MONITOR_GET_CLASS (monitor)->setup (monitor);
|
||||||
|
if (ret)
|
||||||
|
monitor->setup = TRUE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_qa_element_monitor_wrap_pad (GstQaElementMonitor * monitor, GstPad * pad)
|
gst_qa_element_monitor_wrap_pad (GstQaElementMonitor * monitor, GstPad * pad)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,8 @@ struct _GstQaElementMonitor {
|
||||||
*/
|
*/
|
||||||
struct _GstQaElementMonitorClass {
|
struct _GstQaElementMonitorClass {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
gboolean (* setup) (GstQaElementMonitor * monitor);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* normal GObject stuff */
|
/* normal GObject stuff */
|
||||||
|
|
|
@ -20,11 +20,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gst-qa-monitor-factory.h"
|
#include "gst-qa-monitor-factory.h"
|
||||||
|
#include "gst-qa-bin-monitor.h"
|
||||||
|
|
||||||
GstQaElementMonitor *
|
GstQaElementMonitor *
|
||||||
gst_qa_monitor_factory_create (GstElement * element)
|
gst_qa_monitor_factory_create (GstElement * element)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (element != NULL, NULL);
|
g_return_val_if_fail (element != NULL, NULL);
|
||||||
|
|
||||||
|
if (GST_IS_BIN (element)) {
|
||||||
|
return gst_qa_bin_monitor_new (GST_BIN_CAST (element));
|
||||||
|
}
|
||||||
|
|
||||||
return gst_qa_element_monitor_new (element);
|
return gst_qa_element_monitor_new (element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue