Example #1
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;
}
Example #2
0
static gpointer owr_payload_detect_codecs(gpointer data)
{
    GList *decoder_factories;
    GList *encoder_factories;
    GstCaps *caps;

    OWR_UNUSED(data);

    decoder_factories = gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECODER |
                                                              GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO,
                                                              GST_RANK_MARGINAL);
    encoder_factories = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER |
                                                               GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO,
                                                               GST_RANK_MARGINAL);

    caps = gst_caps_new_empty_simple("video/x-h264");
    h264_decoders = gst_element_factory_list_filter(decoder_factories, caps, GST_PAD_SINK, FALSE);
    h264_encoders = gst_element_factory_list_filter(encoder_factories, caps, GST_PAD_SRC, FALSE);
    gst_caps_unref (caps);

    caps = gst_caps_new_empty_simple("video/x-vp8");
    vp8_decoders = gst_element_factory_list_filter(decoder_factories, caps, GST_PAD_SINK, FALSE);
    vp8_encoders = gst_element_factory_list_filter(encoder_factories, caps, GST_PAD_SRC, FALSE);
    gst_caps_unref (caps);

    gst_plugin_feature_list_free(decoder_factories);
    gst_plugin_feature_list_free(encoder_factories);

    h264_decoders = g_list_sort(h264_decoders, gst_plugin_feature_rank_compare_func);
    h264_encoders = g_list_sort(h264_encoders, gst_plugin_feature_rank_compare_func);
    vp8_decoders = g_list_sort(vp8_decoders, gst_plugin_feature_rank_compare_func);
    vp8_encoders = g_list_sort(vp8_encoders, gst_plugin_feature_rank_compare_func);

    return NULL;
}
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;
}
Example #4
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;
}
Example #5
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;
}
Example #6
0
static void
gst_auto_convert_dispose (GObject * object)
{
  GstAutoConvert *autoconvert = GST_AUTO_CONVERT (object);

  gst_pad_set_fixatecaps_function (autoconvert->sinkpad, NULL);

  GST_AUTOCONVERT_LOCK (autoconvert);
  if (autoconvert->current_subelement) {
    gst_object_unref (autoconvert->current_subelement);
    autoconvert->current_subelement = NULL;
    autoconvert->current_internal_sinkpad = NULL;
    autoconvert->current_internal_srcpad = NULL;
  }

  g_list_foreach (autoconvert->cached_events, (GFunc) gst_mini_object_unref,
      NULL);
  g_list_free (autoconvert->cached_events);
  autoconvert->cached_events = NULL;

  if (autoconvert->factories) {
    gst_plugin_feature_list_free (autoconvert->factories);
    autoconvert->factories = NULL;
  }
  GST_AUTOCONVERT_UNLOCK (autoconvert);

  G_OBJECT_CLASS (parent_class)->dispose (object);
}
/**
 * gst_factory_list_get_elements:
 * @type: a #GstFactoryListType
 *
 * Get a sorted list of factories of @type.
 *
 * Returns: a #GValueArray of #GstElementFactory elements. Use
 * g_value_array_free() after usage.
 */
