示例#1
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);
}
示例#2
0
static void
print_factory_details_info (GstElementFactory * factory)
{
  gchar **keys, **k;
  GstRank rank;
  char s[20];

  rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
  n_print ("Factory Details:\n");
  n_print ("  %-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);

  keys = gst_element_factory_get_metadata_keys (factory);
  if (keys != NULL) {
    for (k = keys; *k != NULL; ++k) {
      const gchar *val;
      gchar *key = *k;

      val = gst_element_factory_get_metadata (factory, key);
      key[0] = g_ascii_toupper (key[0]);
      n_print ("  %-25s%s\n", key, val);
    }
    g_strfreev (keys);
  }
  n_print ("\n");
}
示例#3
0
/**
 * gst_element_factory_list_is_type:
 * @factory: a #GstElementFactory
 * @type: a #GstElementFactoryListType
 *
 * Check if @factory is of the given types.
 *
 * Returns: %TRUE if @factory is of @type.
 */
gboolean
gst_element_factory_list_is_type (GstElementFactory * factory,
    GstElementFactoryListType type)
{
  gboolean res = FALSE;
  const gchar *klass;

  klass =
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);

  /* Filter by element type first, as soon as it matches
   * one type, we skip all other tests */
  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SINK))
    res = (strstr (klass, "Sink") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SRC))
    res = (strstr (klass, "Source") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DECODER))
    res = (strstr (klass, "Decoder") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_ENCODER))
    res = (strstr (klass, "Encoder") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_MUXER))
    res = (strstr (klass, "Muxer") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEMUXER))
    res = (strstr (klass, "Demux") != NULL);

  /* FIXME : We're actually parsing two Classes here... */
  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PARSER))
    res = ((strstr (klass, "Parser") != NULL)
        && (strstr (klass, "Codec") != NULL));

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER))
    res = (strstr (klass, "Depayloader") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PAYLOADER))
    res = (strstr (klass, "Payloader") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_FORMATTER))
    res = (strstr (klass, "Formatter") != NULL);

  /* Filter by media type now, we only test if it
   * matched any of the types above. */
  if (res
      && (type & (GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)))
    res = ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO)
        && (strstr (klass, "Audio") != NULL))
        || ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO)
        && (strstr (klass, "Video") != NULL))
        || ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)
        && (strstr (klass, "Image") != NULL));

  return res;
}
static void
test_position (InsanityTest * test, GstBuffer * buf)
{
  GstQuery *query;
  GstClockTimeDiff diff;

  if (GST_BUFFER_PTS_IS_VALID (buf) == FALSE)
    return;

  if (GST_CLOCK_TIME_IS_VALID (glob_first_pos_point) == FALSE) {
    glob_first_pos_point = gst_segment_to_stream_time (&glob_last_segment,
        glob_last_segment.format, GST_BUFFER_PTS (buf));
  }

  glob_expected_pos = gst_segment_to_stream_time (&glob_last_segment,
      glob_last_segment.format, GST_BUFFER_PTS (buf));

  diff = ABS (GST_CLOCK_DIFF (glob_expected_pos, glob_first_pos_point));

  if (diff < glob_playback_duration * GST_SECOND)
    return;

  query = gst_query_new_position (GST_FORMAT_TIME);

  if (gst_element_query (glob_pipeline, query)) {
    gint64 pos;
    GstFormat fmt;
    GstClockTimeDiff diff;

    gst_query_parse_position (query, &fmt, &pos);
    diff = ABS (GST_CLOCK_DIFF (glob_expected_pos, pos));

    if (diff <= POSITION_THRESHOLD) {
      insanity_test_validate_checklist_item (test, "position-detection", TRUE,
          NULL);
    } else {
      gchar *validate_msg = g_strdup_printf ("Found position: %" GST_TIME_FORMAT
          " expected: %" GST_TIME_FORMAT, GST_TIME_ARGS (pos),
          GST_TIME_ARGS (glob_expected_pos));

      insanity_test_validate_checklist_item (test, "position-detection",
          FALSE, validate_msg);

      g_free (validate_msg);
    }
  } else {
    LOG (test,
        "%s Does not handle position queries (position-detection \"SKIP\")",
        gst_element_factory_get_metadata (gst_element_get_factory
            (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME));
  }

  next_test (test);
}
static void
add_element_used (InsanityGstPipelineTest * ptest, GstElement * element)
{
  GstElementFactory *factory;
  const char *factory_name;
  char label[32], *element_name;
  GValue string_value = { 0 };
  GstElement *parent;

  /* Only add once */
  element_name = gst_element_get_name (element);
  if (g_hash_table_lookup_extended (ptest->priv->elements_used, element_name,
          NULL, NULL)) {
    g_free (element_name);
    return;
  }
  g_hash_table_insert (ptest->priv->elements_used, g_strdup (element_name),
      NULL);

  ptest->priv->element_count++;
  g_value_init (&string_value, G_TYPE_STRING);

  factory = gst_element_get_factory (element);
  factory_name =
      factory ? gst_element_factory_get_metadata (factory,
      GST_ELEMENT_METADATA_LONGNAME) : "(no factory)";

  g_value_take_string (&string_value, element_name);
  snprintf (label, sizeof (label), "elements-used.%u.name",
      ptest->priv->element_count);
  insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
  g_value_reset (&string_value);

  g_value_set_string (&string_value, factory_name);
  snprintf (label, sizeof (label), "elements-used.%u.factory",
      ptest->priv->element_count);
  insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
  g_value_reset (&string_value);

  parent = GST_ELEMENT (gst_element_get_parent (element));
  if (parent) {
    g_value_take_string (&string_value, gst_element_get_name (parent));
    snprintf (label, sizeof (label), "elements-used.%u.parent",
        ptest->priv->element_count);
    insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
    g_value_reset (&string_value);
    gst_object_unref (parent);
  }
}
static void
unvalidate_seeking_tests (InsanityTest * test)
{
  gchar *message = g_strdup_printf ("%s not seekable in %s mode",
      gst_element_factory_get_metadata (gst_element_get_factory
          (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME),
      pipeline_mode_get_name (glob_push_mode));

  insanity_test_validate_checklist_item (test, "fast-forward", TRUE, message);
  insanity_test_validate_checklist_item (test, "fast-backward", TRUE, message);
  insanity_test_validate_checklist_item (test, "backward-playback", TRUE,
      message);

  g_free (message);
}
static char *
make_bundle_name (GstObject * obj, const gchar * name)
{
  GstElementFactory *factory;
  gchar *basename, *s, *bundle;

  factory = gst_element_get_factory ((GstElement *) obj);
  basename = g_strdup (gst_element_factory_get_metadata (factory,
          GST_ELEMENT_METADATA_LONGNAME));
  s = basename;
  while ((s = strchr (s, ' '))) {
    *s = '_';
  }
  bundle = g_strjoin (NULL, basename, "_", name, ".preset.lv2", NULL);

  g_free (basename);

  return bundle;
}
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;
}
static gboolean
gst_auto_video_src_factory_filter (GstPluginFeature * feature, gpointer data)
{
  guint rank;
  const gchar *klass;

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

  /* video sources */
  klass = gst_element_factory_get_metadata (GST_ELEMENT_FACTORY (feature),
      GST_ELEMENT_METADATA_KLASS);
  if (!(strstr (klass, "Source") && strstr (klass, "Video")))
    return FALSE;

  /* only select elements with autoplugging rank */
  rank = gst_plugin_feature_get_rank (feature);
  if (rank < GST_RANK_MARGINAL)
    return FALSE;

  return TRUE;
}
/* Test Callbacks  and vmethods*/
static GstPipeline *
create_pipeline (InsanityGstPipelineTest * ptest, gpointer unused_data)
{
  GstElementFactory *decofactory = NULL;

  GError *err = NULL;
  InsanityTest *test = INSANITY_TEST (ptest);
  gchar *decodername = NULL, *uri = NULL, *location = NULL;
  const gchar *klass;

  DECODER_TEST_LOCK ();
  glob_pipeline = GST_ELEMENT (gst_pipeline_new ("pipeline"));

  /* Create the source */
  insanity_test_get_boolean_argument (test, "push-mode",
      (gboolean *) & glob_push_mode);

  insanity_test_get_string_argument (test, "location", &location);
  if (location == NULL || g_strcmp0 (location, "") == 0) {
    ERROR (test, "Location name not set");
    goto failed;
  }

  uri = gst_filename_to_uri (location, &err);
  if (err != NULL) {
    ERROR (test, "Error creating uri %s", err->message);

    goto failed;
  } else if (glob_push_mode == FALSE) {
    glob_src = gst_element_factory_make ("filesrc", "src");
  } else {
    gchar *tmpuri;

    glob_src = gst_element_factory_make ("pushfilesrc", "src");
    tmpuri = g_strconcat ("push", uri, NULL);
    g_free (uri);

    uri = tmpuri;
  }

  gst_uri_handler_set_uri (GST_URI_HANDLER (glob_src), uri, &err);
  if (err != NULL) {
    ERROR (test, "Error setting uri %s", err->message);
    goto failed;
  }

  if (!insanity_test_get_string_argument (test, "decoder-name", &decodername) ||
      g_strcmp0 (decodername, "") == 0) {
    ERROR (test, "Decoder name not set");
    goto failed;
  }

  /* ... create the decoder, will not be used until we typefind and
   * plug the demuxer */
  glob_decoder = gst_element_factory_make (decodername, "decoder");
  if (glob_decoder == NULL)
    goto failed;

  /* We check wether the element is a parser or not */
  decofactory = gst_element_get_factory (glob_decoder);
  klass =
      gst_element_factory_get_metadata (decofactory,
      GST_ELEMENT_METADATA_KLASS);
  glob_testing_parser = g_strrstr (klass, "Parser") ? TRUE : FALSE;

  if (glob_testing_parser == FALSE && g_strrstr (klass, "Decoder") == NULL) {
    gchar *val_test = g_strdup_printf ("%s not a decoder nor a parser as"
        " neither of \"Decoder\" nor \"parser\" where present in the element"
        " factory klass: %s", decodername, klass);

    insanity_test_validate_checklist_item (test, "testing-decoder-or-parser",
        FALSE, val_test);

    g_free (val_test);
    goto failed;
  } else {
    insanity_test_validate_checklist_item (test, "testing-decoder-or-parser",
        TRUE, NULL);
  }

  if (glob_testing_parser == FALSE) {
    GstCaps *decode_sinkcaps = NULL;
    GList *tmp, *parsers;
    const GList *template;

    for (template = gst_element_factory_get_static_pad_templates (decofactory);
static void
suboverlay_child_added_cb (GstElement * suboverlay, GstElement * child,
    InsanityTest * test)
{
  GstIterator *it = NULL;
  GstPad *render_sub_sink, *tmppad;
  GstElementFactory *fact;
  const gchar *klass, *name;
  gulong probe_id;
  GValue value = { 0, };

  gboolean is_renderer = FALSE;


  /* cc-ed from -base/gstsubtitleoveraly.c */
  fact = gst_element_get_factory (child);
  klass = gst_element_factory_get_metadata (fact, GST_ELEMENT_METADATA_KLASS);

  if (GST_IS_BIN (child))
    return;

  name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (fact));

  if (g_strrstr (klass, "Overlay/Subtitle") != NULL ||
      g_strrstr (klass, "Overlay/SubPicture") != NULL)
    is_renderer = TRUE;

  else if (g_strcmp0 (name, "textoverlay") == 0)
    is_renderer = TRUE;

  if (is_renderer == FALSE)
    goto done;

  LOG (test, "Renderer found: %s", name);

  /* Now adding the probe to the renderer "subtitle" sink pad */
  it = gst_element_iterate_sink_pads (child);
  if (gst_iterator_find_custom (it,
          (GCompareFunc) find_renderer_subtitle_sinkpad, &value, NULL)) {
    render_sub_sink = g_value_get_object (&value);
  } else {
    goto done;
  }

  if (insanity_gst_test_add_data_probe (INSANITY_GST_TEST (test),
          GST_BIN (glob_pipeline), GST_OBJECT_NAME (child),
          GST_ELEMENT_NAME (render_sub_sink), &tmppad, &probe_id,
          &renderer_probe_cb, NULL, NULL) == TRUE) {

    glob_renderer_sink_probe = g_slice_new0 (ProbeContext);
    glob_renderer_sink_probe->probe_id = probe_id;
    glob_renderer_sink_probe->pad = render_sub_sink;
    glob_renderer_sink_probe->element = child;
    glob_renderer_sink_probe->test = test;
    glob_renderer_sink_probe->waiting_first_segment = TRUE;

    insanity_test_validate_checklist_item (test, "install-probes", TRUE, NULL);
  } else {
    insanity_test_validate_checklist_item (test, "install-probes", FALSE,
        "Failed to attach probe to fakesink");
    insanity_test_done (test);

    goto done;
  }

done:
  if (it)
    gst_iterator_free (it);

}
示例#12
0
/**
 * gst_element_factory_list_is_type:
 * @factory: a #GstElementFactory
 * @type: a #GstElementFactoryListType
 *
 * Check if @factory is of the given types.
 *
 * Returns: %TRUE if @factory is of @type.
 */
gboolean
gst_element_factory_list_is_type (GstElementFactory * factory,
    GstElementFactoryListType type)
{
  gboolean res = FALSE;
  const gchar *klass;

  klass =
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);

  if (klass == NULL) {
    GST_ERROR_OBJECT (factory, "element factory is missing klass identifiers");
    return res;
  }

  /* Filter by element type first, as soon as it matches
   * one type, we skip all other tests */
  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SINK))
    res = (strstr (klass, "Sink") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SRC))
    res = (strstr (klass, "Source") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DECODER))
    res = (strstr (klass, "Decoder") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_ENCODER))
    res = (strstr (klass, "Encoder") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_MUXER))
    res = (strstr (klass, "Muxer") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEMUXER))
    res = (strstr (klass, "Demux") != NULL);

  /* FIXME : We're actually parsing two Classes here... */
  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PARSER))
    res = ((strstr (klass, "Parser") != NULL)
        && (strstr (klass, "Codec") != NULL));

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER))
    res = (strstr (klass, "Depayloader") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PAYLOADER))
    res = (strstr (klass, "Payloader") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_FORMATTER))
    res = (strstr (klass, "Formatter") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DECRYPTOR))
    res = (strstr (klass, "Decryptor") != NULL);

  if (!res && (type & GST_ELEMENT_FACTORY_TYPE_ENCRYPTOR))
    res = (strstr (klass, "Encryptor") != NULL);

  /* Filter by media type now, we only test if it
   * matched any of the types above or only checking the media
   * type was requested. */
  if ((res || !(type & (GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS - 1)))
      && (type & (GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE |
              GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA)))
    res = ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO)
        && (strstr (klass, "Audio") != NULL))
        || ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO)
        && (strstr (klass, "Video") != NULL))
        || ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)
        && (strstr (klass, "Image") != NULL)) ||
        ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE)
        && (strstr (klass, "Subtitle") != NULL)) ||
        ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA)
        && (strstr (klass, "Metadata") != NULL));

  return res;
}
static void
test_queries (InsanityTest * test)
{
  GstQuery *query = gst_query_new_seeking (GST_FORMAT_TIME);

  if (gst_element_query (glob_pipeline, query)) {
    GstFormat fmt;
    gboolean seekable, known_seekable;

    gst_query_parse_seeking (query, &fmt, &seekable, NULL, NULL);
    if (glob_media_desc_parser == NULL) {
      insanity_test_validate_checklist_item (test, "seekable-detection",
          TRUE, "No media-descriptor file, result not verified against it");

      glob_seekable = seekable;
    } else {
      known_seekable =
          media_descriptor_parser_get_seekable (glob_media_desc_parser);

      insanity_test_validate_checklist_item (test, "seekable-detection",
          known_seekable == seekable, NULL);
      glob_seekable = known_seekable;
    }
  } else {
    if (glob_media_desc_parser != NULL)
      glob_seekable =
          media_descriptor_parser_get_seekable (glob_media_desc_parser);

    LOG (test,
        "%s Does not handle seeking queries (seekable-detection \"SKIP\")",
        gst_element_factory_get_metadata (gst_element_get_factory
            (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME));
  }

  gst_query_unref (query);
  query = gst_query_new_duration (GST_FORMAT_TIME);
  if (gst_element_query (glob_pipeline, query)) {
    GstFormat fmt;
    gchar *validate_msg = NULL;
    gint64 duration;

    if (glob_media_desc_parser == NULL) {
      gst_query_parse_duration (query, &fmt, &duration);
      validate_msg =
          g_strdup_printf ("Found duration %" GST_TIME_FORMAT
          " No media-descriptor file, result not verified against it",
          GST_TIME_ARGS (duration));
      insanity_test_validate_checklist_item (test, "duration-detection",
          TRUE, validate_msg);

      g_free (validate_msg);

      glob_duration = duration;
    } else {
      glob_duration =
          media_descriptor_parser_get_duration (glob_media_desc_parser);
      gst_query_parse_duration (query, &fmt, &duration);

      if (glob_duration != duration) {
        validate_msg =
            g_strdup_printf ("Found time %" GST_TIME_FORMAT "-> %"
            GST_TIME_FORMAT, GST_TIME_ARGS (duration),
            GST_TIME_ARGS (glob_duration));

        insanity_test_validate_checklist_item (test, "duration-detection",
            glob_duration == duration, validate_msg);

        g_free (validate_msg);
      } else {
        insanity_test_validate_checklist_item (test, "duration-detection",
            TRUE, NULL);
      }
    }

  } else {
    if (glob_media_desc_parser != NULL)
      glob_duration =
          media_descriptor_parser_get_seekable (glob_media_desc_parser);

    LOG (test, "%s Does not handle duration queries "
        "(duration-detection \"SKIP\")",
        gst_element_factory_get_metadata (gst_element_get_factory
            (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME));
  }

  if (GST_CLOCK_TIME_IS_VALID (glob_duration) &&
      glob_playback_duration > glob_duration) {
    LOG (test, "playback_duration > media duration, setting it"
        "to media_duration != 2");

    glob_playback_duration = glob_duration / 2;
  }
  gst_query_unref (query);


  next_test (test);
}
gchar *
ges_effect_assect_id_get_type_and_bindesc (const char *id,
    GESTrackType * track_type, GError ** error)
{
  GList *tmp;
  GstElement *effect;
  gchar **typebin_desc = NULL;
  gchar *bindesc = NULL;

  *track_type = GES_TRACK_TYPE_UNKNOWN;
  typebin_desc = g_strsplit (id, " ", 2);
  if (!g_strcmp0 (typebin_desc[0], "audio")) {
    *track_type = GES_TRACK_TYPE_AUDIO;
    bindesc = g_strdup (typebin_desc[1]);
  } else if (!g_strcmp0 (typebin_desc[0], "video")) {
    *track_type = GES_TRACK_TYPE_VIDEO;
    bindesc = g_strdup (typebin_desc[1]);
  } else {
    bindesc = g_strdup (id);
  }

  g_strfreev (typebin_desc);

  effect = gst_parse_bin_from_description (bindesc, TRUE, error);
  if (effect == NULL) {
    g_free (bindesc);

    GST_ERROR ("Could not create element from: %s", id);

    return NULL;
  }

  if (*track_type != GES_TRACK_TYPE_UNKNOWN) {
    gst_object_unref (effect);

    return bindesc;
  }

  for (tmp = GST_BIN_CHILDREN (effect); tmp; tmp = tmp->next) {
    GstElementFactory *factory =
        gst_element_get_factory (GST_ELEMENT (tmp->data));
    const gchar *klass =
        gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);

    if (g_strrstr (klass, "Effect")) {
      if (g_strrstr (klass, "Audio")) {
        *track_type = GES_TRACK_TYPE_AUDIO;
        break;
      } else if (g_strrstr (klass, "Video")) {
        *track_type = GES_TRACK_TYPE_VIDEO;
        break;
      }
    }
  }

  gst_object_unref (effect);

  if (*track_type == GES_TRACK_TYPE_UNKNOWN) {
    *track_type = GES_TRACK_TYPE_VIDEO;
    GST_ERROR ("Could not determine track type for %s, defaulting to video",
        id);
  }

  return bindesc;
}
示例#15
0
static gboolean
rsndec_factory_filter (GstPluginFeature * feature, RsnDecFactoryFilterCtx * ctx)
{
  GstElementFactory *factory;
  guint rank;
  const gchar *klass;
  const GList *templates;
  GList *walk;
  gboolean can_sink = FALSE;

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

  factory = GST_ELEMENT_FACTORY (feature);

  klass =
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);
  /* only decoders can play */
  if (strstr (klass, "Decoder") == NULL)
    return FALSE;

  /* only select elements with autoplugging rank */
  rank = gst_plugin_feature_get_rank (feature);
  if (rank < GST_RANK_MARGINAL)
    return FALSE;

  /* See if the element has a sink pad that can possibly sink this caps */

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

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

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

      intersect = gst_caps_intersect (ctx->desired_caps, tmpl_caps);
      gst_caps_unref (tmpl_caps);

      /* check if the intersection is empty */
      if (!gst_caps_is_empty (intersect)) {
        /* non empty intersection, we can use this element */
        can_sink = TRUE;
        ctx->decoder_caps = gst_caps_merge (ctx->decoder_caps, intersect);
      } else
        gst_caps_unref (intersect);
    }
  }

  if (can_sink) {
    GST_DEBUG ("Found decoder element %s (%s)",
        gst_element_factory_get_metadata (factory,
            GST_ELEMENT_METADATA_LONGNAME),
        gst_plugin_feature_get_name (feature));
  }

  return can_sink;
}
示例#16
0
static void
print_element_list (gboolean print_all)
{
  int plugincount = 0, featurecount = 0, blacklistcount = 0;
  GList *plugins, *orig_plugins;

  orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
  while (plugins) {
    GList *features, *orig_features;
    GstPlugin *plugin;

    plugin = (GstPlugin *) (plugins->data);
    plugins = g_list_next (plugins);
    plugincount++;

    if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
      blacklistcount++;
      continue;
    }

    orig_features = features =
        gst_registry_get_feature_list_by_plugin (gst_registry_get (),
        gst_plugin_get_name (plugin));
    while (features) {
      GstPluginFeature *feature;

      if (G_UNLIKELY (features->data == NULL))
        goto next;
      feature = GST_PLUGIN_FEATURE (features->data);
      featurecount++;

      if (GST_IS_ELEMENT_FACTORY (feature)) {
        GstElementFactory *factory;

        factory = GST_ELEMENT_FACTORY (feature);
        if (print_all)
          print_element_info (factory, TRUE);
        else
          g_print ("%s:  %s: %s\n", gst_plugin_get_name (plugin),
              GST_OBJECT_NAME (factory),
              gst_element_factory_get_metadata (factory,
                  GST_ELEMENT_METADATA_LONGNAME));
      } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
        GstTypeFindFactory *factory;
        const gchar *const *extensions;

        factory = GST_TYPE_FIND_FACTORY (feature);
        if (!print_all)
          g_print ("%s: %s: ", gst_plugin_get_name (plugin),
              gst_plugin_feature_get_name (feature));

        extensions = gst_type_find_factory_get_extensions (factory);
        if (extensions != NULL) {
          guint i = 0;

          while (extensions[i]) {
            if (!print_all)
              g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
            i++;
          }
          if (!print_all)
            g_print ("\n");
        } else {
          if (!print_all)
            g_print ("no extensions\n");
        }
      } else {
        if (!print_all)
          n_print ("%s:  %s (%s)\n", gst_plugin_get_name (plugin),
              GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature)));
      }

    next:
      features = g_list_next (features);
    }

    gst_plugin_feature_list_free (orig_features);
  }

  gst_plugin_list_free (orig_plugins);

  g_print ("\n");
  g_print (_("Total count: "));
  g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
  if (blacklistcount) {
    g_print (" (");
    g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
            blacklistcount), blacklistcount);
    g_print (" not shown)");
  }
  g_print (", ");
  g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
  g_print ("\n");
}
示例#17
0
static void
print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
{
  GstPadDirection direction;
  const gchar *type_name;
  const gchar *klass;
  const GList *static_templates, *l;
  GstCaps *caps = NULL;
  guint i, num;

  klass =
      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);
  g_return_if_fail (klass != NULL);

  if (strstr (klass, "Demuxer") ||
      strstr (klass, "Decoder") ||
      strstr (klass, "Depay") || strstr (klass, "Parser")) {
    type_name = "decoder";
    direction = GST_PAD_SINK;
  } else if (strstr (klass, "Muxer") ||
      strstr (klass, "Encoder") || strstr (klass, "Pay")) {
    type_name = "encoder";
    direction = GST_PAD_SRC;
  } else {
    return;
  }

  /* decoder/demuxer sink pads should always be static and there should only
   * be one, the same applies to encoders/muxers and source pads */
  static_templates = gst_element_factory_get_static_pad_templates (factory);
  for (l = static_templates; l != NULL; l = l->next) {
    GstStaticPadTemplate *tmpl = NULL;

    tmpl = (GstStaticPadTemplate *) l->data;
    if (tmpl->direction == direction) {
      caps = gst_static_pad_template_get_caps (tmpl);
      break;
    }
  }

  if (caps == NULL) {
    g_printerr ("Couldn't find static pad template for %s '%s'\n",
        type_name, GST_OBJECT_NAME (factory));
    return;
  }

  caps = gst_caps_make_writable (caps);
  num = gst_caps_get_size (caps);
  for (i = 0; i < num; ++i) {
    GstStructure *s;
    gchar *s_str;

    s = gst_caps_get_structure (caps, i);
    /* remove fields that are almost always just MIN-MAX of some sort
     * in order to make the caps look less messy */
    gst_structure_remove_field (s, "pixel-aspect-ratio");
    gst_structure_remove_field (s, "framerate");
    gst_structure_remove_field (s, "channels");
    gst_structure_remove_field (s, "width");
    gst_structure_remove_field (s, "height");
    gst_structure_remove_field (s, "rate");
    gst_structure_remove_field (s, "depth");
    gst_structure_remove_field (s, "clock-rate");
    s_str = gst_structure_to_string (s);
    g_print ("%s-%s\n", type_name, s_str);
    g_free (s_str);
  }
  gst_caps_unref (caps);
}
示例#18
0
static void
print_plugin_features (GstPlugin * plugin)
{
  GList *features, *origlist;
  gint num_features = 0;
  gint num_elements = 0;
  gint num_tracers = 0;
  gint num_typefinders = 0;
  gint num_devproviders = 0;
  gint num_other = 0;

  origlist = features =
      gst_registry_get_feature_list_by_plugin (gst_registry_get (),
      gst_plugin_get_name (plugin));

  while (features) {
    GstPluginFeature *feature;

    feature = GST_PLUGIN_FEATURE (features->data);

    if (GST_IS_ELEMENT_FACTORY (feature)) {
      GstElementFactory *factory;

      factory = GST_ELEMENT_FACTORY (feature);
      n_print ("  %s: %s\n", GST_OBJECT_NAME (factory),
          gst_element_factory_get_metadata (factory,
              GST_ELEMENT_METADATA_LONGNAME));
      num_elements++;
    } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
      GstTypeFindFactory *factory;
      const gchar *const *extensions;

      factory = GST_TYPE_FIND_FACTORY (feature);
      extensions = gst_type_find_factory_get_extensions (factory);
      if (extensions) {
        guint i = 0;

        g_print ("  %s: %s: ", gst_plugin_get_name (plugin),
            gst_plugin_feature_get_name (feature));
        while (extensions[i]) {
          g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
          i++;
        }
        g_print ("\n");
      } else
        g_print ("  %s: %s: no extensions\n", gst_plugin_get_name (plugin),
            gst_plugin_feature_get_name (feature));

      num_typefinders++;
    } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
      GstDeviceProviderFactory *factory;

      factory = GST_DEVICE_PROVIDER_FACTORY (feature);
      n_print ("  %s: %s\n", GST_OBJECT_NAME (factory),
          gst_device_provider_factory_get_metadata (factory,
              GST_ELEMENT_METADATA_LONGNAME));
      num_devproviders++;
    } else if (GST_IS_TRACER_FACTORY (feature)) {
      n_print ("  %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
          g_type_name (G_OBJECT_TYPE (feature)));
      num_tracers++;
    } else if (feature) {
      n_print ("  %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
          g_type_name (G_OBJECT_TYPE (feature)));
      num_other++;
    }
    num_features++;
    features = g_list_next (features);
  }

  gst_plugin_feature_list_free (origlist);

  n_print ("\n");
  n_print ("  %d features:\n", num_features);
  if (num_elements > 0)
    n_print ("  +-- %d elements\n", num_elements);
  if (num_typefinders > 0)
    n_print ("  +-- %d typefinders\n", num_typefinders);
  if (num_devproviders > 0)
    n_print ("  +-- %d device providers\n", num_devproviders);
  if (num_tracers > 0)
    n_print ("  +-- %d tracers\n", num_tracers);
  if (num_other > 0)
    n_print ("  +-- %d other objects\n", num_other);

  n_print ("\n");
}