validate-reporter: Add return value to intercept_report.

It will allow to drop, keep or report reports.
This commit is contained in:
Mathieu Duponchelle 2014-10-01 15:11:21 +02:00 committed by Mathieu Duponchelle
parent 6104701268
commit 3e557ca92b
5 changed files with 49 additions and 16 deletions

View file

@ -56,8 +56,9 @@ static GObject *gst_validate_monitor_constructor (GType type,
gboolean gst_validate_monitor_setup (GstValidateMonitor * monitor); gboolean gst_validate_monitor_setup (GstValidateMonitor * monitor);
static void gst_validate_monitor_intercept_report (GstValidateReporter * static GstValidateInterceptionReturn
reporter, GstValidateReport * report); gst_validate_monitor_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report);
#define _do_init \ #define _do_init \
G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init) G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init)
@ -218,7 +219,7 @@ gst_validate_monitor_get_element_name (GstValidateMonitor * monitor)
} }
/* Check if any of our overrides wants to change the report severity */ /* Check if any of our overrides wants to change the report severity */
static void static GstValidateInterceptionReturn
gst_validate_monitor_intercept_report (GstValidateReporter * reporter, gst_validate_monitor_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report) GstValidateReport * report)
{ {
@ -232,6 +233,8 @@ gst_validate_monitor_intercept_report (GstValidateReporter * reporter,
gst_validate_issue_get_id (report->issue), report->level); gst_validate_issue_get_id (report->issue), report->level);
} }
GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (monitor); GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (monitor);
return GST_VALIDATE_REPORTER_REPORT;
} }
void void

View file

