From 3cb08304da07bae0de56b6822dae712d74fbb552 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Mar 2016 11:46:45 +0100 Subject: [PATCH] gst-audio: add gst_audio_channel_positions_to_string() We currently don't log much about channel positions making debugging harder as it should be. This is the first step in my attempt to improve this. https://bugzilla.gnome.org/show_bug.cgi?id=763985 --- docs/libs/gst-plugins-base-libs-sections.txt | 1 + gst-libs/gst/audio/audio-channels.c | 105 +++++++++++++++++++++++++++ gst-libs/gst/audio/audio-channels.h | 3 + win32/common/libgstaudio.def | 1 + 4 files changed, 110 insertions(+) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index fa23f24..f357f26 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -512,6 +512,7 @@ gst_audio_check_valid_channel_positions gst_audio_buffer_reorder_channels gst_audio_reorder_channels gst_audio_get_channel_reorder_map +gst_audio_channel_positions_to_string GstAudioChannelMixer GstAudioChannelMixerFlags gst_audio_channel_mixer_new diff --git a/gst-libs/gst/audio/audio-channels.c b/gst-libs/gst/audio/audio-channels.c index b358cc2..e605633 100644 --- a/gst-libs/gst/audio/audio-channels.c +++ b/gst-libs/gst/audio/audio-channels.c @@ -538,3 +538,108 @@ gst_audio_channel_get_fallback_mask (gint channels) return default_masks[channels - 1]; } + +static const gchar * +position_to_string (GstAudioChannelPosition pos) +{ + switch (pos) { + case GST_AUDIO_CHANNEL_POSITION_NONE: + return "NONE"; + case GST_AUDIO_CHANNEL_POSITION_MONO: + return "MONO"; + case GST_AUDIO_CHANNEL_POSITION_INVALID: + return "INVALID"; + case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT: + return "FL"; + case GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT: + return "FR"; + case GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER: + return "FC"; + case GST_AUDIO_CHANNEL_POSITION_LFE1: + return "LFE1"; + case GST_AUDIO_CHANNEL_POSITION_REAR_LEFT: + return "RL"; + case GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT: + return "RR"; + case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: + return "FLoC"; + case GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: + return "FRoC"; + case GST_AUDIO_CHANNEL_POSITION_REAR_CENTER: + return "RC"; + case GST_AUDIO_CHANNEL_POSITION_LFE2: + return "LF2"; + case GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT: + return "SL"; + case GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT: + return "SR"; + case GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT: + return "TFL"; + case GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT: + return "TFR"; + case GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER: + return "TFC"; + case GST_AUDIO_CHANNEL_POSITION_TOP_CENTER: + return "TFC"; + case GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT: + return "TRL"; + case GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT: + return "TRR"; + case GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT: + return "TSL"; + case GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT: + return "TSR"; + case GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER: + return "TRC"; + case GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER: + return "BFC"; + case GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT: + return "BFL"; + case GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT: + return "BFR"; + case GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT: + return "WL"; + case GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT: + return "WR"; + case GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT: + return "SL"; + case GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT: + return "SR"; + default: + break; + } + + return "UNKNOWN"; +} + +/** + * gst_audio_channel_positions_to_string: + * @position: (array length=channels): The %GstAudioChannelPositions + * to convert. + * @channels: The number of channels. + * + * Converts @position to a human-readable string representation for + * debugging purposes. + * + * Returns: (transfer full): a newly allocated string representing + * @position + * + * Since 1.10 + */ +gchar * +gst_audio_channel_positions_to_string (const GstAudioChannelPosition * position, + gint channels) +{ + guint i; + GString *tmp; + + g_return_val_if_fail (channels > 0, FALSE); + g_return_val_if_fail (position != NULL, FALSE); + + tmp = g_string_new ("["); + for (i = 0; i < channels; i++) + g_string_append_printf (tmp, " %s", position_to_string (position[i])); + g_string_append (tmp, " ]"); + + return g_string_free (tmp, FALSE); +} diff --git a/gst-libs/gst/audio/audio-channels.h b/gst-libs/gst/audio/audio-channels.h index 4aa00de..cd57898 100644 --- a/gst-libs/gst/audio/audio-channels.h +++ b/gst-libs/gst/audio/audio-channels.h @@ -162,6 +162,9 @@ gboolean gst_audio_get_channel_reorder_map (gint channels, gint *reorder_map); guint64 gst_audio_channel_get_fallback_mask (gint channels); +gchar* gst_audio_channel_positions_to_string (const GstAudioChannelPosition * position, + gint channels); + G_END_DECLS #endif /* __GST_AUDIO_CHANNELS_H__ */ diff --git a/win32/common/libgstaudio.def b/win32/common/libgstaudio.def index b20e606..fa39be3 100644 --- a/win32/common/libgstaudio.def +++ b/win32/common/libgstaudio.def @@ -36,6 +36,7 @@ EXPORTS gst_audio_channel_position_get_type gst_audio_channel_positions_from_mask gst_audio_channel_positions_to_mask + gst_audio_channel_positions_to_string gst_audio_channel_positions_to_valid_order gst_audio_check_valid_channel_positions gst_audio_clipping_meta_api_get_type -- 2.7.4