//finds the visualisation factory GstElementFactory * setup_vis_find_factory (const gchar *vis_name) { GstElementFactory *fac = NULL; GList *l, *features; features = get_visualization_features (); /* find element factory using long name */ for (l = features; l != NULL; l = l->next) { GstElementFactory *f = GST_ELEMENT_FACTORY (l->data); //long name if (f && strcmp (vis_name, gst_element_factory_get_longname (f)) == 0) { fac = f; goto done; } //short name else if (f && strcmp (vis_name, GST_OBJECT_NAME (f)) == 0) { fac = f; goto done; } } done: g_list_free (features); return fac; }
static gpointer rb_audiocd_load_songs (RBAudioCdSource *source) { RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source); RhythmDB *db; GVolume *volume; g_object_get (source, "volume", &volume, NULL); priv->device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); g_object_unref (volume); db = get_db_for_source (source); rb_debug ("loading Audio CD from %s", priv->device_path); /* create a cdda gstreamer element, to get cd info from */ priv->cdda = gst_element_make_from_uri (GST_URI_SRC, "cdda://", NULL); if (!priv->cdda) { gdk_threads_enter (); rb_error_dialog (NULL, _("Couldn't load Audio CD"), _("Rhythmbox could not get access to the CD device.")); gdk_threads_leave (); goto error_out; } rb_debug ("cdda longname: %s", gst_element_factory_get_longname (gst_element_get_factory (priv->cdda))); g_object_set (G_OBJECT (priv->cdda), "device", priv->device_path, NULL); priv->pipeline = gst_pipeline_new ("pipeline"); priv->fakesink = gst_element_factory_make ("fakesink", "fakesink"); gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdda, priv->fakesink, NULL); gst_element_link (priv->cdda, priv->fakesink); /* disable paranoia (if using cdparanoia) since we're only reading track information here. * this reduces cdparanoia's cache size, so the process is much faster. */ if (g_object_class_find_property (G_OBJECT_GET_CLASS (source), "paranoia-mode")) g_object_set (source, "paranoia-mode", 0, NULL); if (rb_audiocd_scan_songs (source, db)) rb_audiocd_load_metadata (source, db); error_out: g_object_unref (db); g_object_unref (source); return NULL; }
static gboolean mixer_filter_func (GstMixer * mixer, gpointer user_data) { GstElementFactory *factory; const gchar *long_name; gchar *devname = NULL; gchar *name; gint *p_count = (gint *) user_data; /* fetch name */ if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (mixer)), "device-name")) { g_object_get (mixer, "device-name", &devname, NULL); GST_DEBUG ("device name: %s", GST_STR_NULL (devname)); } else { devname = NULL; GST_DEBUG ("device name unknown, no 'device-name' property"); } factory = gst_element_get_factory (GST_ELEMENT (mixer)); long_name = gst_element_factory_get_longname (factory); if (devname) { name = g_strdup_printf ("%s (%s)", devname, long_name); g_free (devname); } else { gchar *title; *p_count += 1; title = g_strdup_printf (_("Unknown Volume Control %d"), *p_count); name = g_strdup_printf ("%s (%s)", title, long_name); g_free (title); } g_object_set_data_full (G_OBJECT (mixer), "mate-volume-control-name", name, (GDestroyNotify) g_free); GST_DEBUG ("Adding '%s' to list of available mixers", name); gst_element_set_state (GST_ELEMENT (mixer), GST_STATE_NULL); return TRUE; /* add mixer to list */ }
void GstUtils::element_factory_list_to_g_enum(GEnumValue *target_enum, GstElementFactoryListType type, GstRank minrank, bool insert_none_first, const std::vector<std::string> &black_list) { GList *element_list = gst_element_factory_list_get_elements(type, minrank); GList *iter = element_list; gint i = 0; if (insert_none_first) { target_enum[0].value = 0; target_enum[0].value_name = g_strdup("None"); target_enum[0].value_nick = g_strdup("None"); i++; } while (iter != nullptr) { if (black_list.end() == std::find( black_list.begin(), black_list.end(), gst_plugin_feature_get_name((GstPluginFeature *) iter->data))){ target_enum[i].value = i; target_enum[i].value_name = g_strdup(gst_element_factory_get_longname((GstElementFactory *) iter->data)); target_enum[i].value_nick = g_strdup(gst_plugin_feature_get_name((GstPluginFeature *) iter->data)); i++; } iter = g_list_next(iter); } target_enum[i].value = 0; target_enum[i].value_name = nullptr; target_enum[i].value_nick = nullptr; gst_plugin_feature_list_free(element_list); }
void add_longname (GstElementFactory *f, GList ** to) { *to = g_list_append (*to, (gchar *) gst_element_factory_get_longname (f)); }
static void gst_audio_mixer_filter_probe_feature (GstAudioMixerFilterFunc filter_func, GstElementFactory * factory, GList ** p_collection, gboolean first, gpointer user_data) { GstElement *element; GST_DEBUG ("probing %s ...", gst_element_factory_get_longname (factory)); /* create element */ element = gst_element_factory_create (factory, NULL); if (element == NULL) { GST_DEBUG ("could not create element from factory"); return; } GST_DEBUG ("created element %s (%p)", GST_ELEMENT_NAME (element), element); if (GST_IS_PROPERTY_PROBE (element)) { GstPropertyProbe *probe; const GParamSpec *devspec; probe = GST_PROPERTY_PROBE (element); GST_DEBUG ("probing available devices ..."); if ((devspec = gst_property_probe_get_property (probe, "device"))) { GValueArray *array; if ((array = gst_property_probe_probe_and_get_values (probe, devspec))) { guint n; GST_DEBUG ("there are %d available devices", array->n_values); /* set all devices and test for mixer */ for (n = 0; n < array->n_values; n++) { GValue *device; /* set this device */ device = g_value_array_get_nth (array, n); g_object_set_property (G_OBJECT (element), "device", device); GST_DEBUG ("trying device %s ..", g_value_get_string (device)); if (gst_audio_mixer_filter_check_element (element)) { gst_audio_mixer_filter_do_filter (filter_func, factory, &element, p_collection, user_data); if (first && *p_collection != NULL) { GST_DEBUG ("Stopping after first found mixer, as requested"); break; } } } g_value_array_free (array); } } } else { GST_DEBUG ("element does not support the property probe interface"); if (gst_audio_mixer_filter_check_element (element)) { gst_audio_mixer_filter_do_filter (filter_func, factory, &element, p_collection, user_data); } } if (element) { gst_element_set_state (element, GST_STATE_NULL); gst_object_unref (element); } }
int main (int argc, char *argv[]) { /* Initialisation */ gst_init (&argc, &argv); GList *element_list = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER, GST_RANK_NONE); GList *iter = element_list; while (iter != NULL) { g_print ("+++++\n"); g_print ("%s -- ", gst_element_factory_get_longname ((GstElementFactory *)iter->data)); g_print ("%s\n", gst_plugin_feature_get_name ((GstPluginFeature *)iter->data)); const GList *static_pads = gst_element_factory_get_static_pad_templates ((GstElementFactory *)iter->data); while (NULL != static_pads) { GstStaticPadTemplate *pad = (GstStaticPadTemplate *)static_pads->data; //the following is EMPTY gchar *caps_str = gst_caps_to_string (&pad->static_caps.caps); //g_free (caps_str); /* g_print ("string: %s\n", */ /* pad->static_caps.string); */ GstCaps *caps = gst_caps_from_string (pad->static_caps.string); guint caps_size = gst_caps_get_size (caps); if (! gst_caps_is_any (caps)) for (guint i = caps_size; i > 0; i--) { GstStructure *caps_struct = gst_caps_get_structure (caps, i-1); if (gst_structure_has_name (caps_struct,"application/x-rtp")) { g_print ("string: %s\n", gst_structure_to_string (caps_struct)); {//payload const GValue *val = gst_structure_get_value (caps_struct, "payload"); if (NULL != val) { //g_print ("payload struct type %s\n", G_VALUE_TYPE_NAME (val)); if(GST_VALUE_HOLDS_INT_RANGE(val)) { g_print ("payload min %d\n", gst_value_get_int_range_min (val)); } if (GST_VALUE_HOLDS_LIST(val)) { for (guint i = 0; i < gst_value_list_get_size (val); i++) { const GValue *item_val = gst_value_list_get_value (val, i); g_print ("payload list %d\n", g_value_get_int (item_val)); } } if (G_VALUE_HOLDS_INT (val)) { g_print ("payload int %d\n", g_value_get_int (val)); } } } { //encodeing-name const GValue *val = gst_structure_get_value (caps_struct, "encoding-name"); if (NULL != val) { //g_print ("encoding-name struct type %s\n", G_VALUE_TYPE_NAME (val)); if (GST_VALUE_HOLDS_LIST(val)) { for (guint i = 0; i < gst_value_list_get_size (val); i++) { const GValue *item_val = gst_value_list_get_value (val, i); g_print ("encoding-name list %s\n", g_value_get_string (item_val)); } } if (G_VALUE_HOLDS_STRING (val)) { g_print ("encoding-name string %s\n", g_value_get_string (val)); } } } {//media const GValue *val = gst_structure_get_value (caps_struct, "media"); if (NULL != val) { if (GST_VALUE_HOLDS_LIST(val)) { for (guint i = 0; i < gst_value_list_get_size (val); i++) { const GValue *item_val = gst_value_list_get_value (val, i); g_print ("media list %s\n", g_value_get_string (item_val)); } } if (G_VALUE_HOLDS_STRING (val)) { g_print ("media string %s\n", g_value_get_string (val)); } } } {//clock rate const GValue *val = gst_structure_get_value (caps_struct, "clock-rate"); if (NULL != val) { //g_print ("payload struct type %s\n", G_VALUE_TYPE_NAME (val)); if(GST_VALUE_HOLDS_INT_RANGE(val)) { g_print ("clock-rate min %d\n", gst_value_get_int_range_min (val)); } if (GST_VALUE_HOLDS_LIST(val)) { for (guint i = 0; i < gst_value_list_get_size (val); i++) { const GValue *item_val = gst_value_list_get_value (val, i); g_print ("clock-rate list %d\n", g_value_get_int (item_val)); } } if (G_VALUE_HOLDS_INT (val)) { g_print ("clock-rate int %d\n", g_value_get_int (val)); } } } /* g_print ("\nencoding-name %s\n", */ /* gst_structure_get_string (caps_struct, */ /* "encoding-name")); */ } } static_pads = g_list_next (static_pads); gst_caps_unref (caps); } iter = g_list_next (iter); } gst_plugin_feature_list_free (element_list); return 0; }
static VALUE get_long_name(VALUE self) { return CSTR2RVAL(gst_element_factory_get_longname(SELF(self))); }
static gboolean rsndec_factory_filter (GstPluginFeature * feature, RsnDecFactoryFilterCtx * ctx) { GstElementFactory *factory; guint rank; const gchar *klass; const GList *templates; GList *walk; gboolean can_sink = FALSE; /* we only care about element factories */ if (!GST_IS_ELEMENT_FACTORY (feature)) return FALSE; factory = GST_ELEMENT_FACTORY (feature); klass = gst_element_factory_get_klass (factory); /* only decoders can play */ if (strstr (klass, "Decoder") == NULL) return FALSE; /* only select elements with autoplugging rank */ rank = gst_plugin_feature_get_rank (feature); if (rank < GST_RANK_MARGINAL) return FALSE; /* See if the element has a sink pad that can possibly sink this caps */ /* get the templates from the element factory */ templates = gst_element_factory_get_static_pad_templates (factory); for (walk = (GList *) templates; walk && !can_sink; walk = g_list_next (walk)) { GstStaticPadTemplate *templ = walk->data; /* we only care about the sink templates */ if (templ->direction == GST_PAD_SINK) { GstCaps *intersect; GstCaps *tmpl_caps; /* try to intersect the caps with the caps of the template */ tmpl_caps = gst_static_caps_get (&templ->static_caps); intersect = gst_caps_intersect (ctx->desired_caps, tmpl_caps); gst_caps_unref (tmpl_caps); /* check if the intersection is empty */ if (!gst_caps_is_empty (intersect)) { /* non empty intersection, we can use this element */ can_sink = TRUE; ctx->decoder_caps = gst_caps_merge (ctx->decoder_caps, intersect); } else gst_caps_unref (intersect); } } if (can_sink) { GST_DEBUG ("Found decoder element %s (%s)", gst_element_factory_get_longname (factory), gst_plugin_feature_get_name (feature)); } return can_sink; }
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"); }
static void print_plugin_features (GstPlugin * plugin) { GList *features; gint num_features = 0; gint num_elements = 0; gint num_types = 0; gint num_indexes = 0; gint num_other = 0; 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); if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; factory = GST_ELEMENT_FACTORY (feature); n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory), gst_element_factory_get_longname (factory)); num_elements++; } else if (GST_IS_INDEX_FACTORY (feature)) { GstIndexFactory *factory; factory = GST_INDEX_FACTORY (feature); n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); num_indexes++; } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; factory = GST_TYPE_FIND_FACTORY (feature); if (factory->extensions) { guint i = 0; g_print ("%s: %s: ", plugin->desc.name, gst_plugin_feature_get_name (feature)); while (factory->extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); i++; } g_print ("\n"); } else g_print ("%s: %s: no extensions\n", plugin->desc.name, gst_plugin_feature_get_name (feature)); num_types++; } else { n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); num_other++; } num_features++; features = g_list_next (features); } n_print ("\n"); n_print (" %d features:\n", num_features); if (num_elements > 0) n_print (" +-- %d elements\n", num_elements); if (num_types > 0) n_print (" +-- %d types\n", num_types); if (num_indexes > 0) n_print (" +-- %d indexes\n", num_indexes); if (num_other > 0) n_print (" +-- %d other objects\n", num_other); n_print ("\n"); }
int main(int argc, char *argv[]) { GstElement *pipeline, *vis_plugin; GstBus *bus; GstMessage *msg; GList *list, *walk; GstElementFactory *selected_factory = NULL; guint flags; char *pipeline_str; gboolean list_plugins = FALSE; gchar *plugin_name = NULL; GError *error = NULL; GOptionContext *context; GOptionEntry options[] = { { "list-plugins", 'l', 0, G_OPTION_ARG_NONE, &list_plugins, "list available plugins and exits", NULL }, { "plugin", 'p', 0, G_OPTION_ARG_STRING, &plugin_name, "set the desired plugin", NULL }, { NULL } }; context = g_option_context_new(""); g_option_context_add_main_entries(context, options, ""); if (!g_option_context_parse(context, &argc, &argv, &error)) { g_print("option parsing failed: %s\n", error->message); return -1; } g_option_context_free(context); if (argc > 1) { if (g_str_has_prefix(argv[1], "http://") || g_str_has_prefix(argv[1], "ftp://")) pipeline_str = g_strdup_printf("%s uri=\"%s\"", PLAYBIN, argv[1]); else if (argv[1][0] == '~') pipeline_str = g_strdup_printf("%s uri=\"file://%s%s\"", PLAYBIN, g_get_home_dir(), argv[1]+1); else if (g_file_test(argv[1], G_FILE_TEST_IS_REGULAR)) pipeline_str = g_strdup_printf("playbin uri=\"file://%s\"", argv[1]); else pipeline_str = g_strdup_printf("%s uri=%s", PLAYBIN, DEFAULT_URI); } else pipeline_str = g_strdup_printf("%s uri=%s", PLAYBIN, DEFAULT_URI); gst_init(&argc, &argv); list = gst_registry_feature_filter(GET_PLUGIN_REGISTRY, filter_vis_features, FALSE, NULL); if (plugin_name == NULL) plugin_name = "GOOM"; g_print("Available visualization plugins:\n"); for (walk = list; walk != NULL; walk = g_list_next(walk)) { const gchar *name; GstElementFactory *factory; factory = GST_ELEMENT_FACTORY(walk->data); name = gst_element_factory_get_longname(factory); g_print(" %s\n", name); if (selected_factory == NULL || g_str_has_prefix(name, plugin_name)) { selected_factory = factory; } } /* Don't use the factory if it's still empty */ /* e.g. no visualization plugins found */ if (!selected_factory) { g_print("No visualization plugins found!\n"); return -1; } if (list_plugins == TRUE) return 0; g_print("Selected '%s'\n", gst_element_factory_get_longname(selected_factory)); vis_plugin = gst_element_factory_create(selected_factory, NULL); if (!vis_plugin) return -1; pipeline = gst_parse_launch(pipeline_str, NULL); g_object_get(pipeline, "flags", &flags, NULL); flags |= GST_PLAY_FLAG_VIS; g_object_set(pipeline, "flags", flags, NULL); g_object_set(pipeline, "vis-plugin", vis_plugin, NULL); gst_element_set_state(pipeline, GST_STATE_PLAYING); bus = gst_element_get_bus(pipeline); msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); if (msg != NULL) gst_message_unref(msg); gst_plugin_feature_list_free(list); gst_object_unref(bus); gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(pipeline); return 0; }