Esempio n. 1
0
int
iterate_plugins_elements (GstElementFactory *factory, GHashTable *hashtable)
{
    GstElement *element;
    const GList *pads;
    GstStaticPadTemplate *padtemplate;
    const GstCaps * caps;
    int i;

    factory =
        GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
                                                      (factory)));

    if (!factory) 
    {
        g_error ("element plugin couldn't be loaded");
        return -1;
    }

    element = gst_element_factory_create (factory, NULL);
    if (!element) 
    {
        g_error ("couldn't construct element for some reason");
        return -1;
    }

    if (factory->numpadtemplates) 
    {
        pads = factory->staticpadtemplates;
        while (pads) 
        {
            padtemplate = (GstStaticPadTemplate *) (pads->data);
            pads = g_list_next (pads);

            if (padtemplate->direction == GST_PAD_SINK 
                && padtemplate->presence == GST_PAD_ALWAYS
                && padtemplate->static_caps.string) {

                    caps = gst_static_caps_get (&padtemplate->static_caps);
                    if (caps != NULL && !gst_caps_is_any (caps) && !gst_caps_is_empty (caps))
                    {
                        for (i = 0; i < gst_caps_get_size (caps); i++) 
                        {
                            GstStructure *structure = gst_caps_get_structure (caps, i);
                            const gchar *mime = gst_structure_get_name (structure);
                            if (g_str_has_prefix (mime, "audio"))
                            {
                                g_hash_table_insert(hashtable, (gpointer)mime, (gpointer)&ONE);
                            }
                        }
                    }
                }
        }
    }

    gst_object_unref (element);
    gst_object_unref (factory);

    return 0;    
}
Esempio n. 2
0
int
main (int   argc,
      char *argv[])
{
  GstElementFactory *factory;
  GstElement * element;

  /* init GStreamer */
  gst_init (&argc, &argv);

  /* create element, method #2 */
  factory = gst_element_factory_find ("fakesrc");
  if (!factory) {
    g_print ("Failed to find factory of type 'fakesrc'\n");
    return -1;
  }
  element = gst_element_factory_create (factory, "source");
  if (!element) {
    g_print ("Failed to create element, even though its factory exists!\n");
    return -1;
  }

  gst_object_unref (GST_OBJECT (element));

  return 0;
}
Esempio n. 3
0
static GstElement *
create_parser_for_caps (const GstCaps * caps)
{
  GList *parser_list, *filtered_list, *l;
  GstElementFactory *parser_factory = NULL;
  GstElement *parser = NULL;

  parser_list =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_PARSER,
      GST_RANK_NONE);
  filtered_list =
      gst_element_factory_list_filter (parser_list, caps, GST_PAD_SINK, FALSE);

  for (l = filtered_list; l != NULL && parser_factory == NULL; l = l->next) {
    parser_factory = GST_ELEMENT_FACTORY (l->data);
    if (gst_element_factory_get_num_pad_templates (parser_factory) != 2)
      parser_factory = NULL;
  }

  if (parser_factory != NULL) {
    parser = gst_element_factory_create (parser_factory, NULL);
  } else {
    parser = gst_element_factory_make ("capsfilter", NULL);
  }

  gst_plugin_feature_list_free (filtered_list);
  gst_plugin_feature_list_free (parser_list);

  return parser;
}
static GstElement *
find_demuxer (GstCaps * caps)
{
  GList *factories =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DEMUXER,
      GST_RANK_MARGINAL);
  GList *compat_elements;
  GstElement *e = NULL;

  if (factories == NULL)
    return NULL;

  compat_elements =
      gst_element_factory_list_filter (factories, caps, GST_PAD_SINK, TRUE);

  if (compat_elements) {
    /* Just take the first (highest ranked) option */
    GstElementFactory *factory =
        GST_ELEMENT_FACTORY_CAST (compat_elements->data);
    e = gst_element_factory_create (factory, NULL);
    gst_plugin_feature_list_free (compat_elements);
  }

  if (factories)
    gst_plugin_feature_list_free (factories);

  return e;
}
Esempio n. 5
0
// setups audio visualization
// a modified version of totem's bacon video widget
static void
setup_vis (gstPlay *play)
{
	if (play->xid == 0)
		return;
	
	GstElement *vis_bin = NULL;
	GstElement *vis_element = NULL;
	GstElement *vis_capsfilter = NULL;
	GstPad *pad = NULL;
	GstElementFactory *fac = NULL;
	
	
	fac = setup_vis_find_factory (play->vis_name);
	if (fac == NULL)
		goto beach; //cant find the visualisation
	
	
	vis_element = gst_element_factory_create (fac, "vis_element");
	if (!GST_IS_ELEMENT (vis_element))
		goto beach; //cant create visualisation element
	
	
	
	vis_capsfilter = gst_element_factory_make ("capsfilter", "vis_capsfilter");
	if (!GST_IS_ELEMENT (vis_capsfilter))
	{
		gst_object_unref (vis_element);
		goto beach; //cant create visualisation capsfilter element
	}
	
	
	vis_bin = gst_bin_new ("vis_bin");
	if (!GST_IS_ELEMENT (vis_bin))
	{
		gst_object_unref (vis_element);
		gst_object_unref (vis_capsfilter);
		goto beach; //cant create visualisation bin
	}
	
	
	gst_bin_add_many (GST_BIN (vis_bin), vis_element, vis_capsfilter, NULL);
	
	// sink ghostpad
	pad = gst_element_get_static_pad (vis_element, "sink");
	gst_element_add_pad (vis_bin, gst_ghost_pad_new ("sink", pad));
	gst_object_unref (pad);
	
	
	// source ghostpad, link with vis_element
	pad = gst_element_get_static_pad (vis_capsfilter, "src");
	gst_element_add_pad (vis_bin, gst_ghost_pad_new ("src", pad));
	gst_element_link_pads (vis_element, "src", vis_capsfilter, "sink");
	gst_object_unref (pad);
	
beach:
	g_object_set (play->element, "vis-plugin", vis_bin, NULL);
	
	return;
}
Esempio n. 6
0
static void
on_tree_selection_changed (GObject * object, GstElementBrowser * browser)
{
  GstElementFactory *factory;
  GstElementBrowserElementTree *element_tree =
      GST_ELEMENT_BROWSER_ELEMENT_TREE (object);

  g_object_get (element_tree, "selected", &factory, NULL);
  browser->selected = factory;

  g_return_if_fail (factory != NULL);

  gtk_label_set_text (GTK_LABEL (browser->longname),
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME));
  gtk_label_set_text (GTK_LABEL (browser->description),
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_DESCRIPTION));
  gtk_label_set_text (GTK_LABEL (browser->author),
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_AUTHOR));

  g_object_set (G_OBJECT (browser->padtemplates), "element-factory",
      browser->selected, NULL);

  if (browser->element)
    gst_object_unref (GST_OBJECT (browser->element));

  browser->element = gst_element_factory_create (browser->selected, NULL);
  g_object_set (G_OBJECT (browser->pads), "element", browser->element, NULL);
}
Esempio n. 7
0
static void
on_element_tree_select (GstElementBrowserElementTree * element_tree,
    gpointer user_data)
{
  GstElementFactory *selected_factory;
  GstElement *element, *selected_bin;
  GstEditorPalette *palette = GST_EDITOR_PALETTE (user_data);
  GError *error = NULL;

  g_return_if_fail (palette->canvas != NULL);

  g_object_get (element_tree, "selected", &selected_factory, NULL);

  selected_bin = gst_editor_canvas_get_selected_bin (palette->canvas, &error);
  if (!selected_bin) {
    gst_editor_popup_warning (error->message);
    g_error_free (error);
    return;
  }

  element = gst_element_factory_create (selected_factory, NULL);

  g_return_if_fail (element != NULL);
  gst_bin_add (GST_BIN (selected_bin), element);
}
Esempio n. 8
0
static GstElement * try_codecs(GList *codecs, const gchar *name_prefix)
{
    GList *l;
    gchar *element_name;

    for (l = codecs; l; l = l->next) {
        GstElementFactory *f = l->data;
        GstElement *e;

        element_name = g_strdup_printf("%s_%s_%u", name_prefix,
                                       gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(f)),
                                       get_unique_id());

        e = gst_element_factory_create(f, element_name);
        g_free(element_name);

        if (!e)
            continue;

        /* Try setting to READY. If this fails the codec does not work, for
         * example because the hardware codec is currently busy
         */
        if (gst_element_set_state (e, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) {
            gst_element_set_state (e, GST_STATE_NULL);
            gst_object_unref(e);
            continue;
        }

        return e;
    }

    return NULL;
}
Esempio n. 9
0
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;
}
Esempio n. 10
0
// static 
void
MediaParserGst::cb_typefound(GstElement* typefind, guint /*probability*/,
                              GstCaps* caps, gpointer data)
{
    print_caps(caps);

    MediaParserGst* parser = static_cast<MediaParserGst*>(data);

    GstElementFactory* demuxfactory = swfdec_gst_get_demuxer_factory(caps);
    
    if (!demuxfactory) {
        GstPad* srcpad = gst_element_get_static_pad(typefind, "src");

        if (!srcpad) {
            throw MediaException(_("MediaParserGst: couldn't get the typefind "
                                   "src element."));
        }

        cb_pad_added(typefind, srcpad, parser);
        gst_object_unref(GST_OBJECT(srcpad));
        parser->_demux_probe_ended = true;
        return;
    }

    // We have a factory, so create the demuxer.
    GstElement* demuxer = gst_element_factory_create(demuxfactory, "demuxer");
    gst_object_unref(GST_OBJECT(demuxfactory));

    if (!demuxer) {
        throw MediaException(_("MediaParserGst: couldn't create the "
                    "demuxer"));
    }
    
    gboolean success = gst_bin_add(GST_BIN(parser->_bin), demuxer);
    if (!success) {
        log_error(_("MediaParserGst: failed adding demuxer to bin."));
    }        
    
    success = gst_element_link(typefind, demuxer);
    if (!success) {
        throw MediaException(_("MediaParserGst: failed adding demuxer "
                    "to bin."));
    }
    
    g_signal_connect(demuxer, "pad-added",
            G_CALLBACK(MediaParserGst::cb_pad_added), parser);
    g_signal_connect(demuxer, "no-more-pads", 
            G_CALLBACK(MediaParserGst::cb_no_more_pads), parser);
    
    if (!gst_element_set_state(parser->_bin, GST_STATE_PLAYING) ==
            GST_STATE_CHANGE_SUCCESS) {
        throw GnashException(_("MediaParserGst could not change "
                    "element state"));
    }
}
Esempio n. 11
0
/*
 * Method: create(element_name=nil)
 * element_name: a name which will be attributed to the element.
 *
 * Creates a new element of the type defined by the element factory.
 *
 * If element name is ommited (or nil), then the element will receive a guaranteed 
 * unique name, consisting of the element factory name and a number. 
 * If name is given, it will be given the name supplied.
 *
 * Returns: a newly created object based on Gst::Element.
 */
