Esempio n. 1
0
static gint
gst_auto_video_src_compare_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
{
  gint diff;

  diff = gst_plugin_feature_get_rank (f2) - gst_plugin_feature_get_rank (f1);
  if (diff != 0)
    return diff;
  return strcmp (gst_plugin_feature_get_name (f2),
      gst_plugin_feature_get_name (f1));
}
/* Get the intersection of parser caps and available (sorted) decoders */
static GstCaps *
get_parser_caps_filter (GstDecodebin3 * dbin, GstCaps * caps)
{
  GList *tmp;
  GstCaps *filter_caps = gst_caps_new_empty ();

  g_mutex_lock (&dbin->factories_lock);
  gst_decode_bin_update_factories_list (dbin);
  for (tmp = dbin->decoder_factories; tmp; tmp = tmp->next) {
    GstElementFactory *factory = (GstElementFactory *) tmp->data;
    GstCaps *tcaps, *intersection;
    const GList *tmps;

    GST_LOG ("Trying factory %s",
        gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
    for (tmps = gst_element_factory_get_static_pad_templates (factory); tmps;
        tmps = tmps->next) {
      GstStaticPadTemplate *st = (GstStaticPadTemplate *) tmps->data;
      if (st->direction != GST_PAD_SINK || st->presence != GST_PAD_ALWAYS)
        continue;
      tcaps = gst_static_pad_template_get_caps (st);
      intersection =
          gst_caps_intersect_full (tcaps, caps, GST_CAPS_INTERSECT_FIRST);
      filter_caps = gst_caps_merge (filter_caps, intersection);
      gst_caps_unref (tcaps);
    }
  }
  g_mutex_unlock (&dbin->factories_lock);
  GST_DEBUG_OBJECT (dbin, "Got filter caps %" GST_PTR_FORMAT, filter_caps);
  return filter_caps;
}
Esempio n. 3
0
static void
print_plugin_automatic_install_info (GstPlugin * plugin)
{
  GList *features, *l;

  /* not interested in typefind factories, only element factories */
  features = gst_registry_get_feature_list (gst_registry_get (),
      GST_TYPE_ELEMENT_FACTORY);

  for (l = features; l != NULL; l = l->next) {
    GstPluginFeature *feature;
    GstPlugin *feature_plugin;

    feature = GST_PLUGIN_FEATURE (l->data);

    /* only interested in the ones that are in the plugin we just loaded */
    feature_plugin = gst_plugin_feature_get_plugin (feature);
    if (feature_plugin == plugin) {
      GstElementFactory *factory;

      g_print ("element-%s\n", gst_plugin_feature_get_name (feature));

      factory = GST_ELEMENT_FACTORY (feature);
      print_plugin_automatic_install_info_protocols (factory);
      print_plugin_automatic_install_info_codecs (factory);
    }
    if (feature_plugin)
      gst_object_unref (feature_plugin);
  }

  g_list_foreach (features, (GFunc) gst_object_unref, NULL);
  g_list_free (features);
}
Esempio n. 4
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;
}
static gboolean
check_parser_caps_filter (GstDecodebin3 * dbin, GstCaps * caps)
{
  GList *tmp;
  gboolean res = FALSE;

  g_mutex_lock (&dbin->factories_lock);
  gst_decode_bin_update_factories_list (dbin);
  for (tmp = dbin->decoder_factories; tmp; tmp = tmp->next) {
    GstElementFactory *factory = (GstElementFactory *) tmp->data;
    GstCaps *tcaps;
    const GList *tmps;

    GST_LOG ("Trying factory %s",
        gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
    for (tmps = gst_element_factory_get_static_pad_templates (factory); tmps;
        tmps = tmps->next) {
      GstStaticPadTemplate *st = (GstStaticPadTemplate *) tmps->data;
      if (st->direction != GST_PAD_SINK || st->presence != GST_PAD_ALWAYS)
        continue;
      tcaps = gst_static_pad_template_get_caps (st);
      if (gst_caps_can_intersect (tcaps, caps)) {
        res = TRUE;
        gst_caps_unref (tcaps);
        goto beach;
      }
      gst_caps_unref (tcaps);
    }
  }
beach:
  g_mutex_unlock (&dbin->factories_lock);
  GST_DEBUG_OBJECT (dbin, "Can intersect : %d", res);
  return res;
}
Esempio n. 6
0
static const char *Gstreamer_FindMatch(const char *strcaps)
{
    struct typeinfo data;
    GList *list, *copy;
    guint bestrank = 0;
    GstElementFactory *bestfactory = NULL;
    GstCaps *caps = gst_caps_from_string(strcaps);

    TRACE("%s\n", strcaps);

    data.caps = caps;
    data.type = "Decoder";
    copy = gst_registry_feature_filter(gst_registry_get(), match_element, 0, &data);
    for (list = copy; list; list = list->next) {
        GstElementFactory *factory = (GstElementFactory*)list->data;
        guint rank;
        rank = gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory));
        if (rank > bestrank || !bestrank) {
            bestrank = rank;
            bestfactory = factory;
        }
    }
    gst_caps_unref(caps);
    g_list_free(copy);

    if (!bestfactory) {
        FIXME("Could not find plugin for %s\n", strcaps);
        return NULL;
    }
    return gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(bestfactory));
}
Esempio n. 7
0
static void
conference_element_added (FsElementAddedNotifier *notifier,
    GstBin *bin,
    GstElement *element,
    gpointer user_data)
{
  GstElementFactory *factory;
  const gchar *name;

  factory = gst_element_get_factory (element);
  name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));

  if (!tp_strdiff (name, "x264enc"))
    {
      /* Ensure that the encoder creates the baseline profile */
      g_object_set (element,
          "byte-stream", TRUE,
          "bframes", 0,
          "b-adapt", FALSE,
          "cabac", FALSE,
          "dct8x8", FALSE,
          NULL);
    }
  else if (!tp_strdiff (name, "gstrtpbin"))
    {
      /* Lower the jitterbuffer latency to make it more suitable for video
       * conferencing */
      g_object_set (element, "latency", 100, NULL);
    }
}
Esempio n. 8
0
static void
mutate_playbin (RBVisualizerPlugin *plugin, GstElement *playbin)
{
	GstElement *current_vis_plugin;
	GstElement *current_video_sink;
	int playbin_flags;

	if (playbin == plugin->playbin)
		return;

	rb_debug ("mutating playbin");

	/* check no one has already set the playbin properties we're interested in */
	g_object_get (playbin,
		      "vis-plugin", &current_vis_plugin,
		      "video-sink", &current_video_sink,
		      "flags", &playbin_flags,
		      NULL);

	/* ignore fakesinks */
	if (current_video_sink != NULL) {
		const char *factoryname;
		GstElementFactory *factory;

		factory = gst_element_get_factory (current_video_sink);
		factoryname = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
		if (strcmp (factoryname, "fakesink") == 0) {
			g_object_unref (current_video_sink);
			current_video_sink = NULL;
		}
	}

	if ((current_vis_plugin != NULL) || (current_video_sink != NULL)) {
		g_warning ("sink and/or vis plugin already set on playbin");
		if (current_vis_plugin)
			g_object_unref (current_vis_plugin);
		if (current_video_sink)
			g_object_unref (current_video_sink);
		return;
	}

	/* detach from old playbin (this should never really happen) */
	if (plugin->playbin) {
		g_object_unref (plugin->playbin);
	}

	/* attach to new playbin */
	plugin->playbin = g_object_ref (playbin);
	g_object_set (plugin->playbin, "video-sink", plugin->sink, NULL);

	/* start visualizer if it's supposed to be running */
	if (plugin->visualizer != NULL) {
		playbin_flags |= PLAYBIN2_FLAG_VIS;
		g_object_set (plugin->playbin,
			      "flags", playbin_flags,
			      "vis-plugin", plugin->visualizer,
			      NULL);
	}
}
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);
}
/* Copy-pasted from decodebin */
static gint
compare_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
{
  gint diff;
  const gchar *rname1, *rname2;

  diff =  gst_plugin_feature_get_rank (f2) - gst_plugin_feature_get_rank (f1);
  if (diff != 0)
    return diff;

  rname1 = gst_plugin_feature_get_name (f1);
  rname2 = gst_plugin_feature_get_name (f2);

  diff = strcmp (rname2, rname1);

  return diff;
}
Esempio n. 11
0
static GstElement* rygel_gst_utils_get_best_depay (GList* features, GstCaps* caps) {
#line 236 "rygel-gst-utils.c"
	GstElement* result = NULL;
	GList* relevant_factories;
	GstElementFactory* factory;
#line 66 "rygel-gst-utils.vala"
	g_return_val_if_fail (caps != NULL, NULL);
#line 69 "rygel-gst-utils.vala"
	relevant_factories = NULL;
#line 244 "rygel-gst-utils.c"
	{
		GList* feature_collection;
		GList* feature_it;
#line 72 "rygel-gst-utils.vala"
		feature_collection = features;
#line 250 "rygel-gst-utils.c"
		for (feature_it = feature_collection; feature_it != NULL; feature_it = feature_it->next) {
			GstPluginFeature* feature;
#line 72 "rygel-gst-utils.vala"
			feature = _gst_object_ref0 ((GstPluginFeature*) feature_it->data);
#line 255 "rygel-gst-utils.c"
			{
				GstElementFactory* factory;
#line 73 "rygel-gst-utils.vala"
				factory = _gst_object_ref0 (GST_ELEMENT_FACTORY (feature));
#line 74 "rygel-gst-utils.vala"
				if (gst_element_factory_can_sink_caps (factory, caps)) {
#line 75 "rygel-gst-utils.vala"
					relevant_factories = g_list_append (relevant_factories, _gst_object_ref0 (factory));
#line 264 "rygel-gst-utils.c"
				}
				_gst_object_unref0 (feature);
				_gst_object_unref0 (factory);
			}
		}
	}
#line 79 "rygel-gst-utils.vala"
	if (g_list_length (relevant_factories) == 0) {
#line 273 "rygel-gst-utils.c"
		result = NULL;
		__g_list_free_gst_object_unref0 (relevant_factories);
#line 81 "rygel-gst-utils.vala"
		return result;
#line 278 "rygel-gst-utils.c"
	}
#line 85 "rygel-gst-utils.vala"
	relevant_factories = g_list_sort (relevant_factories, _rygel_gst_utils_compare_factories_gcompare_func);
#line 88 "rygel-gst-utils.vala"
	factory = _gst_object_ref0 ((GstElementFactory*) relevant_factories->data);
#line 284 "rygel-gst-utils.c"
	result = gst_element_factory_make (gst_plugin_feature_get_name ((GstPluginFeature*) factory), NULL);
	__g_list_free_gst_object_unref0 (relevant_factories);
	_gst_object_unref0 (factory);
#line 90 "rygel-gst-utils.vala"
	return result;
#line 290 "rygel-gst-utils.c"
}
Esempio n. 12
0
static const gchar *
factory_name_from_element (GstElement *element)
{
  GstElementFactory *factory = gst_element_get_factory (element);

  if (factory)
    return gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
  else
    return NULL;
}
Esempio n. 13
0
/**
 * gst_plugin_feature_list_debug:
 * @list: (transfer none) (element-type Gst.PluginFeature): a #GList of
 *     plugin features
 *
 * Debug the plugin feature names in @list.
 */