@ -39,8 +39,9 @@
* TODO * TODO
*/ */
static void gst_validate_pad_monitor_intercept_report (GstValidateReporter * static GstValidateInterceptionReturn
reporter, GstValidateReport * report); gst_validate_pad_monitor_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report);
#define _do_init \ #define _do_init \
G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init) G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init)
@ -121,7 +122,7 @@ typedef struct
} SerializedEventData; } SerializedEventData;
static void static GstValidateInterceptionReturn
gst_validate_pad_monitor_intercept_report (GstValidateReporter * gst_validate_pad_monitor_intercept_report (GstValidateReporter *
reporter, GstValidateReport * report) reporter, GstValidateReport * report)
{ {
@ -133,6 +134,7 @@ gst_validate_pad_monitor_intercept_report (GstValidateReporter *
old_iface_class = g_type_interface_peek_parent (iface_class); old_iface_class = g_type_interface_peek_parent (iface_class);
old_iface_class->intercept_report (reporter, report); old_iface_class->intercept_report (reporter, report);
return GST_VALIDATE_REPORTER_REPORT;
} }
static void static void

View file

@ -98,21 +98,25 @@ gst_validate_reporter_get_priv (GstValidateReporter * reporter)
(g_mutex_unlock (&gst_validate_reporter_get_priv(GST_VALIDATE_REPORTER_CAST(r))->reports_lock)); \ (g_mutex_unlock (&gst_validate_reporter_get_priv(GST_VALIDATE_REPORTER_CAST(r))->reports_lock)); \
} G_STMT_END } G_STMT_END
static void static GstValidateInterceptionReturn
gst_validate_reporter_intercept_report (GstValidateReporter * reporter, gst_validate_reporter_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report) GstValidateReport * report)
{ {
GstValidateInterceptionReturn ret = GST_VALIDATE_REPORTER_REPORT;
GstValidateReporterInterface *iface = GstValidateReporterInterface *iface =
GST_VALIDATE_REPORTER_GET_INTERFACE (reporter); GST_VALIDATE_REPORTER_GET_INTERFACE (reporter);
if (iface->intercept_report) { if (iface->intercept_report) {
iface->intercept_report (reporter, report); ret = iface->intercept_report (reporter, report);
} }
return ret;
} }
GstValidateReport * GstValidateReport *
gst_validate_reporter_get_report (GstValidateReporter *reporter, gst_validate_reporter_get_report (GstValidateReporter * reporter,
GstValidateIssueId issue_id) { GstValidateIssueId issue_id)
{
GstValidateReport *report; GstValidateReport *report;
GstValidateReporterPrivate *priv = gst_validate_reporter_get_priv (reporter); GstValidateReporterPrivate *priv = gst_validate_reporter_get_priv (reporter);
@ -132,6 +136,7 @@ gst_validate_report_valist (GstValidateReporter * reporter,
va_list vacopy; va_list vacopy;
GstValidateIssue *issue; GstValidateIssue *issue;
GstValidateReporterPrivate *priv = gst_validate_reporter_get_priv (reporter); GstValidateReporterPrivate *priv = gst_validate_reporter_get_priv (reporter);
GstValidateInterceptionReturn int_ret;
issue = gst_validate_issue_from_id (issue_id); issue = gst_validate_issue_from_id (issue_id);
@ -141,7 +146,13 @@ gst_validate_report_valist (GstValidateReporter * reporter,
message = g_strdup_vprintf (format, vacopy); message = g_strdup_vprintf (format, vacopy);
report = gst_validate_report_new (issue, reporter, message); report = gst_validate_report_new (issue, reporter, message);
gst_validate_reporter_intercept_report (reporter, report); int_ret = gst_validate_reporter_intercept_report (reporter, report);
if (int_ret == GST_VALIDATE_REPORTER_DROP) {
gst_validate_report_unref (report);
g_free (message);
return;
}
if (issue->repeat == FALSE) { if (issue->repeat == FALSE) {
GstValidateIssueId issue_id = gst_validate_issue_get_id (issue); GstValidateIssueId issue_id = gst_validate_issue_get_id (issue);
@ -179,7 +190,7 @@ gst_validate_report_valist (GstValidateReporter * reporter,
g_free (combo); g_free (combo);
#endif #endif
if (priv->runner) { if (priv->runner && int_ret == GST_VALIDATE_REPORTER_REPORT) {
gst_validate_runner_add_report (priv->runner, report); gst_validate_runner_add_report (priv->runner, report);
} else { } else {
gst_validate_report_unref (report); gst_validate_report_unref (report);

View file

@ -51,12 +51,26 @@ G_BEGIN_DECLS
gst_validate_report (GST_VALIDATE_REPORTER (m), \ gst_validate_report (GST_VALIDATE_REPORTER (m), \
GST_VALIDATE_ISSUE_ID_##issue_id, ##args ); \ GST_VALIDATE_ISSUE_ID_##issue_id, ##args ); \
} G_STMT_END } G_STMT_END
#endif /* G_HAVE_ISO_VARARGS */ #endif /* G_HAVE_ISO_VARARGS */
#endif /* G_HAVE_GNUC_VARARGS */ #endif /* G_HAVE_GNUC_VARARGS */
GType gst_validate_reporter_get_type (void); GType gst_validate_reporter_get_type (void);
/**
* GstValidateInterceptionReturn:
*
* @GST_VALIDATE_REPORTER_DROP: The report will be completely ignored.
* @GST_VALIDATE_REPORTER_KEEP: The report will be kept by the reporter,
* but not reported to the runner.
* @GST_VALIDATE_REPORTER_REPORT: The report will be kept by the reporter
* and reported to the runner.
*/
typedef enum
{
GST_VALIDATE_REPORTER_DROP,
GST_VALIDATE_REPORTER_KEEP,
GST_VALIDATE_REPORTER_REPORT
} GstValidateInterceptionReturn;
/** /**
* GstValidateReporter: * GstValidateReporter:
*/ */
@ -64,7 +78,8 @@ struct _GstValidateReporterInterface
{ {
GTypeInterface parent; GTypeInterface parent;
void (*intercept_report)(GstValidateReporter * reporter, GstValidateReport * report); GstValidateInterceptionReturn (*intercept_report) (GstValidateReporter *
reporter, GstValidateReport * report);
}; };
void gst_validate_reporter_set_name (GstValidateReporter * reporter, void gst_validate_reporter_set_name (GstValidateReporter * reporter,

View file

@ -115,7 +115,7 @@ typedef struct KeyFileGroupName
gchar *group_name; gchar *group_name;
} KeyFileGroupName; } KeyFileGroupName;
static void static GstValidateInterceptionReturn
gst_validate_scenario_intercept_report (GstValidateReporter * reporter, gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report) GstValidateReport * report)
{ {
@ -127,6 +127,8 @@ gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
gst_validate_override_get_severity (tmp->data, gst_validate_override_get_severity (tmp->data,
gst_validate_issue_get_id (report->issue), report->level); gst_validate_issue_get_id (report->issue), report->level);
} }
return GST_VALIDATE_REPORTER_REPORT;
} }
static void static void