static VALUE
create(int argc, VALUE *argv, VALUE self)
{
    GstElement *element;
    VALUE name;

    rb_scan_args(argc, argv, "01", &name);

    element = gst_element_factory_create(SELF(self), RVAL2CSTR_ACCEPT_NIL(name));
    return GOBJ2RVAL(element);
}
Esempio n. 12
0
GstElement *
rb_gst_encoding_profile_get_encoder (GstEncodingProfile *profile)
{
	GstElementFactory *factory;

	factory = get_audio_encoder_factory (profile);
	if (factory == NULL) {
		return NULL;
	}

	return gst_element_factory_create (factory, NULL);
}
static GstElement *
get_encoder (GstCaps * caps)
{
  GstElementFactory *fact = get_encoder_factory (caps);
  GstElement *res = NULL;

  if (fact) {
    res = gst_element_factory_create (fact, "internal-encoder");
    gst_object_unref (fact);
  }
  return res;
}
GstElement *
rygel_gst_utils_get_rtp_depayloader (GstCaps *caps) {
  GList *features;
  GList *filtered;
  const gchar *feature_name;

  if (!rygel_gst_utils_need_rtp_depayloader (caps)) {
    return NULL;
  }

  features = gst_element_factory_list_get_elements ((GstElementFactoryListType) GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER, GST_RANK_NONE);
  filtered = gst_element_factory_list_filter (features, caps, GST_PAD_SINK, FALSE);
  gst_plugin_feature_list_free (features);

  feature_name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (filtered->data));
  /* If most "fitting" depayloader was rtpdepay skip it because it is
   * just some kind of proxy.
   */
  if (g_strcmp0 (feature_name, "rtpdepay") == 0) {
    if (filtered->next) {
      GstElement* element = gst_element_factory_create (GST_ELEMENT_FACTORY (filtered->next->data), NULL);
      if (element) {
        gst_object_ref_sink (element);
      }

      gst_plugin_feature_list_free (filtered);
      return element;
    }

    return NULL;
  } else {
    GstElement* element = gst_element_factory_create (GST_ELEMENT_FACTORY (filtered->data), NULL);
    if (element) {
      gst_object_ref_sink (element);
    }

    gst_plugin_feature_list_free (filtered);
    return element;
  }
}
Esempio n. 15
0
static GstElement *
get_encoder (const GstCaps * caps, GError ** err)
{
  GList *encoders = NULL;
  GList *filtered = NULL;
  GstElementFactory *factory = NULL;
  GstElement *encoder = NULL;

  encoders =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER |
      GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE, GST_RANK_NONE);

  if (encoders == NULL) {
    *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN,
        "Cannot find any image encoder");
    goto fail;
  }

  GST_INFO ("got factory list %p", encoders);
  gst_plugin_feature_list_debug (encoders);

  filtered =
      gst_element_factory_list_filter (encoders, caps, GST_PAD_SRC, FALSE);
  GST_INFO ("got filtered list %p", filtered);

  if (filtered == NULL) {
    gchar *tmp = gst_caps_to_string (caps);
    *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN,
        "Cannot find any image encoder for caps %s", tmp);
    g_free (tmp);
    goto fail;
  }

  gst_plugin_feature_list_debug (filtered);

  factory = (GstElementFactory *) filtered->data;

  GST_INFO ("got factory %p", factory);
  encoder = gst_element_factory_create (factory, NULL);

  GST_INFO ("created encoder element %p, %s", encoder,
      gst_element_get_name (encoder));