GValueArray *
gst_factory_list_get_elements (GstFactoryListType type)
{
  GValueArray *result;
  GList *walk, *list;
  FilterData data;

  result = g_value_array_new (0);

  /* prepare type */
  data.type = type;

  /* get the feature list using the filter */
  list =
      gst_default_registry_feature_filter ((GstPluginFeatureFilter)
      element_filter, FALSE, &data);

  /* convert to an array */
  for (walk = list; walk; walk = g_list_next (walk)) {
    GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data);
    GValue val = { 0, };

    g_value_init (&val, G_TYPE_OBJECT);
    g_value_set_object (&val, factory);
    g_value_array_append (result, &val);
    g_value_unset (&val);
  }
  gst_plugin_feature_list_free (list);

  /* sort on rank and name */
  g_value_array_sort (result, (GCompareFunc) compare_ranks);

  return result;
}
void
gst_auto_video_convert_update_factory_list (GstAutoVideoConvert *
    autovideoconvert)
{
  /* use a static mutex to protect factories list and factories cookie */
  g_static_mutex_lock (&factories_mutex);

  /* test if a factories list already exist or not */
  if (!factories) {
    /* no factories list create it */
    factories_cookie =
        gst_registry_get_feature_list_cookie (gst_registry_get ());
    factories = gst_auto_video_convert_create_factory_list (autovideoconvert);
  } else {
    /* a factories list exist but is it up to date? */
    if (factories_cookie !=
        gst_registry_get_feature_list_cookie (gst_registry_get ())) {
      /* we need to update the factories list */
      /* first free the old one */
      gst_plugin_feature_list_free (factories);
      /* then create an updated one */
      factories_cookie =
          gst_registry_get_feature_list_cookie (gst_registry_get ());
      factories = gst_auto_video_convert_create_factory_list (autovideoconvert);
    }
  }

  g_static_mutex_unlock (&factories_mutex);
}
static void
setup (void)
{
  GList *features, *f;
  GList *plugins, *p;
  gchar **ignorelist = NULL;
  const gchar *STATE_IGNORE_ELEMENTS = NULL;
  GstRegistry *def;

  GST_DEBUG ("getting elements for package %s", PACKAGE);
  STATE_IGNORE_ELEMENTS = g_getenv ("GST_STATE_IGNORE_ELEMENTS");
  if (!g_getenv ("GST_NO_STATE_IGNORE_ELEMENTS") && STATE_IGNORE_ELEMENTS) {
    GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
    ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0);
  }

  def = gst_registry_get ();

  plugins = gst_registry_get_plugin_list (def);

  for (p = plugins; p; p = p->next) {
    GstPlugin *plugin = p->data;

    if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
      continue;

    features =
        gst_registry_get_feature_list_by_plugin (def,
        gst_plugin_get_name (plugin));

    for (f = features; f; f = f->next) {
      GstPluginFeature *feature = f->data;
      const gchar *name = gst_plugin_feature_get_name (feature);
      gboolean ignore = FALSE;

      if (!GST_IS_ELEMENT_FACTORY (feature))
        continue;

      if (ignorelist) {
        gchar **s;

        for (s = ignorelist; s && *s; ++s) {
          if (g_str_has_prefix (name, *s)) {
            GST_DEBUG ("ignoring element %s", name);
            ignore = TRUE;
          }
        }
        if (ignore)
          continue;
      }

      GST_DEBUG ("adding element %s", name);
      elements = g_list_prepend (elements, (gpointer) g_strdup (name));
    }
    gst_plugin_feature_list_free (features);
  }
  gst_plugin_list_free (plugins);
  g_strfreev (ignorelist);
}
Example #10
0
GstCaps *
gst_type_find_helper_get_range (GstObject * obj,
    GstTypeFindHelperGetRangeFunction func, guint64 size,
    GstTypeFindProbability * prob)
{
  GstTypeFindHelper helper;
  GstTypeFind find;
  GSList *walk;
  GList *l, *type_list;
  GstCaps *result = NULL;

  g_return_val_if_fail (GST_IS_OBJECT (obj), NULL);
  g_return_val_if_fail (func != NULL, NULL);

  helper.buffers = NULL;
  helper.size = size;
  helper.last_offset = 0;
  helper.func = func;
  helper.best_probability = 0;
  helper.caps = NULL;
  helper.obj = obj;

  find.data = &helper;
  find.peek = helper_find_peek;
  find.suggest = helper_find_suggest;

  if (size == 0 || size == (guint64) - 1) {
    find.get_length = NULL;
  } else {
    find.get_length = helper_find_get_length;
  }

  /* FIXME: we need to keep this list within the registry */
  type_list = gst_type_find_factory_get_list ();
  type_list = g_list_sort (type_list, type_find_factory_rank_cmp);

  for (l = type_list; l; l = l->next) {
    helper.factory = GST_TYPE_FIND_FACTORY (l->data);
    gst_type_find_factory_call_function (helper.factory, &find);
    if (helper.best_probability >= GST_TYPE_FIND_MAXIMUM)
      break;
  }
  gst_plugin_feature_list_free (type_list);

  for (walk = helper.buffers; walk; walk = walk->next)
    gst_buffer_unref (GST_BUFFER_CAST (walk->data));
  g_slist_free (helper.buffers);

  if (helper.best_probability > 0)
    result = helper.caps;

  if (prob)
    *prob = helper.best_probability;

  GST_LOG_OBJECT (obj, "Returning %" GST_PTR_FORMAT " (probability = %u)",
      result, (guint) helper.best_probability);

  return result;
}
Example #11
0
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 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);
}
EXPORT_C
#endif

