static void setup () { GList *features, *f; GList *plugins, *p; gchar **ignorelist = NULL; const gchar *STATE_IGNORE_ELEMENTS = NULL; GST_DEBUG ("getting elements for package %s", PACKAGE); STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS"); if (STATE_IGNORE_ELEMENTS) { GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS); ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0); } plugins = gst_registry_get_plugin_list (gst_registry_get_default ()); 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 (gst_registry_get_default (), 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); }
static void print_plugin_automatic_install_info (GstPlugin * plugin) { const gchar *plugin_name; GList *features, *l; plugin_name = gst_plugin_get_name (plugin); /* not interested in typefind factories, only element factories */ features = gst_registry_get_feature_list (gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); for (l = features; l != NULL; l = l->next) { GstPluginFeature *feature; feature = GST_PLUGIN_FEATURE (l->data); /* only interested in the ones that are in the plugin we just loaded */ if (g_str_equal (plugin_name, feature->plugin_name)) { GstElementFactory *factory; g_print ("element-%s\n", gst_plugin_feature_get_name (feature)); factory = GST_ELEMENT_FACTORY (feature); print_plugin_automatic_install_info_protocols (factory); print_plugin_automatic_install_info_codecs (factory); } } g_list_foreach (features, (GFunc) gst_object_unref, NULL); g_list_free (features); }
/** * gst_plugin_load_by_name: * @name: name of plugin to load * * Load the named plugin. Refs the plugin. * * Returns: A reference to a loaded plugin, or NULL on error. */ GstPlugin * gst_plugin_load_by_name (const gchar * name) { GstPlugin *plugin, *newplugin; GError *error = NULL; GST_DEBUG ("looking up plugin %s in default registry", name); plugin = gst_registry_find_plugin (gst_registry_get_default (), name); if (plugin) { GST_DEBUG ("loading plugin %s from file %s", name, plugin->filename); newplugin = gst_plugin_load_file (plugin->filename, &error); gst_object_unref (plugin); if (!newplugin) { GST_WARNING ("load_plugin error: %s", error->message); g_error_free (error); return NULL; } /* newplugin was reffed by load_file */ return newplugin; } GST_DEBUG ("Could not find plugin %s in registry", name); return NULL; }
void test_registry() { GList *g; GstRegistry *registry; //xmlfile = "test_registry"; std_log(LOG_FILENAME_LINE, "Test Started test_registry"); registry = gst_registry_get_default (); for (g = registry->plugins; g; g = g->next) { GstPlugin *plugin = GST_PLUGIN (g->data); ASSERT_OBJECT_REFCOUNT (plugin, "plugin in registry", 1); GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (plugin), plugin->desc.name); } for (g = registry->features; g; g = g->next) { GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data); fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 1, "Feature in registry should have refcount of 1"); GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (feature), feature->name); } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
GstElement* rygel_gst_utils_get_rtp_depayloader (GstCaps* caps) { #line 172 "rygel-gst-utils.c" GstElement* result = NULL; GstRegistry* registry; GList* features; #line 50 "rygel-gst-utils.vala" g_return_val_if_fail (caps != NULL, NULL); #line 51 "rygel-gst-utils.vala" if (!rygel_gst_utils_need_rtp_depayloader (caps)) { #line 180 "rygel-gst-utils.c" result = NULL; #line 52 "rygel-gst-utils.vala" return result; #line 184 "rygel-gst-utils.c" } #line 55 "rygel-gst-utils.vala" registry = gst_registry_get_default (); #line 56 "rygel-gst-utils.vala" features = gst_registry_feature_filter (registry, _rygel_gst_utils_rtp_depay_filter_gst_plugin_feature_filter, FALSE, NULL); #line 190 "rygel-gst-utils.c" result = rygel_gst_utils_get_best_depay (features, caps); __g_list_free_gst_object_unref0 (features); #line 58 "rygel-gst-utils.vala" return result; #line 195 "rygel-gst-utils.c" }
int main (int argc, char *argv[]) { GstElementFactory *factory; GOptionEntry options[] = { GST_TOOLS_GOPTION_VERSION, {NULL} }; GOptionContext *ctx; GError *err = NULL; setlocale (LC_ALL, ""); #if !GLIB_CHECK_VERSION (2, 31, 0) g_thread_init (NULL); #endif gst_tools_set_prgname ("gst-xmlinspect"); ctx = g_option_context_new ("[ELEMENT-NAME]"); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", err->message); exit (1); } g_option_context_free (ctx); gst_tools_print_version ("gst-xmlinspect"); /* if no arguments, print out all elements */ if (argc == 1) { GList *features, *f; features = gst_registry_get_feature_list (gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); for (f = features; f != NULL; f = f->next) print_element_info (GST_ELEMENT_FACTORY (f->data)); gst_plugin_feature_list_free (features); return 0; } /* else we try to get a factory */ factory = gst_element_factory_find (argv[1]); /* if there's a factory, print out the info */ if (factory) { PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); return print_element_info (factory); } /* otherwise, error out */ g_printerr ("no such element '%s'\n", argv[1]); return -1; }
static int print_element_info (GstElementFactory * factory, gboolean print_names) { GstElement *element; gint maxlevel = 0; factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory))); if (!factory) { g_print ("element plugin couldn't be loaded\n"); return -1; } element = gst_element_factory_create (factory, NULL); if (!element) { g_print ("couldn't construct element for some reason\n"); return -1; } if (print_names) _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name); else _name = NULL; print_factory_details_info (factory); if (GST_PLUGIN_FEATURE (factory)->plugin_name) { GstPlugin *plugin; plugin = gst_registry_find_plugin (gst_registry_get_default (), GST_PLUGIN_FEATURE (factory)->plugin_name); if (plugin) { print_plugin_info (plugin); } } print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); print_interfaces (G_OBJECT_TYPE (element)); print_pad_templates_info (element, factory); print_element_flag_info (element); print_implementation_info (element); print_clocking_info (element); print_index_info (element); print_uri_handler_info (element); print_pad_info (element); print_element_properties_info (element); print_signal_info (element); print_children_info (element); gst_object_unref (element); gst_object_unref (factory); g_free (_name); return 0; }
void gst_rtsp_ext_list_init (void) { GST_DEBUG_CATEGORY_INIT (rtspext_debug, "rtspext", 0, "RTSP extension"); /* get a list of all extensions */ extensions = gst_registry_feature_filter (gst_registry_get_default (), (GstPluginFeatureFilter) gst_rtsp_ext_list_filter, FALSE, NULL); }
EXPORT_C #endif GstPluginFeature * gst_plugin_feature_load (GstPluginFeature * feature) { GstPlugin *plugin; GstPluginFeature *real_feature; g_return_val_if_fail (feature != NULL, FALSE); g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE); GST_DEBUG ("loading plugin for feature %p; '%s'", feature, GST_PLUGIN_FEATURE_NAME (feature)); if (feature->loaded) return gst_object_ref (feature); GST_DEBUG ("loading plugin %s", feature->plugin_name); plugin = gst_plugin_load_by_name (feature->plugin_name); if (!plugin) goto load_failed; GST_DEBUG ("loaded plugin %s", feature->plugin_name); gst_object_unref (plugin); real_feature = gst_registry_lookup_feature (gst_registry_get_default (), feature->name); if (real_feature == NULL) goto disappeared; else if (!real_feature->loaded) goto not_found; return real_feature; /* ERRORS */ load_failed: { GST_WARNING ("Failed to load plugin containing feature '%s'.", GST_PLUGIN_FEATURE_NAME (feature)); return NULL; } disappeared: { GST_INFO ("Loaded plugin containing feature '%s', but feature disappeared.", feature->name); return NULL; } not_found: { GST_INFO ("Tried to load plugin containing feature '%s', but feature was " "not found.", real_feature->name); return NULL; } }
EXPORT_C #endif gboolean gst_plugin_feature_check_version (GstPluginFeature * feature, guint min_major, guint min_minor, guint min_micro) { GstRegistry *registry; GstPlugin *plugin; gboolean ret = FALSE; g_return_val_if_fail (feature != NULL, FALSE); g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE); GST_DEBUG ("Looking up plugin '%s' containing plugin feature '%s'", feature->plugin_name, feature->name); registry = gst_registry_get_default (); plugin = gst_registry_find_plugin (registry, feature->plugin_name); if (plugin) { const gchar *ver_str; guint major, minor, micro; ver_str = gst_plugin_get_version (plugin); g_return_val_if_fail (ver_str != NULL, FALSE); if (sscanf (ver_str, "%u.%u.%u", &major, &minor, µ) == 3) { if (major > min_major) ret = TRUE; else if (major < min_major) ret = FALSE; else if (minor > min_minor) ret = TRUE; else if (minor < min_minor) ret = FALSE; else if (micro > min_micro) ret = TRUE; else ret = (micro == min_micro); GST_DEBUG ("Checking whether %u.%u.%u >= %u.%u.%u? %s", major, minor, micro, min_major, min_minor, min_micro, (ret) ? "yes" : "no"); } else { GST_WARNING ("Could not parse version string '%s' of plugin '%s'", ver_str, feature->plugin_name); } gst_object_unref (plugin); } else { GST_DEBUG ("Could not find plugin '%s'", feature->plugin_name); } return ret; }
static void init_factories (void) { /* first filter out the interesting element factories */ factories = gst_registry_feature_filter ( gst_registry_get_default (), (GstPluginFeatureFilter) cb_feature_filter, FALSE, NULL); /* sort them according to their ranks */ factories = g_list_sort (factories, (GCompareFunc) cb_compare_ranks); }
void test_typefind() { GstPlugin *plugin; GstPluginFeature *feature; GstTypeFind typefind = { peek, suggest, NULL, NULL, GST_PADDING_INIT }; //xmlfile = "test_typefind"; std_log(LOG_FILENAME_LINE, "Test Started test_typefind"); plugin = gst_default_registry_find_plugin ("typefindfunctions"); fail_if (plugin == NULL, "Failed to find typefind functions"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in registry should be 2"); /* //commented fail_if (gst_plugin_is_loaded (plugin), "Expected plugin to be unloaded"); */ feature = gst_registry_find_feature (gst_registry_get_default (), "audio/x-au", GST_TYPE_TYPE_FIND_FACTORY); fail_if (feature == NULL, "Failed to find audio/x-aw typefind factory"); #ifndef __SYMBIAN32__ fail_if (feature->plugin != plugin, "Expected identity to be from coreelements plugin"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3, "Refcount of plugin in registry+feature should be 3"); gst_type_find_factory_call_function (GST_TYPE_FIND_FACTORY (feature), &typefind); gst_object_unref (feature->plugin); #endif gst_object_unref (plugin); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1, "Refcount of plugin in after list free should be 1"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
// // 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; }
/*** * !reimp */ QStringList Backend::availableMimeTypes() const { QStringList availableMimeTypes; if (!isValid()) return availableMimeTypes; GstElementFactory *mpegFactory; // Add mp3 as a separate mime type as people are likely to look for it. if ((mpegFactory = gst_element_factory_find ("ffmpeg")) || (mpegFactory = gst_element_factory_find ("mad"))) { availableMimeTypes << QLatin1String("audio/x-mp3"); gst_object_unref(GST_OBJECT(mpegFactory)); } // Iterate over all audio and video decoders and extract mime types from sink caps GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); if (klass == QLatin1String("Codec/Decoder/Audio") || klass == QLatin1String("Codec/Decoder/Video")) { const GList *static_templates; GstElementFactory *factory = GST_ELEMENT_FACTORY(feature); static_templates = gst_element_factory_get_static_pad_templates(factory); for (; static_templates != NULL ; static_templates = static_templates->next) { GstStaticPadTemplate *padTemplate = (GstStaticPadTemplate *) static_templates->data; if (padTemplate && padTemplate->direction == GST_PAD_SINK) { GstCaps *caps = gst_static_pad_template_get_caps (padTemplate); if (caps) { const GstStructure* capsStruct = gst_caps_get_structure (caps, 0); QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct)); if (!availableMimeTypes.contains(mime)) availableMimeTypes.append(mime); } } } } } g_list_free(factoryList); availableMimeTypes.sort(); return availableMimeTypes; }
EffectManager::EffectManager(Backend *backend) : QObject(backend) , m_backend(backend) { GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); QString name, klass, description, author; for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); if ( klass == "Filter/Effect/Audio" ) { name = GST_PLUGIN_FEATURE_NAME(feature); // These plugins simply make no sense to the frontend: // "audiorate" Should be internal // "volume" not needed // "equalizer-nbands" not really useful at the moment // These plugins simply don't work or have major stability issues: // "iir" Does not seem to do much at the moment // "audioinvert" Only works for some streams, should be invesigated // "lpwsinc" Crashes for large values of filter kernel // "name" Crashes for large values of filter kernel // Seems to be working, but not well tested: // name == "rglimiter" Seems functional // name == "rgvolume" Seems to be working QString pluginString = qgetenv("PHONON_GST_ALL_EFFECTS"); bool acceptAll = pluginString.toInt(); if (acceptAll // Plugins that have been accepted so far || name == "audiopanorama" || name == "audioamplify" || name == "audiodynamic" || name == "equalizer-10bands" || name == "speed") { description = gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature)); author = gst_element_factory_get_author (GST_ELEMENT_FACTORY(feature)); EffectInfo *effect = new EffectInfo(name, description, author); m_audioEffectList.append(effect); } } } g_list_free(factoryList); }
void GstVideoPlayerBackend::enableFactory(const gchar *name, gboolean enable) { GstRegistry *registry = gst_registry_get_default(); if (!registry) return; GstElementFactory *factory = gst_element_factory_find(name); if (!factory) return; if (enable) gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE(factory), GST_RANK_PRIMARY + 1); else gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE(factory), GST_RANK_NONE); gst_registry_add_feature(registry, GST_PLUGIN_FEATURE(factory)); }
/** * gst_element_factory_find: * @name: name of factory to find * * Search for an element factory of the given name. Refs the returned * element factory; caller is responsible for unreffing. * * Returns: (transfer full): #GstElementFactory if found, NULL otherwise */ GstElementFactory * gst_element_factory_find (const gchar * name) { GstPluginFeature *feature; g_return_val_if_fail (name != NULL, NULL); feature = gst_registry_find_feature (gst_registry_get_default (), name, GST_TYPE_ELEMENT_FACTORY); if (feature) return GST_ELEMENT_FACTORY (feature); /* this isn't an error, for instance when you query if an element factory is * present */ GST_LOG ("no such element factory \"%s\"", name); return NULL; }
void test_find_feature() { GstPluginFeature *feature; //xmlfile = "test_find_feature"; std_log(LOG_FILENAME_LINE, "Test Started test_find_feature"); feature = gst_registry_find_feature (gst_registry_get_default (), "identity", GST_TYPE_ELEMENT_FACTORY); fail_if (feature == NULL, "Failed to find identity element factory"); fail_if (strcmp (feature->plugin_name, "coreelements"), "Expected identity to be from coreelements plugin"); fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 2, "Refcount of feature should be 2"); GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (feature)); gst_object_unref (feature); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
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_find_plugin() { GstPlugin *plugin; //xmlfile = "test_find_plugin"; std_log(LOG_FILENAME_LINE, "Test Started test_find_plugin"); plugin = gst_registry_find_plugin (gst_registry_get_default (), "coreelements"); fail_if (plugin == NULL, "Failed to find coreelements plugin"); ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 2); fail_unless_equals_string (plugin->desc.version, VERSION); fail_unless_equals_string (plugin->desc.license, "LGPL"); fail_unless_equals_string (plugin->desc.source, "gstreamer"); fail_unless_equals_string (plugin->desc.package, GST_PACKAGE_NAME); fail_unless_equals_string (plugin->desc.origin, GST_PACKAGE_ORIGIN); gst_object_unref (plugin); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
EXPORT_C #endif GList * gst_audio_default_registry_mixer_filter (GstAudioMixerFilterFunc filter_func, gboolean first, gpointer data) { GList *mixer_list = NULL; GList *feature_list; GList *walk; /* go through all elements of a certain class and check whether * they implement a mixer. If so, add it to the list. */ feature_list = gst_registry_get_feature_list (gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); feature_list = g_list_sort (feature_list, element_factory_rank_compare_func); for (walk = feature_list; walk != NULL; walk = walk->next) { GstElementFactory *factory; const gchar *klass; factory = GST_ELEMENT_FACTORY (walk->data); /* check category */ klass = gst_element_factory_get_klass (factory); if (strcmp (klass, "Generic/Audio") == 0) { gst_audio_mixer_filter_probe_feature (filter_func, factory, &mixer_list, first, data); } if (first && mixer_list != NULL) { GST_DEBUG ("Stopping after first found mixer, as requested"); break; } } gst_plugin_feature_list_free (feature_list); return g_list_reverse (mixer_list); }
gboolean gst_mem_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; factory = gst_index_factory_new ("memindex", "A index that stores entries in memory", gst_mem_index_get_type ()); if (factory == NULL) { g_warning ("failed to create memindex factory"); return FALSE; } GST_PLUGIN_FEATURE (factory)->plugin_name = plugin->desc.name; GST_PLUGIN_FEATURE (factory)->loaded = TRUE; gst_registry_add_feature (gst_registry_get_default (), GST_PLUGIN_FEATURE (factory)); return TRUE; }
gboolean gst_file_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; factory = gst_index_factory_new ("fileindex", "A index that stores entries in file", gst_file_index_get_type ()); if (factory == NULL) { return FALSE; } GST_PLUGIN_FEATURE (factory)->plugin_name = plugin->desc.name; GST_PLUGIN_FEATURE (factory)->loaded = TRUE; gst_registry_add_feature (gst_registry_get_default (), GST_PLUGIN_FEATURE (factory)); GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL); return TRUE; }
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 gst_plugin_finalize (GObject * object) { GstPlugin *plugin = GST_PLUGIN_CAST (object); GstRegistry *registry = gst_registry_get_default (); GList *g; GST_DEBUG ("finalizing plugin %p", plugin); for (g = registry->plugins; g; g = g->next) { if (g->data == (gpointer) plugin) { g_warning ("removing plugin that is still in registry"); } } g_free (plugin->filename); g_free (plugin->basename); gst_plugin_desc_free (&plugin->desc); g_list_foreach (plugin->priv->deps, (GFunc) gst_plugin_ext_dep_free, NULL); g_list_free (plugin->priv->deps); plugin->priv->deps = NULL; G_OBJECT_CLASS (gst_plugin_parent_class)->finalize (object); }
static VALUE rb_gst_registry_get_default(VALUE self) { return RGST_REGISTRY_NEW(gst_registry_get_default()); }
static gboolean do_plugin_load (GstPluginLoader * l, const gchar * filename, guint tag) { GstPlugin *newplugin; GList *chunks = NULL; GST_DEBUG ("Plugin scanner loading file %s. tag %u", filename, tag); #if 0 /* Test code - crash based on filename */ if (strstr (filename, "coreelements") == NULL) { g_printerr ("Crashing on file %s\n", filename); g_printerr ("%d", *(gint *) (NULL)); } #endif newplugin = gst_plugin_load_file ((gchar *) filename, NULL); if (newplugin) { guint hdr_pos; guint offset; /* Now serialise the plugin details and send */ if (!_priv_gst_registry_chunks_save_plugin (&chunks, gst_registry_get_default (), newplugin)) goto fail; /* Store where the header is, write an empty one, then write * all the payload chunks, then fix up the header size */ hdr_pos = l->tx_buf_write; offset = HEADER_SIZE; put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0); if (chunks) { GList *walk; for (walk = chunks; walk; walk = g_list_next (walk)) { GstRegistryChunk *cur = walk->data; put_chunk (l, cur, &offset); _priv_gst_registry_chunk_free (cur); } g_list_free (chunks); /* Store the size of the written payload */ GST_WRITE_UINT32_BE (l->tx_buf + hdr_pos + 4, offset - HEADER_SIZE); } #if 0 /* Test code - corrupt the tx buffer based on filename */ if (strstr (filename, "sink") != NULL) { int fd, res; g_printerr ("Corrupting tx buf on file %s\n", filename); fd = open ("/dev/urandom", O_RDONLY); res = read (fd, l->tx_buf, l->tx_buf_size); close (fd); } #endif gst_object_unref (newplugin); } else { put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0); } return TRUE; fail: put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0); if (chunks) { GList *walk; for (walk = chunks; walk; walk = g_list_next (walk)) { GstRegistryChunk *cur = walk->data; _priv_gst_registry_chunk_free (cur); } g_list_free (chunks); } return FALSE; }
static GstElement * gst_auto_video_src_find_best (GstAutoVideoSrc * src) { GList *list, *item; GstElement *choice = NULL; GstMessage *message = NULL; GSList *errors = NULL; GstBus *bus = gst_bus_new (); GstPad *el_pad = NULL; GstCaps *el_caps = NULL, *intersect = NULL; gboolean no_match = TRUE; list = gst_registry_feature_filter (gst_registry_get_default (), (GstPluginFeatureFilter) gst_auto_video_src_factory_filter, FALSE, src); list = g_list_sort (list, (GCompareFunc) gst_auto_video_src_compare_ranks); GST_LOG_OBJECT (src, "Trying to find usable video devices ..."); for (item = list; item != NULL; item = item->next) { GstElementFactory *f = GST_ELEMENT_FACTORY (item->data); GstElement *el; if ((el = gst_auto_video_src_create_element_with_pretty_name (src, f))) { GstStateChangeReturn ret; GST_DEBUG_OBJECT (src, "Testing %s", GST_PLUGIN_FEATURE (f)->name); /* If AutoVideoSrc has been provided with filter caps, * accept only sources that match with the filter caps */ if (src->filter_caps) { el_pad = gst_element_get_static_pad (GST_ELEMENT (el), "src"); el_caps = gst_pad_get_caps (el_pad); gst_object_unref (el_pad); GST_DEBUG_OBJECT (src, "Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT, src->filter_caps, el_caps); intersect = gst_caps_intersect (src->filter_caps, el_caps); no_match = gst_caps_is_empty (intersect); gst_caps_unref (el_caps); gst_caps_unref (intersect); if (no_match) { GST_DEBUG_OBJECT (src, "Incompatible caps"); gst_object_unref (el); continue; } else { GST_DEBUG_OBJECT (src, "Found compatible caps"); } } gst_element_set_bus (el, bus); ret = gst_element_set_state (el, GST_STATE_READY); if (ret == GST_STATE_CHANGE_SUCCESS) { GST_DEBUG_OBJECT (src, "This worked!"); choice = el; break; } /* collect all error messages */ while ((message = gst_bus_pop_filtered (bus, GST_MESSAGE_ERROR))) { GST_DEBUG_OBJECT (src, "error message %" GST_PTR_FORMAT, message); errors = g_slist_append (errors, message); } gst_element_set_state (el, GST_STATE_NULL); gst_object_unref (el); } } GST_DEBUG_OBJECT (src, "done trying"); if (!choice) { if (errors) { /* FIXME: we forward the first error for now; but later on it might make * sense to actually analyse them */ gst_message_ref (GST_MESSAGE (errors->data)); GST_DEBUG_OBJECT (src, "reposting message %p", errors->data); gst_element_post_message (GST_ELEMENT (src), GST_MESSAGE (errors->data)); } else { /* send warning message to application and use a fakesrc */ GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL), ("Failed to find a usable video source")); choice = gst_element_factory_make ("fakesrc", "fake-video-src"); if (g_object_class_find_property (G_OBJECT_GET_CLASS (choice), "sync")) g_object_set (choice, "sync", TRUE, NULL); gst_element_set_state (choice, GST_STATE_READY); } } gst_object_unref (bus); gst_plugin_feature_list_free (list); g_slist_foreach (errors, (GFunc) gst_mini_object_unref, NULL); g_slist_free (errors); return choice; }
/** * gst_element_register: * @plugin: (allow-none): #GstPlugin to register the element with, or NULL for * a static element (note that passing NULL only works in GStreamer 0.10.13 * and later) * @name: name of elements of this type * @rank: rank of element (higher rank means more importance when autoplugging) * @type: GType of element to register * * Create a new elementfactory capable of instantiating objects of the * @type and add the factory to @plugin. * * Returns: TRUE, if the registering succeeded, FALSE on error */ gboolean gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, GType type) { GstPluginFeature *existing_feature; GstRegistry *registry; GstElementFactory *factory; GType *interfaces; guint n_interfaces, i; GstElementClass *klass; GList *item; g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (g_type_is_a (type, GST_TYPE_ELEMENT), FALSE); registry = gst_registry_get_default (); /* check if feature already exists, if it exists there is no need to update it * when the registry is getting updated, outdated plugins and all their * features are removed and readded. */ existing_feature = gst_registry_lookup_feature (registry, name); if (existing_feature) { GST_DEBUG_OBJECT (registry, "update existing feature %p (%s)", existing_feature, name); factory = GST_ELEMENT_FACTORY_CAST (existing_feature); factory->type = type; existing_feature->loaded = TRUE; g_type_set_qdata (type, _gst_elementclass_factory, factory); gst_object_unref (existing_feature); return TRUE; } factory = GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0, NULL)); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name); GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type)); /* provide info needed during class structure setup */ g_type_set_qdata (type, _gst_elementclass_factory, factory); klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); if ((klass->details.longname == NULL) || (klass->details.klass == NULL) || (klass->details.author == NULL)) goto detailserror; factory->type = type; __gst_element_details_copy (&factory->details, &klass->details); if (klass->meta_data) { factory->meta_data = gst_structure_copy ((GstStructure *) klass->meta_data); } else { factory->meta_data = NULL; } for (item = klass->padtemplates; item; item = item->next) { GstPadTemplate *templ = item->data; GstStaticPadTemplate *newt; gchar *caps_string = gst_caps_to_string (templ->caps); newt = g_slice_new (GstStaticPadTemplate); newt->name_template = g_intern_string (templ->name_template); newt->direction = templ->direction; newt->presence = templ->presence; newt->static_caps.caps.refcount = 0; newt->static_caps.string = g_intern_string (caps_string); factory->staticpadtemplates = g_list_append (factory->staticpadtemplates, newt); g_free (caps_string); } factory->numpadtemplates = klass->numpadtemplates; /* special stuff for URI handling */ if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) { GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_type_interface_peek (klass, GST_TYPE_URI_HANDLER); if (!iface || (!iface->get_type && !iface->get_type_full) || (!iface->get_protocols && !iface->get_protocols_full)) goto urierror; if (iface->get_type) factory->uri_type = iface->get_type (); else if (iface->get_type_full) factory->uri_type = iface->get_type_full (factory->type); if (!GST_URI_TYPE_IS_VALID (factory->uri_type)) goto urierror; if (iface->get_protocols) factory->uri_protocols = g_strdupv (iface->get_protocols ()); else if (iface->get_protocols_full) factory->uri_protocols = iface->get_protocols_full (factory->type); if (!factory->uri_protocols) goto urierror; } interfaces = g_type_interfaces (type, &n_interfaces); for (i = 0; i < n_interfaces; i++) { __gst_element_factory_add_interface (factory, g_type_name (interfaces[i])); } g_free (interfaces); if (plugin && plugin->desc.name) { GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = plugin->desc.name; GST_PLUGIN_FEATURE_CAST (factory)->plugin = plugin; g_object_add_weak_pointer ((GObject *) plugin, (gpointer *) & GST_PLUGIN_FEATURE_CAST (factory)->plugin); } else { GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = "NULL"; GST_PLUGIN_FEATURE_CAST (factory)->plugin = NULL; } gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE_CAST (factory), rank); GST_PLUGIN_FEATURE_CAST (factory)->loaded = TRUE; gst_registry_add_feature (registry, GST_PLUGIN_FEATURE_CAST (factory)); return TRUE; /* ERRORS */ urierror: { GST_WARNING_OBJECT (factory, "error with uri handler!"); gst_element_factory_cleanup (factory); return FALSE; } detailserror: { GST_WARNING_OBJECT (factory, "The GstElementDetails don't seem to have been set properly"); gst_element_factory_cleanup (factory); return FALSE; } }
/** * gst_type_find_factory_get_list: * * Gets the list of all registered typefind factories. You must free the * list using gst_plugin_feature_list_free. * * Returns: the list of all registered #GstTypeFindFactory. */ GList * gst_type_find_factory_get_list (void) { return gst_registry_get_feature_list (gst_registry_get_default (), GST_TYPE_TYPE_FIND_FACTORY); }