gst-discoverer: don't use GstStructure API on tag lists

This commit is contained in:
Tim-Philipp Müller 2012-05-26 19:50:46 +01:00
parent 59d8d73aa2
commit d9adf02a5a

View file

@ -103,7 +103,7 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
my_g_string_append_printf (s, depth, "Tags:\n"); my_g_string_append_printf (s, depth, "Tags:\n");
tags = gst_discoverer_stream_info_get_tags (info); tags = gst_discoverer_stream_info_get_tags (info);
if (tags) { if (tags) {
tmp = gst_structure_to_string ((GstStructure *) tags); tmp = gst_tag_list_to_string (tags);
my_g_string_append_printf (s, depth, " %s\n", tmp); my_g_string_append_printf (s, depth, " %s\n", tmp);
g_free (tmp); g_free (tmp);
} else { } else {
@ -175,7 +175,7 @@ gst_stream_video_information_to_string (GstDiscovererStreamInfo * info,
my_g_string_append_printf (s, depth, "Tags:\n"); my_g_string_append_printf (s, depth, "Tags:\n");
tags = gst_discoverer_stream_info_get_tags (info); tags = gst_discoverer_stream_info_get_tags (info);
if (tags) { if (tags) {
tmp = gst_structure_to_string ((GstStructure *) tags); tmp = gst_tag_list_to_string (tags);
my_g_string_append_printf (s, depth, " %s\n", tmp); my_g_string_append_printf (s, depth, " %s\n", tmp);
g_free (tmp); g_free (tmp);
} else { } else {
@ -227,7 +227,7 @@ gst_stream_subtitle_information_to_string (GstDiscovererStreamInfo * info,
my_g_string_append_printf (s, depth, "Tags:\n"); my_g_string_append_printf (s, depth, "Tags:\n");
tags = gst_discoverer_stream_info_get_tags (info); tags = gst_discoverer_stream_info_get_tags (info);
if (tags) { if (tags) {
tmp = gst_structure_to_string ((GstStructure *) tags); tmp = gst_tag_list_to_string (tags);
my_g_string_append_printf (s, depth, " %s\n", tmp); my_g_string_append_printf (s, depth, " %s\n", tmp);
g_free (tmp); g_free (tmp);
} else { } else {
@ -311,10 +311,9 @@ print_topology (GstDiscovererStreamInfo * info, gint depth)
} }
} }
static gboolean static void
print_tag_each (GQuark field_id, const GValue * value, gpointer user_data) print_tag (const gchar * tag_name, const GValue * value, gint tab)
{ {
gint tab = GPOINTER_TO_INT (user_data);
gchar *ser; gchar *ser;
if (G_VALUE_HOLDS_STRING (value)) if (G_VALUE_HOLDS_STRING (value))
@ -333,13 +332,11 @@ print_tag_each (GQuark field_id, const GValue * value, gpointer user_data)
} else } else
ser = gst_value_serialize (value); ser = gst_value_serialize (value);
g_print ("%*s%s: %s\n", tab, " ", g_print ("%*s%s: %s\n", tab, " ", gst_tag_get_nick (tag_name), ser);
gst_tag_get_nick (g_quark_to_string (field_id)), ser);
g_free (ser); g_free (ser);
return TRUE;
} }
/* FIXME: this function is almost identical to print_tag() */
static void static void
print_tag_foreach (const GstTagList * tags, const gchar * tag, print_tag_foreach (const GstTagList * tags, const gchar * tag,
gpointer user_data) gpointer user_data)
@ -399,9 +396,19 @@ print_properties (GstDiscovererInfo * info, gint tab)
g_print ("%*sSeekable: %s\n", tab + 1, " ", g_print ("%*sSeekable: %s\n", tab + 1, " ",
(gst_discoverer_info_get_seekable (info) ? "yes" : "no")); (gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
if ((tags = gst_discoverer_info_get_tags (info))) { if ((tags = gst_discoverer_info_get_tags (info))) {
guint num_tags, i;
g_print ("%*sTags: \n", tab + 1, " "); g_print ("%*sTags: \n", tab + 1, " ");
gst_structure_foreach ((const GstStructure *) tags, print_tag_each, num_tags = gst_tag_list_n_tags (tags);
GINT_TO_POINTER (tab + 5)); for (i = 0; i < num_tags; ++i) {
const GValue *val;
const gchar *tag_name;
tag_name = gst_tag_list_nth_tag_name (tags, i);
/* FIXME: print all entries for a tag if there are multiple ones */
val = gst_tag_list_get_value_index (tags, tag_name, 0);
print_tag (tag_name, val, tab + 5);
}
} }
if (show_toc && (toc = gst_discoverer_info_get_toc (info))) { if (show_toc && (toc = gst_discoverer_info_get_toc (info))) {
g_print ("%*sTOC: \n", tab + 1, " "); g_print ("%*sTOC: \n", tab + 1, " ");