mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
validate:override: Make overrides GObjects
Summary: This way we can subclass them getting a proper context in the various override methods. Depends on D204 Reviewers: Mathieu_Du Differential Revision: http://phabricator.freedesktop.org/D205
This commit is contained in:
parent
13864f4998
commit
40d00e8614
4 changed files with 141 additions and 19 deletions
|
@ -315,7 +315,17 @@ void
|
||||||
gst_validate_monitor_attach_override (GstValidateMonitor * monitor,
|
gst_validate_monitor_attach_override (GstValidateMonitor * monitor,
|
||||||
GstValidateOverride * override)
|
GstValidateOverride * override)
|
||||||
{
|
{
|
||||||
|
GstValidateRunner *runner;
|
||||||
|
|
||||||
|
runner = gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (override));
|
||||||
|
|
||||||
GST_VALIDATE_MONITOR_OVERRIDES_LOCK (monitor);
|
GST_VALIDATE_MONITOR_OVERRIDES_LOCK (monitor);
|
||||||
|
if (runner)
|
||||||
|
g_assert (runner ==
|
||||||
|
gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (monitor)));
|
||||||
|
else
|
||||||
|
gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (override),
|
||||||
|
gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (monitor)));
|
||||||
g_queue_push_tail (&monitor->overrides, override);
|
g_queue_push_tail (&monitor->overrides, override);
|
||||||
GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (monitor);
|
GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (monitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Collabora Ltd.
|
* Copyright (C) 2013 Collabora Ltd.
|
||||||
* Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>
|
* Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>
|
||||||
|
* Copyright (C) 2015 Raspberry Pi Foundation
|
||||||
|
* Author: Thibault Saunier <thibault.saunier@collabora.com>
|
||||||
*
|
*
|
||||||
* gst-validate-override.c - Validate Override that allows customizing Validate behavior
|
* gst-validate-override.c - Validate Override that allows customizing Validate behavior
|
||||||
*
|
*
|
||||||
|
@ -20,6 +22,13 @@
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* SECTION: gst-validate-override
|
||||||
|
* @title: GstValidateOverride
|
||||||
|
* @short_description: TODO
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
@ -30,28 +39,107 @@
|
||||||
#include "gst-validate-internal.h"
|
#include "gst-validate-internal.h"
|
||||||
#include "gst-validate-override.h"
|
#include "gst-validate-override.h"
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GstValidateOverride, gst_validate_override,
|
||||||
|
G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, NULL))
|
||||||
|
|
||||||
|
struct _GstValidateOverridePriv
|
||||||
|
{
|
||||||
|
GHashTable *level_override;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_FIRST_PROP = 1,
|
||||||
|
PROP_RUNNER,
|
||||||
|
PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
static void
|
||||||
|
_get_property (GObject * object,
|
||||||
|
guint property_id, GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
switch (property_id) {
|
||||||
|
case PROP_RUNNER:
|
||||||
|
g_value_set_object (value,
|
||||||
|
gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (object)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_set_property (GObject * object,
|
||||||
|
guint property_id, const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
switch (property_id) {
|
||||||
|
case PROP_RUNNER:
|
||||||
|
/* we assume the runner is valid as long as this scenario is,
|
||||||
|
* no ref taken */
|
||||||
|
gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (object),
|
||||||
|
g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_validate_override_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
GstValidateOverride *self = GST_VALIDATE_OVERRIDE (object);
|
||||||
|
|
||||||
|
void (*chain_up) (GObject *) =
|
||||||
|
((GObjectClass *) gst_validate_override_parent_class)->finalize;
|
||||||
|
|
||||||
|
g_hash_table_unref (self->priv->level_override);
|
||||||
|
|
||||||
|
chain_up (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_validate_override_class_init (GstValidateOverrideClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *oclass = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
oclass->finalize = gst_validate_override_finalize;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstValidateOverridePriv));
|
||||||
|
|
||||||
|
oclass->get_property = _get_property;
|
||||||
|
oclass->set_property = _set_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (oclass, PROP_RUNNER,
|
||||||
|
g_param_spec_object ("validate-runner", "VALIDATE Runner",
|
||||||
|
"The Validate runner to " "report errors to",
|
||||||
|
GST_TYPE_VALIDATE_RUNNER,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_validate_override_init (GstValidateOverride * self)
|
||||||
|
{
|
||||||
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||||
|
GST_TYPE_VALIDATE_OVERRIDE, GstValidateOverridePriv);
|
||||||
|
|
||||||
|
self->priv->level_override = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
}
|
||||||
|
|
||||||
GstValidateOverride *
|
GstValidateOverride *
|
||||||
gst_validate_override_new (void)
|
gst_validate_override_new (void)
|
||||||
{
|
{
|
||||||
GstValidateOverride *override = g_slice_new0 (GstValidateOverride);
|
return g_object_new (GST_TYPE_VALIDATE_OVERRIDE, NULL);
|
||||||
|
|
||||||
override->level_override = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
||||||
|
|
||||||
return override;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_validate_override_free (GstValidateOverride * override)
|
|
||||||
{
|
|
||||||
g_hash_table_unref (override->level_override);
|
|
||||||
g_slice_free (GstValidateOverride, override);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_validate_override_change_severity (GstValidateOverride * override,
|
gst_validate_override_change_severity (GstValidateOverride * override,
|
||||||
GstValidateIssueId issue_id, GstValidateReportLevel new_level)
|
GstValidateIssueId issue_id, GstValidateReportLevel new_level)
|
||||||
{
|
{
|
||||||
g_hash_table_insert (override->level_override, (gpointer) issue_id,
|
g_hash_table_insert (override->priv->level_override, (gpointer) issue_id,
|
||||||
(gpointer) new_level);
|
(gpointer) new_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +154,7 @@ gst_validate_override_get_severity (GstValidateOverride * override,
|
||||||
{
|
{
|
||||||
GstValidateReportLevel *level = NULL;
|
GstValidateReportLevel *level = NULL;
|
||||||
|
|
||||||
if (g_hash_table_lookup_extended (override->level_override,
|
if (g_hash_table_lookup_extended (override->priv->level_override,
|
||||||
(gpointer) issue_id, NULL, (gpointer) & level)) {
|
(gpointer) issue_id, NULL, (gpointer) & level)) {
|
||||||
|
|
||||||
return GPOINTER_TO_INT (level);
|
return GPOINTER_TO_INT (level);
|
||||||
|
|
|
@ -43,19 +43,43 @@ typedef void (*GstValidateOverrideGetCapsHandler)(GstValidateOverride * override
|
||||||
typedef void (*GstValidateOverrideSetCapsHandler)(GstValidateOverride * override,
|
typedef void (*GstValidateOverrideSetCapsHandler)(GstValidateOverride * override,
|
||||||
GstValidateMonitor * pad_monitor, GstCaps * caps);
|
GstValidateMonitor * pad_monitor, GstCaps * caps);
|
||||||
|
|
||||||
struct _GstValidateOverride {
|
typedef struct _GstValidateOverride GstValidateOverride;
|
||||||
GHashTable *level_override;
|
typedef struct _GstValidateOverrideClass GstValidateOverrideClass;
|
||||||
|
typedef struct _GstValidateOverridePriv GstValidateOverridePriv;
|
||||||
|
|
||||||
|
struct _GstValidateOverrideClass
|
||||||
|
{
|
||||||
|
/*<private>*/
|
||||||
|
GObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstValidateOverride
|
||||||
|
{
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
/* Pad handlers */
|
|
||||||
GstValidateOverrideBufferHandler buffer_handler;
|
GstValidateOverrideBufferHandler buffer_handler;
|
||||||
GstValidateOverrideEventHandler event_handler;
|
GstValidateOverrideEventHandler event_handler;
|
||||||
GstValidateOverrideQueryHandler query_handler;
|
GstValidateOverrideQueryHandler query_handler;
|
||||||
GstValidateOverrideBufferHandler buffer_probe_handler;
|
GstValidateOverrideBufferHandler buffer_probe_handler;
|
||||||
GstValidateOverrideGetCapsHandler getcaps_handler;
|
GstValidateOverrideGetCapsHandler getcaps_handler;
|
||||||
GstValidateOverrideSetCapsHandler setcaps_handler;
|
GstValidateOverrideSetCapsHandler setcaps_handler;
|
||||||
|
|
||||||
|
/*<private>*/
|
||||||
|
GstValidateOverridePriv *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GType gst_validate_override_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
/* TYPE MACROS */
|
||||||
|
#define GST_TYPE_VALIDATE_OVERRIDE (gst_validate_override_get_type ())
|
||||||
|
#define GST_VALIDATE_OVERRIDE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VALIDATE_OVERRIDE, GstValidateOverride))
|
||||||
|
#define GST_VALIDATE_OVERRIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VALIDATE_OVERRIDE, GstValidateOverrideClass))
|
||||||
|
#define GST_IS_VALIDATE_OVERRIDE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VALIDATE_OVERRIDE))
|
||||||
|
#define GST_IS_VALIDATE_OVERRIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VALIDATE_OVERRIDE))
|
||||||
|
#define GST_VALIDATE_OVERRIDE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VALIDATE_OVERRIDE, GstValidateOverrideClass))
|
||||||
|
|
||||||
GstValidateOverride * gst_validate_override_new (void);
|
GstValidateOverride * gst_validate_override_new (void);
|
||||||
|
|
||||||
void gst_validate_override_free (GstValidateOverride * override);
|
void gst_validate_override_free (GstValidateOverride * override);
|
||||||
void gst_validate_override_change_severity (GstValidateOverride * override, GstValidateIssueId issue_id, GstValidateReportLevel new_level);
|
void gst_validate_override_change_severity (GstValidateOverride * override, GstValidateIssueId issue_id, GstValidateReportLevel new_level);
|
||||||
GstValidateReportLevel gst_validate_override_get_severity (GstValidateOverride * override, GstValidateIssueId issue_id, GstValidateReportLevel default_level);
|
GstValidateReportLevel gst_validate_override_get_severity (GstValidateOverride * override, GstValidateIssueId issue_id, GstValidateReportLevel default_level);
|
||||||
|
@ -76,5 +100,4 @@ void gst_validate_override_set_setcaps_handler (GstValidateOverrid
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_VALIDATE_OVERRIDE_H__ */
|
#endif /* #ifndef __GST_VALIDATE_OVERRIDE_H__*/
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ gst_validate_report_valist (GstValidateReporter * reporter,
|
||||||
issue = gst_validate_issue_from_id (issue_id);
|
issue = gst_validate_issue_from_id (issue_id);
|
||||||
|
|
||||||
g_return_if_fail (issue != NULL);
|
g_return_if_fail (issue != NULL);
|
||||||
|
g_return_if_fail (GST_IS_VALIDATE_REPORTER (reporter));
|
||||||
|
|
||||||
G_VA_COPY (vacopy, var_args);
|
G_VA_COPY (vacopy, var_args);
|
||||||
message = g_strdup_vprintf (format, vacopy);
|
message = g_strdup_vprintf (format, vacopy);
|
||||||
|
|
Loading…
Reference in a new issue