GstCaps *
gst_type_find_helper_for_buffer (GstObject * obj, GstBuffer * buf,
                                 GstTypeFindProbability * prob)
{
    GstTypeFindBufHelper helper;
    GstTypeFind find;
    GList *l, *type_list;
    GstCaps *result = NULL;

    g_return_val_if_fail (buf != NULL, NULL);
    g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
    g_return_val_if_fail (GST_BUFFER_OFFSET (buf) == 0 ||
                          GST_BUFFER_OFFSET (buf) == GST_BUFFER_OFFSET_NONE, NULL);

    helper.data = GST_BUFFER_DATA (buf);
    helper.size = GST_BUFFER_SIZE (buf);
    helper.best_probability = 0;
    helper.caps = NULL;
    helper.obj = obj;

    if (helper.data == NULL || helper.size == 0)
        return NULL;

    find.data = &helper;
    find.peek = buf_helper_find_peek;
    find.suggest = buf_helper_find_suggest;
    find.get_length = NULL;

    /* FIXME: we need to keep this list within the registry */
    type_list = gst_type_find_factory_get_list ();
    type_list = g_list_sort (type_list, type_find_factory_rank_cmp);

    for (l = type_list; l; l = l->next) {
        helper.factory = GST_TYPE_FIND_FACTORY (l->data);
        gst_type_find_factory_call_function (helper.factory, &find);
        if (helper.best_probability >= GST_TYPE_FIND_MAXIMUM)
            break;
    }
    gst_plugin_feature_list_free (type_list);

    if (helper.best_probability > 0)
        result = helper.caps;

    if (prob)
        *prob = helper.best_probability;

    GST_LOG_OBJECT (obj, "Returning %" GST_PTR_FORMAT " (probability = %u)",
                    result, (guint) helper.best_probability);

    return result;
}
Example #14
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);
}
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;
  }
}
Example #16
0
int Uridecodebin::autoplug_continue_cb(GstElement* /*bin */,
                                       GstPad* pad,
                                       GstCaps* caps,
                                       gpointer /*user_data*/) {
  GList* list = gst_registry_feature_filter(
      gst_registry_get(), (GstPluginFeatureFilter)sink_factory_filter, FALSE, caps);
  int length = g_list_length(list);
  gst_plugin_feature_list_free(list);

  if (length == 0 || pad_is_image(get_pad_name(pad))) return 0;

  return 1;
}
EXPORT_C
#endif