fail:
  if (encoders)
    gst_plugin_feature_list_free (encoders);
  if (filtered)
    gst_plugin_feature_list_free (filtered);

  return encoder;
}
Esempio n. 16
0
static GstElement *
create_payloader_for_caps (const GstCaps * caps)
{
  GList *payloader_list, *filtered_list, *l;
  GstElementFactory *payloader_factory = NULL;
  GstElement *payloader = NULL;

  payloader_list =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_PAYLOADER,
      GST_RANK_NONE);
  filtered_list =
      gst_element_factory_list_filter (payloader_list, caps, GST_PAD_SRC,
      FALSE);

  for (l = filtered_list; l != NULL && payloader_factory == NULL; l = l->next) {
    payloader_factory = GST_ELEMENT_FACTORY (l->data);
    if (gst_element_factory_get_num_pad_templates (payloader_factory) != 2)
      payloader_factory = NULL;
  }

  if (payloader_factory != NULL) {
    payloader = gst_element_factory_create (payloader_factory, NULL);
  }

  if (payloader) {
    GParamSpec *pspec;

    pspec =
        g_object_class_find_property (G_OBJECT_GET_CLASS (payloader),
        "config-interval");
    if (pspec != NULL && G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_UINT) {
      g_object_set (payloader, "config-interval", 1, NULL);
    }

    pspec =
        g_object_class_find_property (G_OBJECT_GET_CLASS (payloader),
        "picture-id-mode");
    if (pspec != NULL && G_TYPE_IS_ENUM (G_PARAM_SPEC_VALUE_TYPE (pspec))) {
      /* Set picture id so that remote peer can determine continuity if */
      /* there are lost FEC packets and if it has to NACK them */
      g_object_set (payloader, "picture-id-mode", PICTURE_ID_15_BIT, NULL);
    }
  }

  gst_plugin_feature_list_free (filtered_list);
  gst_plugin_feature_list_free (payloader_list);

  return payloader;
}
static void
type_found_cb (GstElement * typefind, guint probability,
    GstCaps * caps, InsanityTest * test)
{
  GList *demuxers = NULL, *capable_demuxers = NULL;
  GstPad *typefsrcpad = NULL;

  typefsrcpad = gst_element_get_static_pad (typefind, "src");

  /* First try to directly link to the decoder */
  if (pad_added_cb (typefind, typefsrcpad, test) == TRUE)
    return;

  /* if we can't find a demuxer that is concidered as good
   * (ie with rank primary, we just don't run the test */
  demuxers = gst_element_factory_list_get_elements
      (GST_ELEMENT_FACTORY_TYPE_DEMUXER, GST_RANK_PRIMARY);

  if (demuxers == NULL) {
    ERROR (test, "Could not find a demuxer concidered as good enough");
    insanity_test_done (test);
    goto done;
  }

  capable_demuxers = gst_element_factory_list_filter (demuxers, caps,
      GST_PAD_SINK, FALSE);

  glob_demuxer = gst_element_factory_create (capable_demuxers->data, "demuxer");
  if (glob_demuxer == NULL) {
    insanity_test_done (test);
    goto done;
  }

  gst_bin_add (GST_BIN (glob_pipeline), glob_demuxer);
  gst_element_link (glob_typefinder, glob_demuxer);
  gst_element_sync_state_with_parent (glob_demuxer);

  connect_element (test, glob_demuxer);

done:
  gst_plugin_feature_list_free (demuxers);
  gst_plugin_feature_list_free (capable_demuxers);
}
Esempio n. 18
0
static GstElement *
gst_auto_audio_sink_create_element_with_pretty_name (GstAutoAudioSink * sink,
    GstElementFactory * factory)
{
  GstElement *element;
  gchar *name, *marker;

  marker = g_strdup (GST_OBJECT_NAME (factory));
  if (g_str_has_suffix (marker, "sink"))
    marker[strlen (marker) - 4] = '\0';
  if (g_str_has_prefix (marker, "gst"))
    g_memmove (marker, marker + 3, strlen (marker + 3) + 1);
  name = g_strdup_printf ("%s-actual-sink-%s", GST_OBJECT_NAME (sink), marker);
  g_free (marker);

  element = gst_element_factory_create (factory, name);
  g_free (name);

  return element;
}
static void
ges_smart_mixer_init (GESSmartMixer * self)
{
  GstPad *pad;
  g_mutex_init (&self->lock);

  self->mixer = gst_element_factory_create (ges_get_compositor_factory (),
      "smart-mixer-mixer");
  g_object_set (self->mixer, "background", 1, NULL);
  gst_bin_add (GST_BIN (self), self->mixer);

  pad = gst_element_get_static_pad (self->mixer, "src");
  self->srcpad = gst_ghost_pad_new ("src", pad);
  gst_pad_set_active (self->srcpad, TRUE);
  gst_object_unref (pad);
  gst_element_add_pad (GST_ELEMENT (self), self->srcpad);

  self->pads_infos = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, (GDestroyNotify) destroy_pad);
}
Esempio n. 20
0
static GstElement *
gst_auto_video_src_create_element_with_pretty_name (GstAutoVideoSrc * src,
    GstElementFactory * factory)
{
  GstElement *element;
  gchar *name, *marker;

  marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
  if (g_str_has_suffix (marker, "src"))
    marker[strlen (marker) - 4] = '\0';
  if (g_str_has_prefix (marker, "gst"))
    g_memmove (marker, marker + 3, strlen (marker + 3) + 1);
  name = g_strdup_printf ("%s-actual-src-%s", GST_OBJECT_NAME (src), marker);
  g_free (marker);

  element = gst_element_factory_create (factory, name);
  g_free (name);

  return element;
}
Esempio n. 21
0
static void
kms_enc_tree_bin_create_encoder_for_caps (KmsEncTreeBin * self,
    const GstCaps * caps, gint target_bitrate)
{
  GList *encoder_list, *filtered_list, *l;
  GstElementFactory *encoder_factory = NULL;

  encoder_list =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER,
      GST_RANK_NONE);

  /* HACK: Augment the openh264 rank */
  for (l = encoder_list; l != NULL; l = l->next) {
    encoder_factory = GST_ELEMENT_FACTORY (l->data);

    if (g_str_has_prefix (GST_OBJECT_NAME (encoder_factory), "openh264")) {
      encoder_list = g_list_remove (encoder_list, l->data);
      encoder_list = g_list_prepend (encoder_list, encoder_factory);
      break;
    }
  }

  encoder_factory = NULL;
  filtered_list =
      gst_element_factory_list_filter (encoder_list, caps, GST_PAD_SRC, FALSE);

  for (l = filtered_list; l != NULL && encoder_factory == NULL; l = l->next) {
    encoder_factory = GST_ELEMENT_FACTORY (l->data);
    if (gst_element_factory_get_num_pad_templates (encoder_factory) != 2)
      encoder_factory = NULL;
  }

  if (encoder_factory != NULL) {
    self->priv->enc = gst_element_factory_create (encoder_factory, NULL);
    kms_enc_tree_bin_set_encoder_type (self);
    configure_encoder (self->priv->enc, self->priv->enc_type, target_bitrate);
  }

  gst_plugin_feature_list_free (filtered_list);
  gst_plugin_feature_list_free (encoder_list);
}
Esempio n. 22
0
/**
 * gst_element_factory_make:
 * @factoryname: a named factory to instantiate
 * @name: (allow-none): name of new element, or %NULL to automatically create
 *    a unique name
 *
 * Create a new element of the type defined by the given element factory.
 * If name is %NULL, then the element will receive a guaranteed unique name,
 * consisting of the element factory name and a number.
 * If name is given, it will be given the name supplied.
 *
 * Returns: (transfer floating) (nullable): new #GstElement or %NULL
 * if unable to create element
 */
