static void setup (void) { GList *features, *f; GList *plugins, *p; gchar **ignorelist = NULL; const gchar *STATE_IGNORE_ELEMENTS = NULL; GstRegistry *def; GST_DEBUG ("getting elements for package %s", PACKAGE); STATE_IGNORE_ELEMENTS = g_getenv ("GST_STATE_IGNORE_ELEMENTS"); if (!g_getenv ("GST_NO_STATE_IGNORE_ELEMENTS") && STATE_IGNORE_ELEMENTS) { GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS); ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0); } def = gst_registry_get (); plugins = gst_registry_get_plugin_list (def); for (p = plugins; p; p = p->next) { GstPlugin *plugin = p->data; if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0) continue; features = gst_registry_get_feature_list_by_plugin (def, gst_plugin_get_name (plugin)); for (f = features; f; f = f->next) { GstPluginFeature *feature = f->data; const gchar *name = gst_plugin_feature_get_name (feature); gboolean ignore = FALSE; if (!GST_IS_ELEMENT_FACTORY (feature)) continue; if (ignorelist) { gchar **s; for (s = ignorelist; s && *s; ++s) { if (g_str_has_prefix (name, *s)) { GST_DEBUG ("ignoring element %s", name); ignore = TRUE; } } if (ignore) continue; } GST_DEBUG ("adding element %s", name); elements = g_list_prepend (elements, (gpointer) g_strdup (name)); } gst_plugin_feature_list_free (features); } gst_plugin_list_free (plugins); g_strfreev (ignorelist); }
// // STARTUP /////////////////////////////////////////////////////////////////////////////// // (static) super-initialization - called once at application startup bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) { static bool done_init = false; if (!done_init) { // Init the glib type system - we need it. g_type_init(); set_gst_plugin_path(); // Protect against GStreamer resetting the locale, yuck. static std::string saved_locale; saved_locale = setlocale(LC_ALL, NULL); if (0 == gst_init_check(NULL, NULL, NULL)) { LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL; setlocale(LC_ALL, saved_locale.c_str() ); return false; } setlocale(LC_ALL, saved_locale.c_str() ); // Set up logging facilities gst_debug_remove_log_function( gst_debug_log_default ); gst_debug_add_log_function( gstreamer_log, NULL ); // Init our custom plugins - only really need do this once. gst_slvideo_init_class(); // List the plugins GStreamer can find LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; GList *list; GstRegistry *registry = gst_registry_get_default(); std::string loaded = ""; for (list = gst_registry_get_plugin_list(registry); list != NULL; list = g_list_next(list)) { GstPlugin *list_plugin = (GstPlugin *)list->data; (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No"; LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL; } gst_plugin_list_free(list); done_init = true; } return true; }
static void print_all_plugin_automatic_install_info (void) { GList *plugins, *orig_plugins; orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ()); while (plugins) { GstPlugin *plugin; plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); print_plugin_automatic_install_info (plugin); } gst_plugin_list_free (orig_plugins); }
void iterate_plugins (GHashTable *hashtable) { GList *plugins, *orig_plugins; orig_plugins = plugins = gst_default_registry_get_plugin_list (); while (plugins) { GList *features, *orig_features; GstPlugin *plugin; plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) { continue; } orig_features = features = gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), plugin->desc.name); while (features) { GstPluginFeature *feature; if (G_UNLIKELY (features->data == NULL)) goto next; feature = GST_PLUGIN_FEATURE (features->data); if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; factory = GST_ELEMENT_FACTORY (feature); iterate_plugins_elements (factory, hashtable); } next: features = g_list_next (features); } gst_plugin_feature_list_free (orig_features); } gst_plugin_list_free (orig_plugins); }
void test_registry_get_plugin_list() { GList *list; GstPlugin *plugin; //xmlfile = "test_registry_get_plugin_list"; std_log(LOG_FILENAME_LINE, "Test Started test_registry_get_plugin_list"); plugin = gst_default_registry_find_plugin ("coreelements"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in registry should be 2"); list = gst_registry_get_plugin_list (gst_registry_get_default ()); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3, "Refcount of plugin in registry+list should be 3"); gst_plugin_list_free (list); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in after list free should be 2"); gst_object_unref (plugin); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static void print_blacklist (void) { GList *plugins, *cur; gint count = 0; g_print ("%s\n", _("Blacklisted files:")); plugins = gst_registry_get_plugin_list (gst_registry_get ()); for (cur = plugins; cur != NULL; cur = g_list_next (cur)) { GstPlugin *plugin = (GstPlugin *) (cur->data); if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) { g_print (" %s\n", gst_plugin_get_name (plugin)); count++; } } g_print ("\n"); g_print (_("Total count: ")); g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count), count); g_print ("\n"); gst_plugin_list_free (plugins); }
static void print_blacklist (void) { GList *plugins, *cur; gint count = 0; g_print ("%s\n", _("Blacklisted files:")); plugins = gst_default_registry_get_plugin_list (); for (cur = plugins; cur != NULL; cur = g_list_next (cur)) { GstPlugin *plugin = (GstPlugin *) (cur->data); if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) { g_print (" %s\n", plugin->desc.name); count++; } } g_print ("\n"); g_print (_("Total count: ")); g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count), count); g_print ("\n"); gst_plugin_list_free (plugins); }
static void print_element_list (gboolean print_all) { int plugincount = 0, featurecount = 0, blacklistcount = 0; GList *plugins, *orig_plugins; orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ()); while (plugins) { GList *features, *orig_features; GstPlugin *plugin; plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); plugincount++; if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) { blacklistcount++; continue; } orig_features = features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), gst_plugin_get_name (plugin)); while (features) { GstPluginFeature *feature; if (G_UNLIKELY (features->data == NULL)) goto next; feature = GST_PLUGIN_FEATURE (features->data); featurecount++; if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; factory = GST_ELEMENT_FACTORY (feature); if (print_all) print_element_info (factory, TRUE); else g_print ("%s: %s: %s\n", gst_plugin_get_name (plugin), GST_OBJECT_NAME (factory), gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME)); } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; const gchar *const *extensions; factory = GST_TYPE_FIND_FACTORY (feature); if (!print_all) g_print ("%s: %s: ", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); extensions = gst_type_find_factory_get_extensions (factory); if (extensions != NULL) { guint i = 0; while (extensions[i]) { if (!print_all) g_print ("%s%s", i > 0 ? ", " : "", extensions[i]); i++; } if (!print_all) g_print ("\n"); } else { if (!print_all) g_print ("no extensions\n"); } } else { if (!print_all) n_print ("%s: %s (%s)\n", gst_plugin_get_name (plugin), GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature))); } next: features = g_list_next (features); } gst_plugin_feature_list_free (orig_features); } gst_plugin_list_free (orig_plugins); g_print ("\n"); g_print (_("Total count: ")); g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount); if (blacklistcount) { g_print (" ("); g_print (ngettext ("%d blacklist entry", "%d blacklist entries", blacklistcount), blacklistcount); g_print (" not shown)"); } g_print (", "); g_print (ngettext ("%d feature", "%d features", featurecount), featurecount); g_print ("\n"); }
static void print_all_uri_handlers (void) { GList *plugins, *p, *features, *f; plugins = gst_registry_get_plugin_list (gst_registry_get ()); for (p = plugins; p; p = p->next) { GstPlugin *plugin = (GstPlugin *) (p->data); features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), gst_plugin_get_name (plugin)); for (f = features; f; f = f->next) { GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data); if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; GstElement *element; factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature)); if (!factory) { g_print ("element plugin %s couldn't be loaded\n", gst_plugin_get_name (plugin)); continue; } element = gst_element_factory_create (factory, NULL); if (!element) { g_print ("couldn't construct element for %s for some reason\n", GST_OBJECT_NAME (factory)); gst_object_unref (factory); continue; } if (GST_IS_URI_HANDLER (element)) { const gchar *const *uri_protocols; const gchar *dir; gchar *joined; switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) { case GST_URI_SRC: dir = "read"; break; case GST_URI_SINK: dir = "write"; break; default: dir = "unknown"; break; } uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element)); joined = g_strjoinv (", ", (gchar **) uri_protocols); g_print ("%s (%s, rank %u): %s\n", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir, gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)), joined); g_free (joined); } gst_object_unref (element); gst_object_unref (factory); } } gst_plugin_feature_list_free (features); } gst_plugin_list_free (plugins); }
//static bool MediaPluginGStreamer010::startup() { // first - check if GStreamer is explicitly disabled if (NULL != getenv("LL_DISABLE_GSTREAMER")) return false; // only do global GStreamer initialization once. if (!mDoneInit) { g_thread_init(NULL); // Init the glib type system - we need it. g_type_init(); set_gst_plugin_path(); /* // Get symbols! #if LL_DARWIN if (! grab_gst_syms("libgstreamer-0.10.dylib", "libgstvideo-0.10.dylib") ) #elseif LL_WINDOWS if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll") ) #else // linux or other ELFy unixoid if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0") ) #endif { writeToLog("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled."); return false; } */ // if (gst_segtrap_set_enabled) // { gst_segtrap_set_enabled(FALSE); // } // else // { // writeToLog("gst_segtrap_set_enabled() is not available; plugin crashes won't be caught."); // } /* #if LL_LINUX // Gstreamer tries a fork during init, waitpid-ing on it, // which conflicts with any installed SIGCHLD handler... struct sigaction tmpact, oldact; if (gst_registry_fork_set_enabled) { // if we can disable SIGCHLD-using forking behaviour, // do it. gst_registry_fork_set_enabled(false); } else { // else temporarily install default SIGCHLD handler // while GStreamer initialises tmpact.sa_handler = SIG_DFL; sigemptyset( &tmpact.sa_mask ); tmpact.sa_flags = SA_SIGINFO; sigaction(SIGCHLD, &tmpact, &oldact); } #endif // LL_LINUX */ // Protect against GStreamer resetting the locale, yuck. static std::string saved_locale; saved_locale = setlocale(LC_ALL, NULL); // finally, try to initialize GStreamer! GError *err = NULL; gboolean init_gst_success = gst_init_check(NULL, NULL, &err); // restore old locale setlocale(LC_ALL, saved_locale.c_str() ); /* #if LL_LINUX // restore old SIGCHLD handler if (!gst_registry_fork_set_enabled) sigaction(SIGCHLD, &oldact, NULL); #endif // LL_LINUX */ if (!init_gst_success) // fail { if (err) { writeToLog("GST init failed: %s", err->message); g_error_free(err); } else { writeToLog("GST init failed for unspecified reason."); } return false; } // Set up logging facilities gst_debug_remove_log_function( gst_debug_log_default ); // gst_debug_add_log_function( gstreamer_log, NULL ); // Init our custom plugins - only really need do this once. gst_slvideo_init_class(); // List the plugins GStreamer can find writeToLog("Found GStreamer plugins:"); GList *list; GstRegistry *registry = gst_registry_get_default(); std::string loaded = "No"; for (list = gst_registry_get_plugin_list(registry); list != NULL; list = g_list_next(list)) { GstPlugin *list_plugin = (GstPlugin *)list->data; if (gst_plugin_is_loaded(list_plugin)) loaded = "Yes"; writeToLog("%s, loaded? %s", gst_plugin_get_name(list_plugin), loaded.c_str()); } gst_plugin_list_free(list); mDoneInit = true; } return true; }
static void print_element_list (gboolean print_all) { int plugincount = 0, featurecount = 0; GList *plugins, *orig_plugins; orig_plugins = plugins = gst_default_registry_get_plugin_list (); while (plugins) { GList *features, *orig_features; GstPlugin *plugin; plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); plugincount++; orig_features = features = gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), plugin->desc.name); while (features) { GstPluginFeature *feature; feature = GST_PLUGIN_FEATURE (features->data); featurecount++; if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; factory = GST_ELEMENT_FACTORY (feature); if (print_all) print_element_info (factory, TRUE); else g_print ("%s: %s: %s\n", plugin->desc.name, GST_PLUGIN_FEATURE_NAME (factory), gst_element_factory_get_longname (factory)); } else if (GST_IS_INDEX_FACTORY (feature)) { GstIndexFactory *factory; factory = GST_INDEX_FACTORY (feature); if (!print_all) g_print ("%s: %s: %s\n", plugin->desc.name, GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; factory = GST_TYPE_FIND_FACTORY (feature); if (!print_all) g_print ("%s: %s: ", plugin->desc.name, gst_plugin_feature_get_name (feature)); if (factory->extensions) { guint i = 0; while (factory->extensions[i]) { if (!print_all) g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); i++; } if (!print_all) g_print ("\n"); } else { if (!print_all) g_print ("no extensions\n"); } } else { if (!print_all) n_print ("%s: %s (%s)\n", plugin->desc.name, GST_PLUGIN_FEATURE_NAME (feature), g_type_name (G_OBJECT_TYPE (feature))); } features = g_list_next (features); } gst_plugin_feature_list_free (orig_features); } gst_plugin_list_free (orig_plugins); g_print ("\n"); g_print (_("Total count: ")); g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount); g_print (", "); g_print (ngettext ("%d feature", "%d features", featurecount), featurecount); g_print ("\n"); }