Merging gst-devtools
[platform/upstream/gstreamer.git] / validate / gst / validate / gst-validate-reporter.h
1 /* GStreamer
2  *
3  * Copyright (C) 2013 Thibault Saunier <thibault.saunier@collabora.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 #ifndef _GST_VALIDATE_REPORTER_
21 #define _GST_VALIDATE_REPORTER_
22
23 typedef struct _GstValidateReporter GstValidateReporter;
24 typedef struct _GstValidateReporterInterface GstValidateReporterInterface;
25
26 #include <glib-object.h>
27 #include <gst/validate/validate-prelude.h>
28 #include <gst/validate/gst-validate-report.h>
29 #include <gst/validate/gst-validate-runner.h>
30 #include <gst/validate/gst-validate-enums.h>
31 #include <gst/validate/gst-validate-scenario.h>
32
33 G_BEGIN_DECLS
34
35 /* GstValidateReporter interface declarations */
36 #ifndef __GI_SCANNER__
37 #define GST_TYPE_VALIDATE_REPORTER                (gst_validate_reporter_get_type ())
38 #define GST_VALIDATE_REPORTER(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VALIDATE_REPORTER, GstValidateReporter))
39 #define GST_IS_VALIDATE_REPORTER(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VALIDATE_REPORTER))
40 #define GST_VALIDATE_REPORTER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_VALIDATE_REPORTER, GstValidateReporterInterface))
41 #define GST_VALIDATE_REPORTER_CAST(obj)           ((GstValidateReporter *) obj)
42 #endif
43
44 /**
45  * GST_VALIDATE_REPORT:
46  * @m: The #GstValidateReporter where the issue happened
47  * @issue_id: The #GstValidateIssueId of the issue
48  * @...: The format of the message describing the issue in a printf
49  *       format, followed by the parameters.
50  *
51  * Reports a new issue in the GstValidate reporting system with @m
52  * as the source of that issue.
53  */
54 #ifdef G_HAVE_ISO_VARARGS
55 #define GST_VALIDATE_REPORT(m, issue_id, ...)                           \
56   G_STMT_START {                                                        \
57     gst_validate_report (GST_VALIDATE_REPORTER (m),                     \
58                          issue_id,              \
59                          __VA_ARGS__ );                                 \
60   } G_STMT_END
61
62 #define GST_VALIDATE_REPORT_ACTION(m, a, issue_id, ...)                         \
63   G_STMT_START {                                                        \
64     gst_validate_report_action (GST_VALIDATE_REPORTER (m), a,   \
65                          issue_id,              \
66                          __VA_ARGS__ );                                 \
67   } G_STMT_END
68
69 #else /* G_HAVE_GNUC_VARARGS */
70 #ifdef G_HAVE_GNUC_VARARGS
71 #define GST_VALIDATE_REPORT(m, issue_id, args...)                       \
72   G_STMT_START {                                                        \
73     gst_validate_report (GST_VALIDATE_REPORTER (m),                     \
74                          issue_id, ##args );    \
75   } G_STMT_END
76 #define GST_VALIDATE_REPORT_ACTION(m, a, issue_id, args...)                     \
77   G_STMT_START {                                                        \
78     gst_validate_report_action (GST_VALIDATE_REPORTER (m), a,           \
79                          issue_id, ##args );    \
80   } G_STMT_END
81 #endif /* G_HAVE_ISO_VARARGS */
82 #endif /* G_HAVE_GNUC_VARARGS */
83 GST_VALIDATE_API
84 GType gst_validate_reporter_get_type (void);
85
86 /**
87  * GstValidateInterceptionReturn:
88  * @GST_VALIDATE_REPORTER_DROP: The report will be completely ignored.
89  * @GST_VALIDATE_REPORTER_KEEP: The report will be kept by the reporter,
90  *                              but not reported to the runner.
91  * @GST_VALIDATE_REPORTER_REPORT: The report will be kept by the reporter
92  *                                and reported to the runner.
93  */
94 typedef enum
95 {
96   GST_VALIDATE_REPORTER_DROP,
97   GST_VALIDATE_REPORTER_KEEP,
98   GST_VALIDATE_REPORTER_REPORT
99 } GstValidateInterceptionReturn;
100
101 /**
102  * GstValidateReporter:
103  */
104 struct _GstValidateReporterInterface
105 {
106   GTypeInterface parent;
107
108     GstValidateInterceptionReturn (*intercept_report)    (GstValidateReporter * reporter,
109                                                           GstValidateReport   * report);
110     GstValidateReportingDetails   (*get_reporting_level) (GstValidateReporter * reporter);
111     GstPipeline *                 (*get_pipeline)        (GstValidateReporter *reporter);
112 };
113
114 GST_VALIDATE_API
115 void gst_validate_reporter_set_name            (GstValidateReporter * reporter,
116                                           gchar * name);
117 GST_VALIDATE_API
118 const gchar * gst_validate_reporter_get_name            (GstValidateReporter * reporter);
119 GST_VALIDATE_API
120 GstValidateRunner * gst_validate_reporter_get_runner (GstValidateReporter *reporter);
121 GST_VALIDATE_API
122 void gst_validate_reporter_init                (GstValidateReporter * reporter, const gchar *name);
123 GST_VALIDATE_API
124 void gst_validate_report                       (GstValidateReporter * reporter, GstValidateIssueId issue_id,
125                                                 const gchar * format, ...) G_GNUC_PRINTF (3, 4) G_GNUC_NO_INSTRUMENT;
126 GST_VALIDATE_API
127 void gst_validate_report_action                (GstValidateReporter * reporter,
128                                                 GstValidateAction *action,
129                                                 GstValidateIssueId issue_id,
130                                                 const gchar * format, ...) G_GNUC_PRINTF (4, 5) G_GNUC_NO_INSTRUMENT;
131 GST_VALIDATE_API
132 void gst_validate_report_valist                (GstValidateReporter * reporter, GstValidateIssueId issue_id,
133                                           const gchar * format, va_list var_args) G_GNUC_PRINTF (3, 0);
134 GST_VALIDATE_API void
135 gst_validate_reporter_report_simple (GstValidateReporter * reporter, GstValidateIssueId issue_id,
136                                           const gchar * message);
137
138 GST_VALIDATE_API
139 void gst_validate_reporter_set_runner          (GstValidateReporter * reporter, GstValidateRunner *runner);
140 GST_VALIDATE_API
141 void gst_validate_reporter_set_handle_g_logs   (GstValidateReporter * reporter);
142 GST_VALIDATE_API
143 GstValidateReport * gst_validate_reporter_get_report (GstValidateReporter *reporter,
144                                                       GstValidateIssueId issue_id);
145 GST_VALIDATE_API
146 GList * gst_validate_reporter_get_reports (GstValidateReporter * reporter);
147 GST_VALIDATE_API
148 gint gst_validate_reporter_get_reports_count (GstValidateReporter *reporter);
149 GST_VALIDATE_API
150 GstValidateReportingDetails gst_validate_reporter_get_reporting_level (GstValidateReporter *reporter);
151
152 GST_VALIDATE_API
153 void gst_validate_reporter_purge_reports (GstValidateReporter * reporter);
154 GST_VALIDATE_API
155 GstPipeline * gst_validate_reporter_get_pipeline (GstValidateReporter * reporter);
156
157 G_END_DECLS
158 #endif /* _GST_VALIDATE_REPORTER_ */