GstElement *
gst_element_factory_make (const gchar * factoryname, const gchar * name)
{
  GstElementFactory *factory;
  GstElement *element;

  g_return_val_if_fail (factoryname != NULL, NULL);
  g_return_val_if_fail (gst_is_initialized (), NULL);

  GST_LOG ("gstelementfactory: make \"%s\" \"%s\"",
      factoryname, GST_STR_NULL (name));

  factory = gst_element_factory_find (factoryname);
  if (factory == NULL)
    goto no_factory;

  GST_LOG_OBJECT (factory, "found factory %p", factory);
  element = gst_element_factory_create (factory, name);
  if (element == NULL)
    goto create_failed;

  gst_object_unref (factory);

  return element;

  /* ERRORS */
no_factory:
  {
    GST_WARNING ("no such element factory \"%s\"!", factoryname);
    return NULL;
  }
create_failed:
  {
    GST_INFO_OBJECT (factory, "couldn't create instance!");
    gst_object_unref (factory);
    return NULL;
  }
}
Esempio n. 23
0
GstRTSPExtensionList *
gst_rtsp_ext_list_get (void)
{
  GstRTSPExtensionList *result;
  GList *walk;

  result = g_new0 (GstRTSPExtensionList, 1);

  for (walk = extensions; walk; walk = g_list_next (walk)) {
    GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data);
    GstElement *element;

    element = gst_element_factory_create (factory, NULL);
    if (!element) {
      GST_ERROR ("could not create extension instance");
      continue;
    }

    GST_DEBUG ("added extension interface for '%s'",
        GST_ELEMENT_NAME (element));
    result->extensions = g_list_prepend (result->extensions, element);
  }
  return result;
}
Esempio n. 24
0
static void
gst_audio_mixer_filter_do_filter (GstAudioMixerFilterFunc filter_func,
    GstElementFactory * factory,
    GstElement ** p_element, GList ** p_collection, gpointer user_data)
{
  /* so, the element is a mixer, let's see if the caller wants it */
  if (filter_func != NULL) {
    if (filter_func (GST_MIXER (*p_element), user_data) == TRUE) {
      *p_collection = g_list_prepend (*p_collection, *p_element);
      /* do not set state back to NULL here on purpose, caller
       * might want to keep the mixer open */
      *p_element = NULL;
    }
  } else {
    gst_element_set_state (*p_element, GST_STATE_NULL);
    *p_collection = g_list_prepend (*p_collection, *p_element);
    *p_element = NULL;
  }

  /* create new element for further probing if the old one was cleared */
  if (*p_element == NULL) {
    *p_element = gst_element_factory_create (factory, NULL);
  }
}
Esempio n. 25
0
//static 
void MediaParserGst::cb_pad_added(GstElement* /* element */, GstPad* new_pad,
                                  gpointer data)
{
    MediaParserGst* parser = static_cast<MediaParserGst*>(data);

    GstCaps* caps = gst_pad_get_caps(new_pad);    
    print_caps(caps);    
    
    GstStructure* str = gst_caps_get_structure (caps, 0);
    if (!str) {
        log_error(_("MediaParserGst: couldn't get structure name."));
        parser->link_to_fakesink(new_pad);
        return;    
    } 
    
    const gchar* caps_name = gst_structure_get_name (str);
    
    bool media_type_audio;

    if (std::equal(caps_name, caps_name+5, "audio")) {
        media_type_audio = true;
    } else if (std::equal(caps_name, caps_name+5, "video")) {
        media_type_audio = false;
    } else {
        log_error(_("MediaParserGst: ignoring stream of type %s."),
                  caps_name);
        parser->link_to_fakesink(new_pad);
        return;
    }    
    
    gboolean parsed = false;
    gboolean framed = false;
    
    gst_structure_get_boolean(str, "parsed", &parsed);
    gst_structure_get_boolean(str, "framed", &framed);
    
    bool already_parsed = parsed || framed;
    
    GstPad* final_pad = 0;
    
    if (already_parsed) {
        final_pad = new_pad;
    } else {
        // We'll try to find a parser, so that we will eventually receive
        // timestamped buffers, on which the MediaParser system relies.
        GstElementFactory* parserfactory = swfdec_gst_get_parser_factory (caps);

        if (!parserfactory) {
            log_error(_("MediaParserGst: Failed to find a parser (media: %s)."),
                      caps_name);
            parser->link_to_fakesink(new_pad);
            return;
        }

        GstElement* parserel = gst_element_factory_create (parserfactory, NULL);
        gst_object_unref (parserfactory);
        if (!parserel) {
            log_error(_("MediaParserGst: Failed to find a parser. We'll continue, "
                        "but either audio or video will not work!"));
            parser->link_to_fakesink(new_pad);
            return;
        }
                     
        gboolean success = gst_bin_add(GST_BIN(parser->_bin), parserel);
        if (!success) {
            gst_object_unref(parserel);
            log_error(_("MediaParserGst: couldn't add parser."));
            parser->link_to_fakesink(new_pad);
            return;
        }
        
        GstPad* sinkpad = gst_element_get_static_pad (parserel, "sink");
        assert(sinkpad);
        
        GstPadLinkReturn ret = gst_pad_link(new_pad, sinkpad);
        
        gst_object_unref(GST_OBJECT(sinkpad));

        if (!GST_PAD_LINK_SUCCESSFUL(ret)) {
            log_error(_("MediaParserGst: couldn't link parser."));
            parser->link_to_fakesink(new_pad);
            return;
        }
        
        final_pad = gst_element_get_static_pad (parserel, "src");
    } 

    if (media_type_audio) {
      
        parser->_audiosink = swfdec_gst_connect_sinkpad_by_pad (final_pad, caps);
        if (!parser->_audiosink) {
            log_error(_("MediaParserGst: couldn't link \"fake\" sink."));
            return;        
        }

        gst_pad_set_chain_function(parser->_audiosink,
                MediaParserGst::cb_chain_func_audio);
        
        g_object_set_data(G_OBJECT (parser->_audiosink), "mediaparser-obj",
                parser);
        
        LOG_ONCE(
            log_unimpl("MediaParserGst won't set codec, sampleRate, "
                "sampleSize, stereo and duration in AudioInfo"); 
        );
        AudioInfo* audioinfo = new AudioInfo(0, 0, 0, false, 0,
                CODEC_TYPE_CUSTOM);
        audioinfo->extra.reset(new ExtraInfoGst(caps));

        parser->_audioInfo.reset(audioinfo);
        log_debug(_("MediaParserGst: Linked audio source (type: %s)"), caps_name); 

    } else {
Esempio n. 26
0
GstElement *
create_codec_bin_from_blueprint (const FsCodec *codec,
    CodecBlueprint *blueprint, const gchar *name, gboolean is_send,
    GError **error)
{
  GstElement *codec_bin = NULL;
  gchar *direction_str = (is_send == TRUE) ? "send" : "receive";
  GList *walk = NULL;
  GstElement *current_element = NULL;
  GstElement *previous_element = NULL;
  GList *pipeline_factory = NULL;

  if (is_send)
    pipeline_factory = blueprint->send_pipeline_factory;
  else
    pipeline_factory = blueprint->receive_pipeline_factory;

  if (!pipeline_factory)
  {
    g_set_error (error, FS_ERROR, FS_ERROR_UNKNOWN_CODEC,
        "The %s codec %s does not have a pipeline,"
        " its probably a special codec",
        fs_media_type_to_string (codec->media_type),
        codec->encoding_name);
    return NULL;
  }

  GST_DEBUG ("creating %s codec bin for id %d, pipeline_factory %p",
    direction_str, codec->id, pipeline_factory);
  if (is_send)
    codec_bin = gst_bin_new (name);
  else
    codec_bin = fs_rtp_bin_error_downgrade_new (name);

  for (walk = g_list_first (pipeline_factory); walk; walk = g_list_next (walk))
  {
    if (g_list_next (g_list_first (walk->data)))
    {
      /* We have to check some kind of configuration to see if we have a
         favorite */
      current_element = gst_element_factory_make ("autoconvert", NULL);

      if (!current_element)
      {
        g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not create autoconvert element");
        goto error;
      }

      g_object_set (current_element, "factories", walk->data, NULL);
    } else {
      current_element =
        gst_element_factory_create (
            GST_ELEMENT_FACTORY (g_list_first (walk->data)->data), NULL);
      if (!current_element)
      {
        g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not create element for pt %d", codec->id);
        goto error;
      }
    }

    if (!gst_bin_add (GST_BIN (codec_bin), current_element))
    {
      g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
        "Could not add new element to %s codec_bin for pt %d",
        direction_str, codec->id);
      goto error;
    }

    if (_g_object_has_property (G_OBJECT (current_element), "pt"))
      g_object_set (current_element, "pt", codec->id,
        NULL);

    /* Lets create the ghost pads on the codec bin */

    if (g_list_previous (walk) == NULL)
      /* if its the first element of the codec bin */
      if (!_create_ghost_pad (current_element,
              is_send ? "src" : "sink", codec_bin, error))
        goto error;

    if (g_list_next (walk) == NULL)
      /* if its the last element of the codec bin */
      if (!_create_ghost_pad (current_element,
              is_send ? "sink" : "src" , codec_bin, error))
        goto error;


    /* let's link them together using the specified media_caps if any
     * this will ensure that multi-codec encoders/decoders will select the
     * appropriate codec based on caps negotiation */
    if (previous_element)
    {
      GstPad *sinkpad;
      GstPad *srcpad;
      GstPadLinkReturn ret;

      if (is_send)
        sinkpad = gst_element_get_static_pad (previous_element, "sink");
      else
        sinkpad = gst_element_get_static_pad (current_element, "sink");

      if (!sinkpad)
      {
        g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not get the sink pad one of the elements in the %s codec bin"
          " for pt %d", direction_str, codec->id);
        goto error;
      }


      if (is_send)
        srcpad = gst_element_get_static_pad (current_element, "src");
      else
        srcpad = gst_element_get_static_pad (previous_element, "src");

      if (!srcpad)
      {
        g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not get the src pad one of the elements in the %s codec bin"
          " for pt %d", direction_str, codec->id);
        gst_object_unref (sinkpad);
        goto error;
      }

      ret = gst_pad_link (srcpad, sinkpad);

      gst_object_unref (srcpad);
      gst_object_unref (sinkpad);

      if (GST_PAD_LINK_FAILED (ret))
      {
        g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not link element inside the %s codec bin for pt %d",
          direction_str, codec->id);
        goto error;
      }
    }

    previous_element = current_element;
  }

  return codec_bin;

 error:
  gst_object_unref (codec_bin);
  return NULL;
}
Esempio n. 27
0
static gint
print_element_info (GstElementFactory * factory)
{
  GstElement *element;
#ifndef GST_DISABLE_LOADSAVE
  GstObjectClass *gstobject_class;
#endif
  GstElementClass *gstelement_class;
  GList *pads;
  GstPad *pad;
  GstStaticPadTemplate *padtemplate;
  gint maxlevel = 0;

  element = gst_element_factory_create (factory, "element");
  if (!element) {
    g_print ("couldn't construct element for some reason\n");
    return -1;
  }
  PUT_START_TAG (0, "element");
  PUT_ESCAPED (1, "name", GST_PLUGIN_FEATURE_NAME (factory));

#ifndef GST_DISABLE_LOADSAVE
  gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
#endif
  gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));

  PUT_START_TAG (1, "details");
  PUT_ESCAPED (2, "long-name", factory->details.longname);
  PUT_ESCAPED (2, "class", factory->details.klass);
  PUT_ESCAPED (2, "description", factory->details.description);
  PUT_ESCAPED (2, "authors", factory->details.author);
  PUT_END_TAG (1, "details");

  output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);

  PUT_START_TAG (1, "pad-templates");
  if (factory->numpadtemplates) {
    pads = factory->staticpadtemplates;
    while (pads) {
      padtemplate = (GstStaticPadTemplate *) (pads->data);
      pads = g_list_next (pads);

      PUT_START_TAG (2, "pad-template");
      PUT_ESCAPED (3, "name", padtemplate->name_template);

      if (padtemplate->direction == GST_PAD_SRC)
        PUT_ESCAPED (3, "direction", "src");
      else if (padtemplate->direction == GST_PAD_SINK)
        PUT_ESCAPED (3, "direction", "sink");
      else
        PUT_ESCAPED (3, "direction", "unknown");

      if (padtemplate->presence == GST_PAD_ALWAYS)
        PUT_ESCAPED (3, "presence", "always");
      else if (padtemplate->presence == GST_PAD_SOMETIMES)
        PUT_ESCAPED (3, "presence", "sometimes");
      else if (padtemplate->presence == GST_PAD_REQUEST) {
        PUT_ESCAPED (3, "presence", "request");
        PUT_ESCAPED (3, "request-function",
            GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
      } else
        PUT_ESCAPED (3, "presence", "unknown");

      if (padtemplate->static_caps.string) {
        print_caps (gst_static_caps_get (&padtemplate->static_caps), 3);
      }
      PUT_END_TAG (2, "pad-template");
    }
  }
  PUT_END_TAG (1, "pad-templates");

  PUT_START_TAG (1, "element-flags");
  PUT_END_TAG (1, "element-flags");

  if (GST_IS_BIN (element)) {
    PUT_START_TAG (1, "bin-flags");

    PUT_END_TAG (1, "bin-flags");
  }


  PUT_START_TAG (1, "element-implementation");

  PUT_STRING (2, "<state-change function=\"%s\"/>",
      GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));