void
gst_plugin_feature_list_debug (GList * list)
{
#ifndef GST_DISABLE_GST_DEBUG
  while (list) {
    GST_DEBUG ("%s",
        gst_plugin_feature_get_name ((GstPluginFeature *) list->data));
    list = list->next;
  }
#endif
}
Esempio n. 14
0
gboolean
rb_gst_encoder_set_encoding_style (GstElement *encoder, const char *style)
{
	GstElementFactory *factory;
	char *group_name;
	char **keys;
	int i;

	factory = gst_element_get_factory (encoder);
	group_name = g_strdup_printf (ENCODER_STYLE_SETTINGS_PREFIX "%s-%s",
				      gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)),
				      style);
	rb_debug ("applying settings from %s", group_name);

	keys = g_key_file_get_keys (get_target_keyfile (), group_name, NULL, NULL);
	if (keys == NULL) {
		rb_debug ("nothing to apply");
		g_free (group_name);
		return FALSE;
	}

	for (i = 0; keys[i] != NULL; i++) {
		GParamSpec *pspec;
		GValue v = {0,};
		char *value;

		pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (encoder), keys[i]);
		if (pspec == NULL) {
			rb_debug ("couldn't find property %s", keys[i]);
			continue;
		}

		value = g_key_file_get_string (get_target_keyfile (), group_name, keys[i], NULL);
		if (value == NULL) {
			rb_debug ("couldn't get value for property %s", keys[i]);
			continue;
		}

		g_value_init (&v, pspec->value_type);
		if (gst_value_deserialize (&v, value)) {
			rb_debug ("applying value \"%s\" to property %s", value, keys[i]);
			g_object_set_property (G_OBJECT (encoder), keys[i], &v);
		} else {
			rb_debug ("couldn't deserialize value \"%s\" for property %s", value, keys[i]);
		}

		g_value_unset (&v);
	}

	g_strfreev (keys);
	g_free (group_name);
	return TRUE;
}
Esempio n. 15
0
GstElement * _owr_payload_create_encoder(OwrPayload *payload)
{
    GstElement *encoder = NULL;
    gchar *element_name = NULL;
    GstElementFactory *factory;
    const gchar *factory_name;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        encoder = try_codecs(h264_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);

        if (!strcmp(factory_name, "openh264enc")) {
            g_object_set(encoder, "gop-size", 0, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "rate-control", "bitrate");
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        } else if (!strcmp(factory_name, "x264enc")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            g_object_set(encoder, "tune", 0x04 /* zero-latency */, NULL);
        } else if (!strcmp(factory_name, "vtenc_h264")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
        } else {
            /* Assume bits/s instead of kbit/s */
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        }
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;

    case OWR_CODEC_TYPE_VP8:
        encoder = try_codecs(vp8_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);
        g_object_set(encoder, "end-usage", 1, "deadline", G_GINT64_CONSTANT(1), "lag-in-frames", 0,
            "error-resilient", 1, "keyframe-mode", 0, NULL);
        g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;
    default:
        element_name = g_strdup_printf("encoder_%s_%u", OwrCodecTypeEncoderElementName[payload->priv->codec_type], get_unique_id());
        encoder = gst_element_factory_make(OwrCodecTypeEncoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(encoder, NULL);
        break;
    }

    return encoder;
}
Esempio n. 16
0
/* function used to sort element features. We first sort on the rank, then
 * on the element name (to get a consistent, predictable list) */
