mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 04:58:47 +00:00
validate: Add a method to easily get plugin configuration
Reviewers: Mathieu_Du Differential Revision: http://phabricator.freedesktop.org/D77
This commit is contained in:
parent
4dce5054de
commit
5d7403a6a5
3 changed files with 43 additions and 12 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "../../validate/validate.h"
|
||||
#include "../../validate/gst-validate-scenario.h"
|
||||
#include "../../validate/gst-validate-utils.h"
|
||||
|
||||
|
@ -45,25 +46,22 @@ _execute_stop (GstValidateScenario * scenario, GstValidateAction * action)
|
|||
static gboolean
|
||||
gst_validate_gapplication_init (GstPlugin * plugin)
|
||||
{
|
||||
GList *structures, *tmp;
|
||||
const gchar *appname = NULL, *config = g_getenv ("GST_VALIDATE_CONFIG");
|
||||
GList *config, *tmp;
|
||||
const gchar *appname;
|
||||
|
||||
config = gst_validate_plugin_get_config (plugin);
|
||||
|
||||
if (!config)
|
||||
return TRUE;
|
||||
|
||||
structures = gst_validate_utils_structs_parse_from_filename (config);
|
||||
|
||||
if (!structures)
|
||||
return TRUE;
|
||||
|
||||
for (tmp = structures; tmp; tmp = tmp->next) {
|
||||
if (gst_structure_has_name (tmp->data, "gapplication"))
|
||||
appname = gst_structure_get_string (tmp->data, "application-name");
|
||||
for (tmp = config; tmp; tmp = tmp->next) {
|
||||
appname = gst_structure_get_string (tmp->data, "application-name");
|
||||
}
|
||||
g_list_free_full (structures, (GDestroyNotify) gst_structure_free);
|
||||
|
||||
if (appname && g_strcmp0 (g_get_prgname (), appname))
|
||||
if (appname && g_strcmp0 (g_get_prgname (), appname)) {
|
||||
GST_INFO_OBJECT (plugin, "App: %s is not %s", g_get_prgname (), appname);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gst_validate_register_action_type_dynamic (plugin, "stop",
|
||||
GST_RANK_PRIMARY, _execute_stop, NULL,
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "validate.h"
|
||||
#include "gst-validate-utils.h"
|
||||
#include "gst-validate-internal.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
@ -79,6 +80,37 @@ gst_validate_registry_get (void)
|
|||
return registry;
|
||||
}
|
||||
|
||||
#define GST_VALIDATE_PLUGIN_CONFIG "gst-validate-plugin-config"
|
||||
|
||||
static void
|
||||
_free_plugin_config (gpointer data)
|
||||
{
|
||||
g_list_free_full (data, (GDestroyNotify) gst_structure_free);
|
||||
}
|
||||
|
||||
GList *
|
||||
gst_validate_plugin_get_config (GstPlugin * plugin)
|
||||
{
|
||||
GList *structures = NULL, *tmp, *plugin_conf = NULL;
|
||||
const gchar *config = g_getenv ("GST_VALIDATE_CONFIG");
|
||||
|
||||
if ((plugin_conf =
|
||||
g_object_get_data (G_OBJECT (plugin), GST_VALIDATE_PLUGIN_CONFIG)))
|
||||
return plugin_conf;
|
||||
|
||||
if (config)
|
||||
structures = gst_validate_utils_structs_parse_from_filename (config);
|
||||
|
||||
for (tmp = structures; tmp; tmp = tmp->next) {
|
||||
if (gst_structure_has_name (tmp->data, gst_plugin_get_name (plugin)))
|
||||
plugin_conf = g_list_append (plugin_conf, tmp->data);
|
||||
}
|
||||
g_object_set_data_full (G_OBJECT (plugin), GST_VALIDATE_PLUGIN_CONFIG,
|
||||
plugin_conf, _free_plugin_config);
|
||||
|
||||
return plugin_conf;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_validate_init_plugins (void)
|
||||
{
|
||||
|
|
|
@ -16,5 +16,6 @@
|
|||
#include <gst/validate/gst-validate-media-info.h>
|
||||
|
||||
void gst_validate_init (void);
|
||||
GList * gst_validate_plugin_get_config (GstPlugin * plugin);
|
||||
|
||||
#endif /* _GST_VALIDATE_H */
|
||||
|
|
Loading…
Reference in a new issue