Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
discoverer: output channel positions
  • Loading branch information
MathieuDuponchelle committed Oct 11, 2017
1 parent 1d5a662 commit 889bb92
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions tools/gst-discoverer.c
Expand Up @@ -27,6 +27,7 @@
#include <glib.h>
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#include <gst/audio/audio.h>

#define MAX_INDENT 40

Expand Down Expand Up @@ -144,6 +145,33 @@ print_tags_topology (guint depth, const GstTagList * tags)
g_print ("%*s\n", 2 * depth, " ");
}

static gchar *
format_channel_mask (GstDiscovererAudioInfo * ainfo)
{
GString *s = g_string_sized_new (32);
GstAudioChannelPosition position[64];
guint channels = gst_discoverer_audio_info_get_channels (ainfo);
GEnumClass *enum_class = g_type_class_ref (GST_TYPE_AUDIO_CHANNEL_POSITION);
guint i;

if (channels == 0)
goto done;

gst_audio_channel_positions_from_mask (channels,
gst_discoverer_audio_info_get_channel_mask (ainfo), position);

for (i = 0; i < channels; i++) {
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
i + 1 == channels ? "" : ", ");
}

g_type_class_unref (enum_class);

done:
return g_string_free (s, FALSE);
}

static gchar *
gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
guint depth)
Expand All @@ -153,6 +181,7 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
const gchar *ctmp;
int len = 400;
const GstTagList *tags;
gchar *channel_positions;

g_return_val_if_fail (info != NULL, NULL);

Expand All @@ -164,8 +193,12 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
ctmp = gst_discoverer_audio_info_get_language (audio_info);
my_g_string_append_printf (s, depth, "Language: %s\n",
ctmp ? ctmp : "<unknown>");
my_g_string_append_printf (s, depth, "Channels: %u\n",
gst_discoverer_audio_info_get_channels (audio_info));

channel_positions = format_channel_mask (audio_info);
my_g_string_append_printf (s, depth, "Channels: %u (%s)\n",
gst_discoverer_audio_info_get_channels (audio_info), channel_positions);
g_free (channel_positions);

my_g_string_append_printf (s, depth, "Sample rate: %u\n",
gst_discoverer_audio_info_get_sample_rate (audio_info));
my_g_string_append_printf (s, depth, "Depth: %u\n",
Expand Down

0 comments on commit 889bb92

Please sign in to comment.