Ejemplo n.º 1
0
static gpointer
_get_decoder_factories (gpointer arg)
{
  GstElementClass *klass = arg;
  GList *factories;
  GstPadTemplate *templ = gst_element_class_get_pad_template (klass,
      "sink");
  RsnDecFactoryFilterCtx ctx = { NULL, };
  GstCaps *raw;
  gboolean raw_audio;

  ctx.desired_caps = gst_pad_template_get_caps (templ);

  raw = gst_caps_from_string ("audio/x-raw-float");
  raw_audio = gst_caps_can_intersect (raw, ctx.desired_caps);
  if (raw_audio) {
    GstCaps *sub = gst_caps_subtract (ctx.desired_caps, raw);
    ctx.desired_caps = sub;
  } else {
    gst_caps_ref (ctx.desired_caps);
  }
  gst_caps_unref (raw);

  /* Set decoder caps to empty. Will be filled by the factory_filter */
  ctx.decoder_caps = gst_caps_new_empty ();
  GST_DEBUG ("Finding factories for caps: %" GST_PTR_FORMAT, ctx.desired_caps);

  factories = gst_default_registry_feature_filter (
      (GstPluginFeatureFilter) rsndec_factory_filter, FALSE, &ctx);

  /* If these are audio caps, we add audioconvert, which is not a decoder,
     but allows raw audio to go through relatively unmolested - this will
     come handy when we have to send placeholder silence to allow preroll
     for those DVDs which have titles with no audio track. */
  if (raw_audio) {
    GstPluginFeature *feature;
    GST_DEBUG ("These are audio caps, adding audioconvert");
    feature =
        gst_default_registry_find_feature ("audioconvert",
        GST_TYPE_ELEMENT_FACTORY);
    if (feature) {
      factories = g_list_append (factories, feature);
    } else {
      GST_WARNING ("Could not find feature audioconvert");
    }
  }

  factories = g_list_sort (factories, (GCompareFunc) sort_by_ranks);

  GST_DEBUG ("Available decoder caps %" GST_PTR_FORMAT, ctx.decoder_caps);
  gst_caps_unref (ctx.decoder_caps);
  gst_caps_unref (ctx.desired_caps);

  return factories;
}
Ejemplo n.º 2
0
static int
print_element_features (const gchar * element_name)
{
  GstPluginFeature *feature;

  /* FIXME implement other pretty print function for these */
  feature = gst_default_registry_find_feature (element_name,
      GST_TYPE_INDEX_FACTORY);
  if (feature) {
    n_print ("%s: an index\n", element_name);
    return 0;
  }
  feature = gst_default_registry_find_feature (element_name,
      GST_TYPE_TYPE_FIND_FACTORY);
  if (feature) {
    n_print ("%s: a typefind function\n", element_name);
    return 0;
  }

  return -1;
}
Ejemplo n.º 3
0
gboolean
have_element (const gchar * element_name)
{
  GstPluginFeature *feature;

  feature = gst_default_registry_find_feature (element_name,
      GST_TYPE_ELEMENT_FACTORY);
  if (feature) {
    g_object_unref (feature);
    return TRUE;
  }
  return FALSE;
}
Ejemplo n.º 4
0
static GstElement *
gst_auto_convert_get_subelement (GstAutoConvert * autoconvert,
    gboolean query_only)
{
  GstElement *element = NULL;
  gboolean initial_identity;

  GST_AUTOCONVERT_LOCK (autoconvert);
  if (autoconvert->current_subelement)
    element = gst_object_ref (autoconvert->current_subelement);
  initial_identity = autoconvert->initial_identity;
  GST_AUTOCONVERT_UNLOCK (autoconvert);

  if (G_UNLIKELY (!query_only && element == NULL && initial_identity)) {
    /* No current sub-element - create an identity and install it */
    GstElementFactory *identity_feature;
    GstElement *identity;

    GST_INFO_OBJECT (autoconvert,
        "No existing child element - instantiating identity");
    /* if the identity feature doesn't exist - something is very wrong */
    identity_feature =
        GST_ELEMENT_FACTORY_CAST (gst_default_registry_find_feature ("identity",
            GST_TYPE_ELEMENT_FACTORY));
    identity =
        gst_auto_convert_get_or_make_element_from_factory (autoconvert,
        identity_feature);
    if (identity
        && gst_auto_convert_activate_element (autoconvert, identity, NULL)) {
      GST_AUTOCONVERT_LOCK (autoconvert);
      if (autoconvert->current_subelement)
        element = gst_object_ref (autoconvert->current_subelement);
      GST_AUTOCONVERT_UNLOCK (autoconvert);
    }
  }

  return element;
}