From 8eeaa1a95f9738db0a50b8d6649bd85c9ee5c9f0 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 13 Aug 2014 20:47:24 +0200 Subject: [PATCH] validate: Make GstValidateActionType a GstMiniObject and expose it in the API --- validate/gst/validate/gst-validate-scenario.c | 41 +++++++++++++++---- validate/gst/validate/gst-validate-scenario.h | 26 ++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 8fa70ae916..95d57d261e 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -63,14 +63,6 @@ static void gst_validate_scenario_dispose (GObject * object); static void gst_validate_scenario_finalize (GObject * object); static GRegex *clean_action_str; -typedef struct _GstValidateActionType -{ - GstValidateExecuteAction execute; - gchar **mandatory_fields; - gchar *description; - gboolean is_config; -} GstValidateActionType; - struct _GstValidateScenarioPrivate { GstValidateRunner *runner; @@ -185,6 +177,36 @@ gst_validate_action_new (void) return action; } +/* GstValidateActionType implementation */ +GType _gst_validate_action_type_type; +GST_DEFINE_MINI_OBJECT_TYPE (GstValidateActionType, gst_validate_action_type); +static GstValidateActionType *gst_validate_action_type_new (void); + +static void +_action_type_free (GstValidateActionType * type) +{ + g_strfreev (type->mandatory_fields); + g_free (type->description); +} + +static void +gst_validate_action_type_init (GstValidateActionType * type) +{ + gst_mini_object_init ((GstMiniObject *) type, 0, + _gst_validate_action_type_type, NULL, NULL, + (GstMiniObjectFreeFunction) _action_type_free); +} + +GstValidateActionType * +gst_validate_action_type_new (void) +{ + GstValidateActionType *type = g_slice_new0 (GstValidateActionType); + + gst_validate_action_type_init (type); + + return type; +} + static gboolean _set_variable_func (const gchar * name, double *value, gpointer user_data) { @@ -1827,7 +1849,7 @@ gst_validate_add_action_type (const gchar * type_name, GstValidateExecuteAction function, const gchar * const *mandatory_fields, const gchar * description, gboolean is_config) { - GstValidateActionType *type = g_slice_new0 (GstValidateActionType); + GstValidateActionType *type = gst_validate_action_type_new (); if (action_types_table == NULL) action_types_table = g_hash_table_new_full (g_str_hash, g_str_equal, @@ -1859,6 +1881,7 @@ init_scenarios (void) GST_DEBUG_FG_YELLOW, "Gst validate scenarios"); _gst_validate_action_type = gst_validate_action_get_type (); + _gst_validate_action_type_type = gst_validate_action_type_get_type (); clean_action_str = g_regex_new ("\\\\\n|#.*\n", G_REGEX_CASELESS, 0, NULL); gst_validate_add_action_type ("seek", _execute_seek, seek_mandatory_fields, diff --git a/validate/gst/validate/gst-validate-scenario.h b/validate/gst/validate/gst-validate-scenario.h index 7262ab3b75..46af719d80 100644 --- a/validate/gst/validate/gst-validate-scenario.h +++ b/validate/gst/validate/gst-validate-scenario.h @@ -40,10 +40,12 @@ typedef struct _GstValidateScenario GstValidateScenario; typedef struct _GstValidateScenarioClass GstValidateScenarioClass; typedef struct _GstValidateScenarioPrivate GstValidateScenarioPrivate; typedef struct _GstValidateAction GstValidateAction; +typedef struct _GstValidateActionType GstValidateActionType; typedef gboolean (*GstValidateExecuteAction) (GstValidateScenario * scenario, GstValidateAction * action); GST_EXPORT GType _gst_validate_action_type; +GST_EXPORT GType _gst_validate_action_type_type; struct _GstValidateAction { @@ -59,6 +61,30 @@ struct _GstValidateAction gpointer _gst_reserved[GST_PADDING_LARGE]; }; +#define GST_TYPE_VALIDATE_ACTION (gst_validate_action_get_type ()) +#define GST_IS_VALIDATE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VALIDATE_ACTION)) +GType gst_validate_action_get_type (void); + +struct _GstValidateActionType +{ + GstMiniObject mini_object; + + GstValidateExecuteAction execute; + + gchar **mandatory_fields; + gchar **option_fields; + + gchar *description; + gboolean is_config; + + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +#define GST_TYPE_VALIDATE_ACTION_TYPE (gst_validate_action_type_get_type ()) +#define GST_IS_VALIDATE_ACTION_TYPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VALIDATE_ACTION_TYPE)) +GType gst_validate_action_type_get_type (void); + + struct _GstValidateScenarioClass { GObjectClass parent_class; -- 2.34.1