| 1 | /* |
| 2 | * generate_plugin_module_defs_gst.cc |
| 3 | * |
| 4 | * Created on: Jul 30, 2015 |
| 5 | * Author: mkolny |
| 6 | */ |
| 7 | |
| 8 | #include <glibmm_generate_extra_defs/generate_extra_defs.h> |
| 9 | |
| 10 | #include <gst/gst.h> |
| 11 | |
| 12 | #include <iostream> |
| 13 | |
| 14 | static std::string |
| 15 | get_element_factory_defs(GstElementFactory *factory) |
| 16 | { |
| 17 | GType type = 0; |
| 18 | std::string result; |
| 19 | |
| 20 | GstPluginFeature* loaded_feature = gst_plugin_feature_load(GST_PLUGIN_FEATURE(factory)); |
| 21 | factory = GST_ELEMENT_FACTORY(loaded_feature); |
| 22 | type = gst_element_factory_get_element_type(factory); |
| 23 | result = get_defs(type, gtype_is_a_pointer); |
| 24 | g_object_unref(factory); |
| 25 | return result; |
| 26 | } |
| 27 | |
| 28 | |
| 29 | static gboolean |
| 30 | feature_filter (GstPluginFeature *feature, gpointer user_data) |
| 31 | { |
| 32 | GstPlugin *plugin = gst_plugin_feature_get_plugin (feature); |
| 33 | gchar *expected_source = reinterpret_cast<char*>(user_data); |
| 34 | |
| 35 | if (plugin == NULL) { |
| 36 | return FALSE; |
| 37 | } |
| 38 | |
| 39 | return g_strcmp0 (expected_source, gst_plugin_get_source (plugin)) == 0; |
| 40 | } |
| 41 | |
| 42 | int main (int argc, char** argv) |
| 43 | { |
| 44 | if (argc < 2) { |
| 45 | std::cerr << "Usage: " << argv[0] << " <source module>" << std::endl; |
| 46 | return -1; |
| 47 | } |
| 48 | |
| 49 | gst_init (&argc, &argv); |
| 50 | |
| 51 | GstRegistry *registry = gst_registry_get (); |
| 52 | |
| 53 | GList *features_list = gst_registry_feature_filter (registry, feature_filter, FALSE, argv[1]); |
| 54 | GList *l = features_list; |
| 55 | while (l) { |
| 56 | GstPluginFeature *feature = reinterpret_cast<GstPluginFeature*>(l->data); |
| 57 | |
| 58 | if (GST_IS_ELEMENT_FACTORY (feature)) { |
| 59 | std::cout << get_element_factory_defs (GST_ELEMENT_FACTORY_CAST (feature)) << std::endl; |
| 60 | } |
| 61 | l = l->next; |
| 62 | } |
| 63 | |
| 64 | gst_plugin_feature_list_free (features_list); |
| 65 | |
| 66 | |
| 67 | |
| 68 | } |