1 /* GStreamer
2  * Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
3  *
4  * gst-validate-monitor-report.h - Validate Element report structures and functions
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 #ifndef __GST_VALIDATE_REPORT_H__
23 #define __GST_VALIDATE_REPORT_H__
24 
25 #include <glib-object.h>
26 
27 typedef struct _GstValidateReport GstValidateReport;
28 typedef guintptr GstValidateIssueId;
29 
30 #include <gst/gst.h>
31 #include <gst/validate/validate-prelude.h>
32 #include <gst/validate/gst-validate-reporter.h>
33 #include "gst-validate-types.h"
34 
35 G_BEGIN_DECLS
36 
37 GST_VALIDATE_API
38 GType           gst_validate_report_get_type (void);
39 #define GST_TYPE_VALIDATE_REPORT (gst_validate_report_get_type ())
40 
41 typedef enum {
42   GST_VALIDATE_FATAL_DEFAULT = 0,
43   GST_VALIDATE_FATAL_ISSUES = 1 << 0,
44   GST_VALIDATE_FATAL_WARNINGS = 1 << 1,
45   GST_VALIDATE_FATAL_CRITICALS = 1 << 2,
46   GST_VALIDATE_PRINT_ISSUES = 1 << 3,
47   GST_VALIDATE_PRINT_WARNINGS = 1 << 4,
48   GST_VALIDATE_PRINT_CRITICALS = 1 << 5
49 } GstValidateDebugFlags;
50 
51 typedef enum {
52   GST_VALIDATE_REPORT_LEVEL_CRITICAL,
53   GST_VALIDATE_REPORT_LEVEL_WARNING,
54   GST_VALIDATE_REPORT_LEVEL_ISSUE,
55   GST_VALIDATE_REPORT_LEVEL_IGNORE,
56   GST_VALIDATE_REPORT_LEVEL_UNKNOWN,
57   GST_VALIDATE_REPORT_LEVEL_NUM_ENTRIES,
58 } GstValidateReportLevel;
59 
60 #define _QUARK g_quark_from_static_string
61 
62 #define BUFFER_BEFORE_SEGMENT                    _QUARK("buffer::before-segment")
63 #define BUFFER_IS_OUT_OF_SEGMENT                 _QUARK("buffer::is-out-of-segment")
64 #define BUFFER_TIMESTAMP_OUT_OF_RECEIVED_RANGE   _QUARK("buffer::timestamp-out-of-received-range")
65 #define WRONG_FLOW_RETURN                        _QUARK("buffer::wrong-flow-return")
66 #define BUFFER_AFTER_EOS                         _QUARK("buffer::after-eos")
67 #define WRONG_BUFFER                             _QUARK("buffer::not-expected-one")
68 #define FLOW_ERROR_WITHOUT_ERROR_MESSAGE         _QUARK("buffer::flow-error-without-error-message")
69 #define BUFFER_MISSING_DISCONT                   _QUARK("buffer::missing-discont")
70 
71 #define CAPS_IS_MISSING_FIELD                    _QUARK("caps::is-missing-field")
72 #define CAPS_FIELD_HAS_BAD_TYPE                  _QUARK("caps::field-has-bad-type")
73 #define CAPS_EXPECTED_FIELD_NOT_FOUND            _QUARK("caps::expected-field-not-found")
74 #define GET_CAPS_NOT_PROXYING_FIELDS             _QUARK("caps::not-proxying-fields")
75 #define CAPS_FIELD_UNEXPECTED_VALUE              _QUARK("caps::field-unexpected-value")
76 
77 #define EVENT_NEWSEGMENT_NOT_PUSHED              _QUARK("event::newsegment-not-pushed")
78 #define SERIALIZED_EVENT_WASNT_PUSHED_IN_TIME    _QUARK("event::serialized-event-wasnt-pushed-in-time")
79 
80 #define EOS_HAS_WRONG_SEQNUM                    _QUARK("event::eos-has-wrong-seqnum")
81 #define FLUSH_START_HAS_WRONG_SEQNUM            _QUARK("event::flush-start-has-wrong-seqnum")
82 #define FLUSH_STOP_HAS_WRONG_SEQNUM             _QUARK("event::flush-stop-has-wrong-seqnum")
83 #define SEGMENT_HAS_WRONG_SEQNUM                _QUARK("event::segment-has-wrong-seqnum")
84 #define SEGMENT_HAS_WRONG_START                 _QUARK("event::segment-has-wrong-start")
85 
86 
87 #define EVENT_SERIALIZED_OUT_OF_ORDER            _QUARK("event::serialized-out-of-order")
88 #define EVENT_NEW_SEGMENT_MISMATCH               _QUARK("event::segment-mismatch")
89 #define EVENT_FLUSH_START_UNEXPECTED             _QUARK("event::flush-start-unexpected")
90 #define EVENT_FLUSH_STOP_UNEXPECTED              _QUARK("event::flush-stop-unexpected")
91 #define EVENT_CAPS_DUPLICATE                     _QUARK("event::caps-duplicate")
92 #define EVENT_SEEK_NOT_HANDLED                   _QUARK("event::seek-not-handled")
93 #define EVENT_SEEK_RESULT_POSITION_WRONG         _QUARK("event::seek-result-position-wrong")
94 #define EVENT_EOS_WITHOUT_SEGMENT                _QUARK("event::eos-without-segment")
95 #define EVENT_INVALID_SEQNUM                     _QUARK("event::invalid-seqnum")
96 
97 #define STATE_CHANGE_FAILURE                     _QUARK("state::change-failure")
98 
99 #define FILE_NO_STREAM_INFO                      _QUARK("file-checking::no-stream-info")
100 #define FILE_NO_STREAM_ID                        _QUARK("file-checking::no-stream-id")
101 #define FILE_TAG_DETECTION_INCORRECT             _QUARK("file-checking::tag-detection-incorrect")
102 #define FILE_SIZE_INCORRECT                      _QUARK("file-checking::size-incorrect")
103 #define FILE_DURATION_INCORRECT                  _QUARK("file-checking::duration-incorrect")
104 #define FILE_SEEKABLE_INCORRECT                  _QUARK("file-checking::seekable-incorrect")
105 #define FILE_PROFILE_INCORRECT                   _QUARK("file-checking::profile-incorrect")
106 #define FILE_FRAMES_INCORRECT                    _QUARK("file-checking::frames-incorrect")
107 #define FILE_SEGMENT_INCORRECT                   _QUARK("file-checking::segment-incorrect")
108 
109 #define ALLOCATION_FAILURE                       _QUARK("runtime::allocation-failure")
110 #define MISSING_PLUGIN                           _QUARK("runtime::missing-plugin")
111 #define NOT_NEGOTIATED                           _QUARK("runtime::not-negotiated")
112 #define WARNING_ON_BUS                           _QUARK("runtime::warning-on-bus")
113 #define ERROR_ON_BUS                             _QUARK("runtime::error-on-bus")
114 
115 #define QUERY_POSITION_SUPERIOR_DURATION         _QUARK("query::position-superior-duration")
116 #define QUERY_POSITION_OUT_OF_SEGMENT            _QUARK("query::position-out-of-segment")
117 
118 #define SCENARIO_NOT_ENDED                       _QUARK("scenario::not-ended")
119 #define SCENARIO_FILE_MALFORMED                  _QUARK("scenario::malformed")
120 #define SCENARIO_ACTION_EXECUTION_ERROR          _QUARK("scenario::execution-error")
121 #define SCENARIO_ACTION_TIMEOUT                  _QUARK("scenario::action-timeout")
122 #define SCENARIO_ACTION_EXECUTION_ISSUE          _QUARK("scenario::execution-issue")
123 
124 #define CONFIG_LATENCY_TOO_HIGH                  _QUARK("config::latency-too-high")
125 #define CONFIG_TOO_MANY_BUFFERS_DROPPED          _QUARK("config::too-many-buffers-dropped")
126 #define CONFIG_BUFFER_FREQUENCY_TOO_LOW          _QUARK("config::buffer-frequency-too-low")
127 
128 #define G_LOG_ISSUE                              _QUARK("g-log::issue")
129 #define G_LOG_WARNING                            _QUARK("g-log::warning")
130 #define G_LOG_CRITICAL                           _QUARK("g-log::critical")
131 
132 typedef struct {
133   GstValidateIssueId issue_id;
134 
135   /* Summary: one-liner translatable description of the issue */
136   gchar *summary;
137   /* description: multi-line translatable description of:
138   * * what the issue is (and why it's an issue)
139   * * what the source problem could be
140   * * pointers to fixing the issue
141   */
142   gchar *description;
143 
144   /* The name of the area of issue
145    * this one is in */
146   gchar *area;
147   /*  The name of the issue type */
148   gchar *name;
149 
150   /* default_level: The default level of severity for this
151   * issue. */
152   GstValidateReportLevel default_level;
153 
154   gint    refcount;
155 
156   gpointer _gst_reserved[GST_PADDING];
157 
158 } GstValidateIssue;
159 
160 GST_VALIDATE_API
161 GType           gst_validate_issue_get_type (void);
162 
163 struct _GstValidateReport {
164   GstMiniObject mini_object;
165 
166   /* issue: The issue this report corresponds to (to get description, summary,...) */
167   GstValidateIssue *issue;
168 
169   GstValidateReportLevel level;
170 
171   /* The reporter that reported the issue (to get names, info, ...) */
172   GstValidateReporter *reporter;
173 
174   /* timestamp: The time at which this issue happened since
175    * the process start (to stay in sync with gst logging) */
176   GstClockTime timestamp;
177 
178   /* message: issue-specific message. Gives more detail on the actual
179    * issue. Can be NULL */
180   gchar *message;
181 
182   /* When reporter->intercept_report returns KEEP, the report is not
183    * added to the runner. It can be added as a "shadow_report" to
184    * the upstream report, which is tracked by the runner. */
185   GMutex shadow_reports_lock;
186   GstValidateReport *master_report;
187   GList *shadow_reports;
188 
189   /* Lists the reports that were repeated inside the same reporter */
190   GList *repeated_reports;
191 
192   GstValidateReportingDetails reporting_level;
193   gchar *reporter_name;
194   gchar *trace;
195   gchar *dotfile_name;
196 
197   gpointer _gst_reserved[GST_PADDING - 2];
198 };
199 
200 void gst_validate_report_add_message (GstValidateReport *report,
201     const gchar *message);
202 
203 #define GST_VALIDATE_ISSUE_FORMAT G_GUINTPTR_FORMAT " (%s) : %s: %s"
204 #define GST_VALIDATE_ISSUE_ARGS(i) gst_validate_issue_get_id (i), \
205                                    gst_validate_report_level_get_name (i->default_level), \
206                                    i->area, \
207                                    i->summary
208 
209 #define GST_VALIDATE_ERROR_REPORT_PRINT_FORMAT GST_TIME_FORMAT " <%s>: %" GST_VALIDATE_ISSUE_FORMAT ": %s"
210 #define GST_VALIDATE_REPORT_PRINT_ARGS(r) GST_TIME_ARGS (r->timestamp), \
211                                     gst_validate_reporter_get_name (r->reporter), \
212                                     GST_VALIDATE_ISSUE_ARGS (r->issue), \
213                                     r->message
214 GST_VALIDATE_API
215 void               gst_validate_report_init (void);
216 GST_VALIDATE_API
217 GstValidateIssue  *gst_validate_issue_from_id (GstValidateIssueId issue_id);
218 GST_VALIDATE_API
219 GstValidateIssueId gst_validate_issue_get_id (GstValidateIssue * issue);
220 GST_VALIDATE_API
221 void               gst_validate_issue_register (GstValidateIssue * issue);
222 GST_VALIDATE_API
223 GstValidateIssue  *gst_validate_issue_new (GstValidateIssueId issue_id, const gchar * summary,
224 					   const gchar * description,
225 					   GstValidateReportLevel default_level);
226 GST_VALIDATE_API
227 void gst_validate_issue_set_default_level (GstValidateIssue *issue,
228                                            GstValidateReportLevel default_level);
229 
230 GST_VALIDATE_API
231 GstValidateReport *gst_validate_report_new (GstValidateIssue * issue,
232               GstValidateReporter * reporter,
233               const gchar * message);
234 GST_VALIDATE_API
235 void               gst_validate_report_unref (GstValidateReport * report);
236 GST_VALIDATE_API
237 GstValidateReport *gst_validate_report_ref   (GstValidateReport * report);
238 
239 GST_VALIDATE_API
240 GstValidateIssueId gst_validate_report_get_issue_id (GstValidateReport * report);
241 
242 GST_VALIDATE_API
243 gboolean           gst_validate_report_check_abort (GstValidateReport * report);
244 GST_VALIDATE_API
245 void               gst_validate_report_printf (GstValidateReport * report);
246 GST_VALIDATE_API
247 void               gst_validate_report_print_level (GstValidateReport *report);
248 GST_VALIDATE_API
249 void               gst_validate_report_print_detected_on (GstValidateReport *report);
250 GST_VALIDATE_API
251 void               gst_validate_report_print_details (GstValidateReport *report);
252 GST_VALIDATE_API
253 void               gst_validate_report_print_description (GstValidateReport *report);
254 
255 GST_VALIDATE_API
256 const gchar *      gst_validate_report_level_get_name (GstValidateReportLevel level);
257 
258 GST_VALIDATE_API
259 void               gst_validate_printf        (gpointer source,
260                                                const gchar      * format,
261                                                ...) G_GNUC_PRINTF (2, 3) G_GNUC_NO_INSTRUMENT;
262 GST_VALIDATE_API
263 void               gst_validate_print_action  (GstValidateAction *action, const gchar * message);
264 GST_VALIDATE_API
265 void               gst_validate_printf_valist (gpointer source,
266                                                const gchar      * format,
267                                                va_list            args) G_GNUC_NO_INSTRUMENT;
268 GST_VALIDATE_API
269 gboolean gst_validate_report_should_print (GstValidateReport * report);
270 GST_VALIDATE_API
271 gboolean gst_validate_report_set_master_report(GstValidateReport *report, GstValidateReport *master_report);
272 GST_VALIDATE_API
273 void gst_validate_report_set_reporting_level (GstValidateReport *report, GstValidateReportingDetails level);
274 GST_VALIDATE_API
275 void gst_validate_report_add_repeated_report (GstValidateReport *report, GstValidateReport *repeated_report);
276 GST_VALIDATE_API
277 GstValidateReportLevel gst_validate_report_level_from_name (const gchar *level_name);
278 
279 G_END_DECLS
280 
281 #endif /* __GST_VALIDATE_REPORT_H__ */
282 
283