GstCaps *
gst_type_find_helper_for_extension (GstObject * obj, const gchar * extension)
{
    GList *l, *type_list;
    GstCaps *result = NULL;

    g_return_val_if_fail (extension != NULL, NULL);

    GST_LOG_OBJECT (obj, "finding caps for extension %s", extension);

    type_list = gst_type_find_factory_get_list ();
    type_list = g_list_sort (type_list, type_find_factory_rank_cmp);

    for (l = type_list; l; l = g_list_next (l)) {
        GstTypeFindFactory *factory;
        gchar **ext;
        gint i;

        factory = GST_TYPE_FIND_FACTORY (l->data);

        /* get the extension that this typefind factory can handle */
        ext = gst_type_find_factory_get_extensions (factory);
        if (ext == NULL)
            continue;

        /* we only want to check those factories without a function */
        if (factory->function != NULL)
            continue;

        /* there are extension, see if one of them matches the requested
         * extension */
        for (i = 0; ext[i]; i++) {
            if (strcmp (ext[i], extension) == 0) {
                /* we found a matching extension, take the caps */
                if ((result = gst_type_find_factory_get_caps (factory))) {
                    gst_caps_ref (result);
                    goto done;
                }
            }
        }
    }
done:
    gst_plugin_feature_list_free (type_list);

    GST_LOG_OBJECT (obj, "Returning %" GST_PTR_FORMAT, result);

    return result;
}
gint list_gaudieffects_features()
{
  GList *list, *walk;

  g_print("Available gaudieffects features :\n");
  list = gst_registry_get_feature_list_by_plugin(GET_PLUGIN_REGISTRY, "gaudieffects");
  for (walk = list; walk != NULL; walk = g_list_next(walk))
    g_print("feature: <%s>\n",
	    gst_plugin_feature_get_name((GstPluginFeature *)walk->data));

  gst_plugin_feature_list_free(list);

  return 0;
}
static GstElementFactory *
get_encoder_factory (GstCaps * caps)
{
  GstElementFactory *fact = NULL;
  GList *encoders, *tmp;

  tmp =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER,
      GST_RANK_MARGINAL);
  encoders = gst_element_factory_list_filter (tmp, caps, GST_PAD_SRC, FALSE);
  gst_plugin_feature_list_free (tmp);

  for (tmp = encoders; tmp; tmp = tmp->next) {
    /* We just pick the first one */
    fact = (GstElementFactory *) tmp->data;
    gst_object_ref (fact);
    break;
  }

  gst_plugin_feature_list_free (encoders);

  return fact;
}
Example #20
0
static GstElementFactory *
get_audio_encoder_factory (GstEncodingProfile *profile)
{
	GstEncodingProfile *p = get_audio_encoding_profile (profile);
	GstElementFactory *f;
	GList *l;
	GList *fl;

	if (p == NULL)
		return NULL;

	l = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER, GST_RANK_MARGINAL);
	fl = gst_element_factory_list_filter (l, gst_encoding_profile_get_format (p), GST_PAD_SRC, FALSE);

	if (fl != NULL) {
		f = gst_object_ref (fl->data);
	} else {
		g_warning ("no encoder factory for profile %s", gst_encoding_profile_get_name (p));
		f = NULL;
	}
	gst_plugin_feature_list_free (l);
	gst_plugin_feature_list_free (fl);
	return f;
}
Example #21
0
/**
 * gst_type_find_helper_for_data_with_extension:
 * @obj: (allow-none): object doing the typefinding, or %NULL (used for logging)
 * @data: (transfer none) (array length=size): * a pointer with data to typefind
 * @size: the size of @data
 * @extension: (allow-none): extension of the media, or %NULL
 * @prob: (out) (allow-none): location to store the probability of the found
 *     caps, or %NULL
 *
 * Tries to find what type of data is contained in the given @data, the
 * assumption being that the data represents the beginning of the stream or
 * file.
 *
 * All available typefinders will be called on the data in order of rank. If
 * a typefinding function returns a probability of %GST_TYPE_FIND_MAXIMUM,
 * typefinding is stopped immediately and the found caps will be returned
 * right away. Otherwise, all available typefind functions will the tried,
 * and the caps with the highest probability will be returned, or %NULL if
 * the content of @data could not be identified.
 *
 * When @extension is not %NULL, this function will first try the typefind
 * functions for the given extension, which might speed up the typefinding
 * in many cases.
 *
 * Free-function: gst_caps_unref
 *
 * Returns: (transfer full) (nullable): the #GstCaps corresponding to the data,
 *     or %NULL if no type could be found. The caller should free the caps
 *     returned with gst_caps_unref().
 *
 * Since: 1.16
 *
 */
GstCaps *
gst_type_find_helper_for_data_with_extension (GstObject * obj,
    const guint8 * data, gsize size, const gchar * extension,
    GstTypeFindProbability * prob)
{
  GstTypeFindBufHelper helper;
  GstTypeFind find;
  GList *l, *type_list;
  GstCaps *result = NULL;

  g_return_val_if_fail (data != NULL, NULL);

  helper.data = data;
  helper.size = size;
  helper.best_probability = GST_TYPE_FIND_NONE;
  helper.caps = NULL;
  helper.obj = obj;

  if (helper.data == NULL || helper.size == 0)
    return NULL;

  find.data = &helper;
  find.peek = buf_helper_find_peek;
  find.suggest = buf_helper_find_suggest;
  find.get_length = NULL;

  type_list = gst_type_find_factory_get_list ();
  type_list = prioritize_extension (obj, type_list, extension);

  for (l = type_list; l; l = l->next) {
    helper.factory = GST_TYPE_FIND_FACTORY (l->data);
    gst_type_find_factory_call_function (helper.factory, &find);
    if (helper.best_probability >= GST_TYPE_FIND_MAXIMUM)
      break;
  }
  gst_plugin_feature_list_free (type_list);

  if (helper.best_probability > 0)
    result = helper.caps;

  if (prob)
    *prob = helper.best_probability;

  GST_LOG_OBJECT (obj, "Returning %" GST_PTR_FORMAT " (probability = %u)",
      result, (guint) helper.best_probability);

  return result;
}
Example #22
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);
}
Example #23
0
/**
 * gst_plugin_find_feature_by_name:
 * @plugin: plugin to get the feature from
 * @name: The name of the feature to find
 *
 * Find a feature of the given name in the given plugin.
 *
 * Returns: a GstPluginFeature or NULL if the feature was not found.
 */