#ifndef GST_DISABLE_LOADSAVE
  PUT_STRING (2, "<save function=\"%s\"/>",
      GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
  PUT_STRING (2, "<load function=\"%s\"/>",
      GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
#endif
  PUT_END_TAG (1, "element-implementation");

  PUT_START_TAG (1, "clocking-interaction");
  if (gst_element_requires_clock (element)) {
    PUT_STRING (2, "<requires-clock/>");
  }
  if (gst_element_provides_clock (element)) {
    GstClock *clock;

    clock = gst_element_get_clock (element);
    if (clock)
      PUT_STRING (2, "<provides-clock name=\"%s\"/>", GST_OBJECT_NAME (clock));
  }
  PUT_END_TAG (1, "clocking-interaction");

  if (gst_element_is_indexable (element)) {
    PUT_STRING (1, "<indexing-capabilities/>");
  }

  PUT_START_TAG (1, "pads");
  if (element->numpads) {
    const GList *pads;

    pads = element->pads;
    while (pads) {
      pad = GST_PAD (pads->data);
      pads = g_list_next (pads);

      PUT_START_TAG (2, "pad");
      PUT_ESCAPED (3, "name", gst_pad_get_name (pad));

      if (gst_pad_get_direction (pad) == GST_PAD_SRC)
        PUT_ESCAPED (3, "direction", "src");
      else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
        PUT_ESCAPED (3, "direction", "sink");
      else
        PUT_ESCAPED (3, "direction", "unknown");

      if (pad->padtemplate)
        PUT_ESCAPED (3, "template", pad->padtemplate->name_template);

      PUT_START_TAG (3, "implementation");
      if (pad->chainfunc)
        PUT_STRING (4, "<chain-based function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
      if (pad->getrangefunc)
        PUT_STRING (4, "<get-range-based function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
      if (pad->eventfunc != gst_pad_event_default)
        PUT_STRING (4, "<event-function function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
      if (pad->queryfunc != gst_pad_query_default)
        PUT_STRING (4, "<query-function function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
      if (pad->querytypefunc != gst_pad_get_query_types_default) {
        PUT_STRING (4, "<query-type-func function=\"%s\">",
            GST_DEBUG_FUNCPTR_NAME (pad->querytypefunc));
        print_query_types (gst_pad_get_query_types (pad), 5);
        PUT_END_TAG (4, "query-type-func");
      }

      if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
        PUT_STRING (4, "<iterintlink-function function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));

      if (pad->bufferallocfunc)
        PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>",
            GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
      PUT_END_TAG (3, "implementation");

      if (pad->caps) {
        print_caps (pad->caps, 3);
      }
      PUT_END_TAG (2, "pad");
    }
  }
  PUT_END_TAG (1, "pads");

  print_element_properties (element, 1);
  print_element_signals (element, 1);

  /* for compound elements */
  /* FIXME: gst_bin_get_list does not exist anymore
     if (GST_IS_BIN (element)) {
     GList *children;
     GstElement *child;
     PUT_START_TAG (1, "children");
     children = (GList *) gst_bin_get_list (GST_BIN (element));
     while (children) {
     child = GST_ELEMENT (children->data);
     children = g_list_next (children);

     PUT_ESCAPED (2, "child", GST_ELEMENT_NAME (child));
     }
     PUT_END_TAG (1, "children");
     }
   */
  PUT_END_TAG (0, "element");

  return 0;
}
static GstElement *
gst_auto_convert_add_element (GstAutoConvert * autoconvert,
    GstElementFactory * factory)
{
  GstElement *element = NULL;
  GstPad *internal_sinkpad = NULL;
  GstPad *internal_srcpad = NULL;
  GstPad *sinkpad = NULL;
  GstPad *srcpad = NULL;
  GstPadLinkReturn padlinkret;

  GST_DEBUG_OBJECT (autoconvert, "Adding element %s to the autoconvert bin",
      gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));

  element = gst_element_factory_create (factory, NULL);
  if (!element)
    return NULL;

  if (!gst_bin_add (GST_BIN (autoconvert), element)) {
    GST_ERROR_OBJECT (autoconvert, "Could not add element %s to the bin",
        GST_OBJECT_NAME (element));
    gst_object_unref (element);
    return NULL;
  }

  srcpad = get_pad_by_direction (element, GST_PAD_SRC);
  if (!srcpad) {
    GST_ERROR_OBJECT (autoconvert, "Could not find source in %s",
        GST_OBJECT_NAME (element));
    goto error;
  }

  sinkpad = get_pad_by_direction (element, GST_PAD_SINK);
  if (!sinkpad) {
    GST_ERROR_OBJECT (autoconvert, "Could not find sink in %s",
        GST_OBJECT_NAME (element));
    goto error;
  }

  internal_sinkpad =
      gst_pad_new_from_static_template (&sink_internal_template,
      "sink_internal");
  internal_srcpad =
      gst_pad_new_from_static_template (&src_internal_template, "src_internal");

  if (!internal_sinkpad || !internal_srcpad) {
    GST_ERROR_OBJECT (autoconvert, "Could not create internal pads");
    if (internal_srcpad)
      gst_object_unref (internal_srcpad);
    if (internal_sinkpad)
      gst_object_unref (internal_sinkpad);
    goto error;
  }

  g_object_weak_ref (G_OBJECT (element), (GWeakNotify) gst_object_unref,
      internal_sinkpad);
  g_object_weak_ref (G_OBJECT (element), (GWeakNotify) gst_object_unref,
      internal_srcpad);

  gst_pad_set_active (internal_sinkpad, TRUE);
  gst_pad_set_active (internal_srcpad, TRUE);

  g_object_set_qdata (G_OBJECT (internal_srcpad), parent_quark, autoconvert);
  g_object_set_qdata (G_OBJECT (internal_sinkpad), parent_quark, autoconvert);

  gst_pad_set_chain_function (internal_sinkpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_chain));
  gst_pad_set_chain_list_function (internal_sinkpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_chain_list));
  gst_pad_set_event_function (internal_sinkpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_event));
  gst_pad_set_query_function (internal_sinkpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_query));

  gst_pad_set_event_function (internal_srcpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_src_event));
  gst_pad_set_query_function (internal_srcpad,
      GST_DEBUG_FUNCPTR (gst_auto_convert_internal_src_query));

  padlinkret = gst_pad_link_full (internal_srcpad, sinkpad,
      GST_PAD_LINK_CHECK_NOTHING);
  if (GST_PAD_LINK_FAILED (padlinkret)) {
    GST_WARNING_OBJECT (autoconvert, "Could not links pad %s:%s to %s:%s"
        " for reason %d",
        GST_DEBUG_PAD_NAME (internal_srcpad),
        GST_DEBUG_PAD_NAME (sinkpad), padlinkret);
    goto error;
  }

  padlinkret = gst_pad_link_full (srcpad, internal_sinkpad,
      GST_PAD_LINK_CHECK_NOTHING);
  if (GST_PAD_LINK_FAILED (padlinkret)) {
    GST_WARNING_OBJECT (autoconvert, "Could not links pad %s:%s to %s:%s"
        " for reason %d",
        GST_DEBUG_PAD_NAME (internal_srcpad),
        GST_DEBUG_PAD_NAME (sinkpad), padlinkret);
    goto error;
  }

  g_object_set_qdata (G_OBJECT (element),
      internal_srcpad_quark, internal_srcpad);
  g_object_set_qdata (G_OBJECT (element),
      internal_sinkpad_quark, internal_sinkpad);

  /* Iffy */
  gst_element_sync_state_with_parent (element);

  /* Increment the reference count we will return to the caller */
  gst_object_ref (element);

  /* unref sink and src pad */
  gst_object_unref (srcpad);
  gst_object_unref (sinkpad);
  return element;

error:
  gst_element_set_locked_state (element, TRUE);
  gst_element_set_state (element, GST_STATE_NULL);
  gst_bin_remove (GST_BIN (autoconvert), element);

  if (srcpad)
    gst_object_unref (srcpad);
  if (sinkpad)
    gst_object_unref (sinkpad);

  return NULL;
}
Esempio n. 29
0
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);
}
Esempio n. 30
0
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);
  }
}