static gint
compare_ranks (GValue * v1, GValue * v2)
{
  gint diff;
  const gchar *rname1, *rname2;
  GstPluginFeature *f1, *f2;

  f1 = g_value_get_object (v1);
  f2 = g_value_get_object (v2);

  diff = gst_plugin_feature_get_rank (f2) - gst_plugin_feature_get_rank (f1);
  if (diff != 0)
    return diff;

  rname1 = gst_plugin_feature_get_name (f1);
  rname2 = gst_plugin_feature_get_name (f2);

  diff = strcmp (rname2, rname1);

  return diff;
}
Esempio n. 17
0
static gint
find_composition_func (const GValue * velement)
{
  GstElement *element = g_value_get_object (velement);
  GstElementFactory *fac = gst_element_get_factory (element);
  const gchar *name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (fac));

  if (g_strcmp0 (name, "gnlcomposition") == 0)
    return 0;

  return 1;
}
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;
}
Esempio n. 19
0
/**
 * gst_factory_list_debug:
 * @array: an array of element factories
 *
 * Debug the element factory names in @array.
 */
void
gst_factory_list_debug (GValueArray * array)
{
  gint i;

  for (i = 0; i < array->n_values; i++) {
    GValue *value;
    GstPluginFeature *feature;

    value = g_value_array_get_nth (array, i);
    feature = g_value_get_object (value);

    GST_DEBUG ("%s", gst_plugin_feature_get_name (feature));
  }
}
Esempio n. 20
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);
}
Esempio n. 21
0
static void
debug_pipeline (GstDebugLevel level, const gchar *prefix, GList *pipeline)
{
  GList *walk;
  GString *str;
  gboolean first = TRUE;

  if (gst_debug_category_get_threshold (GST_CAT_DEFAULT) <  level)
    return;

  str = g_string_new (prefix);

  for (walk = pipeline; walk; walk = g_list_next (walk))
  {
    GList *walk2;
    gboolean first_alt = TRUE;

    if (!first)
      g_string_append (str, " ->");
    first = FALSE;

    for (walk2 = g_list_first (walk->data); walk2; walk2 = g_list_next (walk2))
    {
      if (first_alt)
        g_string_append_printf (str, " %s",
            gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (walk2->data)));
      else
        g_string_append_printf (str, " | %s",
            gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (walk2->data)));

      first_alt = FALSE;
    }
  }
  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, level, NULL, "%s", str->str);
  g_string_free (str, TRUE);
}
Esempio n. 22
0
/**
 * gst_element_factory_list_filter:
 * @list: (transfer none) (element-type Gst.ElementFactory): a #GList of
 *     #GstElementFactory to filter
 * @caps: a #GstCaps
 * @direction: a #GstPadDirection to filter on
 * @subsetonly: whether to filter on caps subsets or not.
 *
 * Filter out all the elementfactories in @list that can handle @caps in
 * the given direction.
 *
 * If @subsetonly is %TRUE, then only the elements whose pads templates
 * are a complete superset of @caps will be returned. Else any element
 * whose pad templates caps can intersect with @caps will be returned.
 *
 * Returns: (transfer full) (element-type Gst.ElementFactory): a #GList of
 *     #GstElementFactory elements that match the given requisits.
 *     Use #gst_plugin_feature_list_free after usage.
 *
 * Since: 0.10.31
 */
