diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2013-10-03 19:52:58 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2013-10-03 19:52:58 +0200 |
commit | a6cf3c8aac41db0cb670ae5277ec5f8c5d510206 (patch) | |
tree | a11bc43c6494cbaed255a75a7c4f0b3e99e49250 | |
parent | 20cdbc83f3cebc2eba1eaf79445a6bda13fdafac (diff) |
discoverer: extract helper to print common stream info
Save some lnes of code by using a helper for common stream info.
-rw-r--r-- | tools/gst-discoverer.c | 78 |
1 files changed, 25 insertions, 53 deletions
diff --git a/tools/gst-discoverer.c b/tools/gst-discoverer.c index 2c02b0784..563616ce7 100644 --- a/tools/gst-discoverer.c +++ b/tools/gst-discoverer.c @@ -51,21 +51,13 @@ my_g_string_append_printf (GString * str, int depth, const gchar * format, ...) va_end (args); } -static gchar * -gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info, +static void +gst_stream_information_to_string (GstDiscovererStreamInfo * info, GString * s, gint depth) { - GstDiscovererAudioInfo *audio_info; - GString *s; gchar *tmp; - const gchar *ctmp; - int len = 400; - const GstTagList *tags; GstCaps *caps; - - g_return_val_if_fail (info != NULL, NULL); - - s = g_string_sized_new (len); + const GstStructure *misc; my_g_string_append_printf (s, depth, "Codec:\n"); caps = gst_discoverer_stream_info_get_caps (info); @@ -75,8 +67,8 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info, g_free (tmp); my_g_string_append_printf (s, depth, "Additional info:\n"); - if (gst_discoverer_stream_info_get_misc (info)) { - tmp = gst_structure_to_string (gst_discoverer_stream_info_get_misc (info)); + if ((misc = gst_discoverer_stream_info_get_misc (info))) { + tmp = gst_structure_to_string (misc); my_g_string_append_printf (s, depth, " %s\n", tmp); g_free (tmp); } else { @@ -85,6 +77,24 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info, my_g_string_append_printf (s, depth, "Stream ID: %s\n", gst_discoverer_stream_info_get_stream_id (info)); +} + +static gchar * +gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info, + gint depth) +{ + GstDiscovererAudioInfo *audio_info; + GString *s; + gchar *tmp; + const gchar *ctmp; + int len = 400; + const GstTagList *tags; + + g_return_val_if_fail (info != NULL, NULL); + + s = g_string_sized_new (len); + + gst_stream_information_to_string (info, s, depth); audio_info = (GstDiscovererAudioInfo *) info; ctmp = gst_discoverer_audio_info_get_language (audio_info); @@ -125,33 +135,13 @@ gst_stream_video_information_to_string (GstDiscovererStreamInfo * info, GString *s; gchar *tmp; int len = 500; - const GstStructure *misc; const GstTagList *tags; - GstCaps *caps; g_return_val_if_fail (info != NULL, NULL); s = g_string_sized_new (len); - my_g_string_append_printf (s, depth, "Codec:\n"); - caps = gst_discoverer_stream_info_get_caps (info); - tmp = gst_caps_to_string (caps); - gst_caps_unref (caps); - my_g_string_append_printf (s, depth, " %s\n", tmp); - g_free (tmp); - - my_g_string_append_printf (s, depth, "Additional info:\n"); - misc = gst_discoverer_stream_info_get_misc (info); - if (misc) { - tmp = gst_structure_to_string (misc); - my_g_string_append_printf (s, depth, " %s\n", tmp); - g_free (tmp); - } else { - my_g_string_append_printf (s, depth, " None\n"); - } - - my_g_string_append_printf (s, depth, "Stream ID: %s\n", - gst_discoverer_stream_info_get_stream_id (info)); + gst_stream_information_to_string (info, s, depth); video_info = (GstDiscovererVideoInfo *) info; my_g_string_append_printf (s, depth, "Width: %u\n", @@ -202,30 +192,12 @@ gst_stream_subtitle_information_to_string (GstDiscovererStreamInfo * info, const gchar *ctmp; int len = 400; const GstTagList *tags; - GstCaps *caps; g_return_val_if_fail (info != NULL, NULL); s = g_string_sized_new (len); - my_g_string_append_printf (s, depth, "Codec:\n"); - caps = gst_discoverer_stream_info_get_caps (info); - tmp = gst_caps_to_string (caps); - gst_caps_unref (caps); - my_g_string_append_printf (s, depth, " %s\n", tmp); - g_free (tmp); - - my_g_string_append_printf (s, depth, "Additional info:\n"); - if (gst_discoverer_stream_info_get_misc (info)) { - tmp = gst_structure_to_string (gst_discoverer_stream_info_get_misc (info)); - my_g_string_append_printf (s, depth, " %s\n", tmp); - g_free (tmp); - } else { - my_g_string_append_printf (s, depth, " None\n"); - } - - my_g_string_append_printf (s, depth, "Stream ID: %s\n", - gst_discoverer_stream_info_get_stream_id (info)); + gst_stream_information_to_string (info, s, depth); subtitle_info = (GstDiscovererSubtitleInfo *) info; ctmp = gst_discoverer_subtitle_info_get_language (subtitle_info); |