예제 #1
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;
}
예제 #2
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;
}
예제 #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;
}
예제 #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;
}
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);
}
예제 #7
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;
  }
}
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;
}
예제 #10
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;
}