GstPluginFeature *
gst_plugin_find_feature_by_name (GstPlugin * plugin, const gchar * name)
{
  GList *walk;
  GstPluginFeature *result = NULL;

  g_return_val_if_fail (name != NULL, NULL);

  walk = gst_filter_run (plugin->features,
      (GstFilterFunc) gst_plugin_feature_name_filter, TRUE, (void *) name);

  if (walk) {
    result = GST_PLUGIN_FEATURE (walk->data);

    gst_object_ref (result);
    gst_plugin_feature_list_free (walk);
  }

  return result;
}
/**
 * gst_protection_select_system:
 * @system_identifiers: (transfer none): A null terminated array of strings
 * that contains the UUID values of each protection system that is to be
 * checked.
 *
 * Iterates the supplied list of UUIDs and checks the GstRegistry for
 * an element that supports one of the supplied UUIDs. If more than one
 * element matches, the system ID of the highest ranked element is selected.
 *
 * Returns: (transfer none): One of the strings from @system_identifiers that
 * indicates the highest ranked element that implements the protection system
 * indicated by that system ID, or %NULL if no element has been found.
 *
 * Since: 1.6
 */
const gchar *
gst_protection_select_system (const gchar ** system_identifiers)
{
  GList *decryptors, *walk;
  const gchar *retval = NULL;

  decryptors =
      gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DECRYPTOR,
      GST_RANK_MARGINAL);

  for (walk = decryptors; !retval && walk; walk = g_list_next (walk)) {
    GstElementFactory *fact = (GstElementFactory *) walk->data;

    retval = gst_protection_factory_check (fact, system_identifiers);
  }

  gst_plugin_feature_list_free (decryptors);

  return retval;
}
Example #25
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);
}
static void
gst_auto_convert_dispose (GObject * object)
{
  GstAutoConvert *autoconvert = GST_AUTO_CONVERT (object);

  g_clear_object (&autoconvert->current_subelement);
  g_clear_object (&autoconvert->current_internal_sinkpad);
  g_clear_object (&autoconvert->current_internal_srcpad);

  for (;;) {
    GList *factories = g_atomic_pointer_get (&autoconvert->factories);

    if (g_atomic_pointer_compare_and_exchange (&autoconvert->factories,
            factories, NULL)) {
      gst_plugin_feature_list_free (factories);
      break;
    }
  }

  G_OBJECT_CLASS (gst_auto_convert_parent_class)->dispose (object);
}
static void
print_plugin (const gchar * marker, GstRegistry * registry, GstPlugin * plugin)
{
  const gchar *name;
  GList *features, *f;

  name = gst_plugin_get_name (plugin);

  GST_DEBUG ("%s: plugin %p %d %s file: %s", marker, plugin,
      GST_OBJECT_REFCOUNT (plugin), name,
      GST_STR_NULL (gst_plugin_get_filename (plugin)));

  features = gst_registry_get_feature_list_by_plugin (registry, name);
  for (f = features; f != NULL; f = f->next) {
    GstPluginFeature *feature;

    feature = GST_PLUGIN_FEATURE (f->data);

    GST_LOG ("%s:    feature: %p %s", marker, feature,
        GST_OBJECT_NAME (feature));
  }
  gst_plugin_feature_list_free (features);
}
Example #28
0
/**
 * gst_plugin_find_feature:
 * @plugin: plugin to get the feature from
 * @name: The name of the feature to find
 * @type: The type of the feature to find
 *
 * Find a feature of the given name and type in the given plugin.
 *
 * Returns: a GstPluginFeature or NULL if the feature was not found.
 */