GList *
gst_element_factory_list_filter (GList * list,
    const GstCaps * caps, GstPadDirection direction, gboolean subsetonly)
{
  GQueue results = G_QUEUE_INIT;

  GST_DEBUG ("finding factories");

  /* loop over all the factories */
  for (; list; list = list->next) {
    GstElementFactory *factory;
    const GList *templates;
    GList *walk;

    factory = (GstElementFactory *) list->data;

    GST_DEBUG ("Trying %s",
        gst_plugin_feature_get_name ((GstPluginFeature *) factory));

    /* get the templates from the element factory */
    templates = gst_element_factory_get_static_pad_templates (factory);
    for (walk = (GList *) templates; walk; walk = g_list_next (walk)) {
      GstStaticPadTemplate *templ = walk->data;

      /* we only care about the sink templates */
      if (templ->direction == direction) {
        GstCaps *tmpl_caps;

        /* try to intersect the caps with the caps of the template */
        tmpl_caps = gst_static_caps_get (&templ->static_caps);

        /* FIXME, intersect is not the right method, we ideally want to check
         * for a subset here */

        /* check if the intersection is empty */
        if ((subsetonly && gst_caps_is_subset (caps, tmpl_caps)) ||
            (!subsetonly && gst_caps_can_intersect (caps, tmpl_caps))) {
          /* non empty intersection, we can use this element */
          g_queue_push_tail (&results, gst_object_ref (factory));
          gst_caps_unref (tmpl_caps);
          break;
        }
        gst_caps_unref (tmpl_caps);
      }
    }
  }
  return results.head;
}
Esempio n. 23
0
static void
element_added (FsElementAddedNotifier *notif, GstBin *bin, GstElement *element,
    gpointer user_data)
{
  GstElementFactory *fact = gst_element_get_factory (element);

  if (!fact)
    return;

  if (strcmp (gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (fact)),
              "theoradec"))
    return;

  ts_fail_unless (decoder_count == 0);
  decoder_count++;
}
Esempio n. 24
0
void GStreamerReader::ElementAddedCb(GstBin *aPlayBin,
                                     GstElement *aElement,
                                     gpointer aUserData)
{
  GstElementFactory *factory = gst_element_get_factory(aElement);

  if (!factory)
    return;

  const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory));

  if (name && !strcmp(name, "uridecodebin")) {
    g_signal_connect(G_OBJECT(aElement), "autoplug-sort",
                     G_CALLBACK(GStreamerReader::ElementFilterCb), aUserData);
  }
}
static void
debug_pipeline (GList *pipeline)
{
  GList *walk;

  GST_DEBUG ("pipeline: ");
  for (walk = pipeline; walk; walk = g_list_next (walk))
  {
    GList *walk2;
    for (walk2 = g_list_first (walk->data); walk2; walk2 = g_list_next (walk2))
      GST_DEBUG ("%p:%d:%s ", walk2->data,
        GST_OBJECT_REFCOUNT_VALUE (GST_OBJECT (walk2->data)),
        gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (walk2->data)));
    GST_DEBUG ("--");
  }
  GST_DEBUG ("\n");
}
Esempio n. 26
0
bool ofGstUtils::setPipelineWithSink(GstElement * pipeline, GstElement * sink, bool isStream_){
	gstPipeline = pipeline;
	gstSink = sink;
	isStream = isStream_;

	if(gstSink){
		gst_base_sink_set_sync(GST_BASE_SINK(gstSink), true);
	}

	if(gstSink && string(gst_plugin_feature_get_name( GST_PLUGIN_FEATURE(gst_element_get_factory(gstSink))))=="appsink"){
		isAppSink = true;
	}else{
		isAppSink = false;
	}

	return startPipeline();
}
Esempio n. 27
0
/* static */ bool
GStreamerFormatHelper::IsPluginFeatureBlacklisted(GstPluginFeature *aFeature)
{
  if (!IsBlacklistEnabled()) {
    return false;
  }

  const gchar *factoryName =
    gst_plugin_feature_get_name(aFeature);

  for (unsigned int i = 0; i < G_N_ELEMENTS(sPluginBlacklist); i++) {
    if (!strcmp(factoryName, sPluginBlacklist[i])) {
      return true;
    }
  }

  return false;
}
Esempio n. 28
0
static gint find_by_factory_func(gconstpointer p_value_ptr, gconstpointer p_user_data)
{
	GValue const *value = static_cast < GValue const* > (p_value_ptr);
	std::string const *expected_factory_name = static_cast < std::string const * > (p_user_data);

	GstElement *elem = GST_ELEMENT(g_value_get_object(value));

	GST_OBJECT_LOCK(elem);

	GstElementFactory *factory = gst_element_get_factory(elem);
	gchar const *factory_name = gst_plugin_feature_get_name(factory);

	gint result = (factory_name == *expected_factory_name) ? 0 : 1;

	GST_OBJECT_UNLOCK(elem);

	return result;
}
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;
  }
}
static gboolean
gst_auto_video_convert_element_filter (GstPluginFeature * feature,
    GstAutoVideoConvert * autovideoconvert)
{
  const gchar *klass;

  /* we only care about element factories */
  if (G_UNLIKELY (!GST_IS_ELEMENT_FACTORY (feature)))
    return FALSE;

  klass = gst_element_factory_get_metadata (GST_ELEMENT_FACTORY_CAST (feature),
      GST_ELEMENT_METADATA_KLASS);
  /* only select color space converter */
  if (strstr (klass, "Filter") &&
      strstr (klass, "Converter") && strstr (klass, "Video")) {
    GST_DEBUG_OBJECT (autovideoconvert,
        "gst_auto_video_convert_element_filter found %s\n",
        gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (feature)));
    return TRUE;
  }
  return FALSE;
}