| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
> |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifdef HAVE_CONFIG_H |
| 23 |
# include "config.h" |
| 24 |
#endif |
| 25 |
|
| 26 |
#include <gst/check/gstcheck.h> |
| 27 |
|
| 28 |
static GList *elements = NULL; |
| 29 |
|
| 30 |
static void |
| 31 |
setup (void) |
| 32 |
{ |
| 33 |
GList *features, *f; |
| 34 |
GList *plugins, *p; |
| 35 |
gchar **ignorelist = NULL; |
| 36 |
const gchar *INDEX_IGNORE_ELEMENTS = NULL; |
| 37 |
|
| 38 |
GST_DEBUG ("getting elements for package %s", PACKAGE); |
| 39 |
INDEX_IGNORE_ELEMENTS = g_getenv ("GST_INDEX_IGNORE_ELEMENTS"); |
| 40 |
if (!g_getenv ("GST_NO_INDEX_IGNORE_ELEMENTS") && INDEX_IGNORE_ELEMENTS) { |
| 41 |
GST_DEBUG ("Will ignore element factories: '%s'", INDEX_IGNORE_ELEMENTS); |
| 42 |
ignorelist = g_strsplit (INDEX_IGNORE_ELEMENTS, " ", 0); |
| 43 |
} |
| 44 |
|
| 45 |
plugins = gst_registry_get_plugin_list (gst_registry_get_default ()); |
| 46 |
|
| 47 |
for (p = plugins; p; p = p->next) { |
| 48 |
GstPlugin *plugin = p->data; |
| 49 |
|
| 50 |
if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0) |
| 51 |
continue; |
| 52 |
|
| 53 |
features = |
| 54 |
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), |
| 55 |
gst_plugin_get_name (plugin)); |
| 56 |
|
| 57 |
for (f = features; f; f = f->next) { |
| 58 |
GstPluginFeature *feature = f->data; |
| 59 |
const gchar *name = gst_plugin_feature_get_name (feature); |
| 60 |
gboolean ignore = FALSE; |
| 61 |
|
| 62 |
if (!GST_IS_ELEMENT_FACTORY (feature)) |
| 63 |
continue; |
| 64 |
|
| 65 |
if (ignorelist) { |
| 66 |
gchar **s; |
| 67 |
|
| 68 |
for (s = ignorelist; s && *s; ++s) { |
| 69 |
if (g_str_has_prefix (name, *s)) { |
| 70 |
GST_DEBUG ("ignoring element %s", name); |
| 71 |
ignore = TRUE; |
| 72 |
} |
| 73 |
} |
| 74 |
if (ignore) |
| 75 |
continue; |
| 76 |
} |
| 77 |
|
| 78 |
GST_DEBUG ("adding element %s", name); |
| 79 |
elements = g_list_prepend (elements, (gpointer) g_strdup (name)); |
| 80 |
} |
| 81 |
gst_plugin_feature_list_free (features); |
| 82 |
} |
| 83 |
gst_plugin_list_free (plugins); |
| 84 |
g_strfreev (ignorelist); |
| 85 |
} |
| 86 |
|
| 87 |
static void |
| 88 |
teardown (void) |
| 89 |
{ |
| 90 |
GList *e; |
| 91 |
|
| 92 |
for (e = elements; e; e = e->next) { |
| 93 |
g_free (e->data); |
| 94 |
} |
| 95 |
g_list_free (elements); |
| 96 |
elements = NULL; |
| 97 |
} |
| 98 |
|
| 99 |
GST_START_TEST (test_set_index) |
| 100 |
{ |
| 101 |
GstElement *element; |
| 102 |
GstIndex *idx; |
| 103 |
GList *e; |
| 104 |
|
| 105 |
idx = gst_index_factory_make ("memindex"); |
| 106 |
if (idx == NULL) |
| 107 |
return; |
| 108 |
|
| 109 |
gst_object_ref_sink (idx); |
| 110 |
|
| 111 |
for (e = elements; e; e = e->next) { |
| 112 |
const gchar *name = e->data; |
| 113 |
|
| 114 |
GST_INFO ("testing element %s", name); |
| 115 |
element = gst_element_factory_make (name, name); |
| 116 |
fail_if (element == NULL, "Could not make element from factory %s", name); |
| 117 |
|
| 118 |
gst_element_set_index (element, idx); |
| 119 |
gst_object_unref (element); |
| 120 |
} |
| 121 |
|
| 122 |
gst_object_unref (idx); |
| 123 |
} |
| 124 |
|
| 125 |
GST_END_TEST; |
| 126 |
|
| 127 |
static Suite * |
| 128 |
index_suite (void) |
| 129 |
{ |
| 130 |
Suite *s = suite_create ("index"); |
| 131 |
TCase *tc_chain = tcase_create ("general"); |
| 132 |
|
| 133 |
suite_add_tcase (s, tc_chain); |
| 134 |
tcase_add_checked_fixture (tc_chain, setup, teardown); |
| 135 |
tcase_add_test (tc_chain, test_set_index); |
| 136 |
|
| 137 |
return s; |
| 138 |
} |
| 139 |
|
| 140 |
GST_CHECK_MAIN (index); |