GstPluginFeature *
gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type)
{
  GList *walk;
  GstPluginFeature *result = NULL;
  GstTypeNameData data;

  g_return_val_if_fail (name != NULL, NULL);

  data.type = type;
  data.name = name;

  walk = gst_filter_run (plugin->features,
      (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, &data);

  if (walk) {
    result = GST_PLUGIN_FEATURE (walk->data);

    gst_object_ref (result);
    gst_plugin_feature_list_free (walk);
  }

  return result;
}
Example #29
0
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);
}
Example #30
0
/**
 * gst_type_find_helper_get_range_ext:
 * @obj: A #GstObject that will be passed as first argument to @func
 * @func: (scope call): A generic #GstTypeFindHelperGetRangeFunction that will
 *        be used to access data at random offsets when doing the typefinding
 * @size: The length in bytes
 * @extension: extension of the media
 * @prob: (out) (allow-none): location to store the probability of the found
 *     caps, or #NULL
 *
 * Utility function to do pull-based typefinding. Unlike gst_type_find_helper()
 * however, this function will use the specified function @func to obtain the
 * data needed by the typefind functions, rather than operating on a given
 * source pad. This is useful mostly for elements like tag demuxers which
 * strip off data at the beginning and/or end of a file and want to typefind
 * the stripped data stream before adding their own source pad (the specified
 * callback can then call the upstream peer pad with offsets adjusted for the
 * tag size, for example).
 *
 * When @extension is not NULL, this function will first try the typefind
 * functions for the given extension, which might speed up the typefinding
 * in many cases.
 *
 * Free-function: gst_caps_unref
 *
 * Returns: (transfer full): the #GstCaps corresponding to the data stream.
 *     Returns #NULL if no #GstCaps matches the data stream.
 *
 * Since: 0.10.26
 */
GstCaps *
gst_type_find_helper_get_range_ext (GstObject * obj,
    GstTypeFindHelperGetRangeFunction func, guint64 size,
    const gchar * extension, GstTypeFindProbability * prob)
{
  GstTypeFindHelper helper;
  GstTypeFind find;
  GSList *walk;
  GList *l, *type_list;
  GstCaps *result = NULL;
  gint pos = 0;

  g_return_val_if_fail (GST_IS_OBJECT (obj), NULL);
  g_return_val_if_fail (func != NULL, NULL);

  helper.buffers = NULL;
  helper.size = size;
  helper.last_offset = 0;
  helper.func = func;
  helper.best_probability = GST_TYPE_FIND_NONE;
  helper.caps = NULL;
  helper.obj = obj;

  find.data = &helper;
  find.peek = helper_find_peek;
  find.suggest = helper_find_suggest;

  if (size == 0 || size == (guint64) - 1) {
    find.get_length = NULL;
  } else {
    find.get_length = helper_find_get_length;
  }

  type_list = gst_type_find_factory_get_list ();

  /* move the typefinders for the extension first in the list. The idea is that
   * when one of them returns MAX we don't need to search further as there is a
   * very high chance we got the right type. */
  if (extension) {
    GList *next;

    GST_LOG_OBJECT (obj, "sorting typefind for extension %s to head",
        extension);

    for (l = type_list; l; l = next) {
      GstTypeFindFactory *factory;
      gint i;
      gchar **ext;

      next = l->next;

      factory = GST_TYPE_FIND_FACTORY (l->data);

      ext = gst_type_find_factory_get_extensions (factory);
      if (ext == NULL)
        continue;

      GST_LOG_OBJECT (obj, "testing factory %s for extension %s",
          GST_PLUGIN_FEATURE_NAME (factory), extension);

      for (i = 0; ext[i]; i++) {
        if (strcmp (ext[i], extension) == 0) {
          /* found extension, move in front */
          GST_LOG_OBJECT (obj, "moving typefind for extension %s to head",
              extension);
          /* remove entry from list */
          type_list = g_list_delete_link (type_list, l);
          /* insert at the position */
          type_list = g_list_insert (type_list, factory, pos);
          /* next element will be inserted after this one */
          pos++;
          break;
        }
      }
    }
  }

  for (l = type_list; l; l = l->next) {
    helper.factory = GST_TYPE_FIND_FACTORY (l->data);
    gst_type_find_factory_call_function (helper.factory, &find);
    if (helper.best_probability >= GST_TYPE_FIND_MAXIMUM)
      break;
  }
  gst_plugin_feature_list_free (type_list);

  for (walk = helper.buffers; walk; walk = walk->next)
    gst_buffer_unref (GST_BUFFER_CAST (walk->data));
  g_slist_free (helper.buffers);

  if (helper.best_probability > 0)
    result = helper.caps;

  if (prob)
    *prob = helper.best_probability;

  GST_LOG_OBJECT (obj, "Returning %" GST_PTR_FORMAT " (probability = %u)",
      result, (guint) helper.best_probability);

  return result;
}