pad-monitor: only do complete caps checks on setcaps
[platform/upstream/gstreamer.git] / validate / gst / qa / gst-qa-runner.c
1 /* GStreamer
2  * Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
3  *
4  * gst-qa-runner.c - QA Runner class
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #include "gst-qa-runner.h"
23 #include "gst-qa-report.h"
24 #include "gst-qa-monitor-factory.h"
25 #include "gst-qa-override-registry.h"
26
27 /**
28  * SECTION:gst-qa-runner
29  * @short_description: Class that runs Gst QA tests for a pipeline
30  *
31  * TODO
32  */
33
34 GST_DEBUG_CATEGORY_STATIC (gst_qa_runner_debug);
35 #define GST_CAT_DEFAULT gst_qa_runner_debug
36
37 #define _do_init \
38   GST_DEBUG_CATEGORY_INIT (gst_qa_runner_debug, "qa_runner", 0, "QA Runner");
39 #define gst_qa_runner_parent_class parent_class
40 G_DEFINE_TYPE_WITH_CODE (GstQaRunner, gst_qa_runner, G_TYPE_OBJECT, _do_init);
41
42 /* signals */
43 enum
44 {
45   REPORT_ADDED_SIGNAL,
46   /* add more above */
47   LAST_SIGNAL
48 };
49
50 static guint _signals[LAST_SIGNAL] = { 0 };
51
52 static void
53 gst_qa_runner_dispose (GObject * object)
54 {
55   GstQaRunner *runner = GST_QA_RUNNER_CAST (object);
56
57   g_slist_free_full (runner->reports, (GDestroyNotify) gst_qa_report_unref);
58
59   G_OBJECT_CLASS (parent_class)->dispose (object);
60 }
61
62 static void
63 gst_qa_runner_class_init (GstQaRunnerClass * klass)
64 {
65   GObjectClass *gobject_class;
66
67   gobject_class = G_OBJECT_CLASS (klass);
68
69   gobject_class->dispose = gst_qa_runner_dispose;
70
71   /* init the report system (can be called multiple times) */
72   gst_qa_report_init ();
73
74   /* Ensure we load overrides before any use of a monitor */
75   gst_qa_override_registry_preload ();
76
77   _signals[REPORT_ADDED_SIGNAL] =
78       g_signal_new ("report-added", G_TYPE_FROM_CLASS (klass),
79       G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
80       GST_TYPE_QA_REPORT);
81 }
82
83 static void
84 gst_qa_runner_init (GstQaRunner * runner)
85 {
86   runner->setup = FALSE;
87 }
88
89 /**
90  * gst_qa_runner_new:
91  */
92 GstQaRunner *
93 gst_qa_runner_new (void)
94 {
95   return g_object_new (GST_TYPE_QA_RUNNER, NULL);
96 }
97
98 void
99 gst_qa_runner_add_report (GstQaRunner * runner, GstQaReport * report)
100 {
101   runner->reports = g_slist_prepend (runner->reports, report);
102
103   g_signal_emit (runner, _signals[REPORT_ADDED_SIGNAL], 0, report);
104 }
105
106 guint
107 gst_qa_runner_get_reports_count (GstQaRunner * runner)
108 {
109   g_return_val_if_fail (runner != NULL, 0);
110   return g_slist_length (runner->reports);
111 }
112
113 GSList *
114 gst_qa_runner_get_reports (GstQaRunner * runner)
115 {
116   /* TODO should we need locking or put in htte docs to always call this
117    * after pipeline ends? */
118   return runner->reports;
119 }