From 96d6078ada20a76f885ea04893aac5f0ca5fe48d Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 1 Nov 2007 19:45:00 +0000 Subject: Fix sbc negotiation and improves buffer handling by using GstAdapter. --- audio/gstsbcutil.c | 63 ++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 38 deletions(-) (limited to 'audio/gstsbcutil.c') diff --git a/audio/gstsbcutil.c b/audio/gstsbcutil.c index e55220c3..1d7a1227 100644 --- a/audio/gstsbcutil.c +++ b/audio/gstsbcutil.c @@ -38,25 +38,6 @@ gint gst_sbc_select_rate_from_list(const GValue *value) return g_value_get_int(gst_value_list_get_value(value, size-1)); } -/* - * Selects one rate from a range of possible rates - * TODO - use a better approach to this (it is selecting the maximum value) - */ -gint gst_sbc_select_rate_from_range(const GValue *value) -{ - return gst_value_get_int_range_max(value); -} - -/* - * Selects one number of channels from a list of possible numbers - * TODO - use a better approach to this (it is selecting the last element) - */ -gint gst_sbc_select_channels_from_list(const GValue *value) -{ - guint size = gst_value_list_get_size(value); - return g_value_get_int(gst_value_list_get_value(value, size-1)); -} - /* * Selects one number of channels option from a range of possible numbers * TODO - use a better approach to this (it is selecting the maximum value) @@ -76,15 +57,6 @@ gint gst_sbc_select_blocks_from_list(const GValue *value) return g_value_get_int(gst_value_list_get_value(value, size-1)); } -/* - * Selects one blocks option from a range of possible blocks - * TODO - use a better approach to this (it is selecting the maximum value) - */ -gint gst_sbc_select_blocks_from_range(const GValue *value) -{ - return gst_value_get_int_range_max(value); -} - /* * Selects one number of subbands from a list * TODO - use a better approach to this (it is selecting the last element) @@ -95,15 +67,6 @@ gint gst_sbc_select_subbands_from_list(const GValue *value) return g_value_get_int(gst_value_list_get_value(value, size-1)); } -/* - * Selects one subbands option from a range - * TODO - use a better approach to this (it is selecting the maximum value) - */ -gint gst_sbc_select_subbands_from_range(const GValue *value) -{ - return gst_value_get_int_range_max(value); -} - /* * Selects one bitpool option from a range * TODO - use a better approach to this (it is selecting the maximum value) @@ -187,8 +150,32 @@ const gchar *gst_sbc_get_allocation_string(int alloc) case CFG_ALLOCATION_SNR: return "snr"; case CFG_ALLOCATION_AUTO: - return NULL; /* TODO what should be selected here? */ + return "loudness"; /* TODO what should be selected here? */ default: return NULL; } } + +GstCaps* gst_sbc_caps_from_sbc(struct ipc_data_cfg *cfg, + struct ipc_codec_sbc *sbc, gint channels) +{ + GstCaps *caps; + const gchar *mode_str; + const gchar *allocation_str; + + mode_str = gst_sbc_get_mode_string(cfg->mode); + allocation_str = gst_sbc_get_allocation_string(sbc->allocation); + + caps = gst_caps_new_simple("audio/x-sbc", + "rate", G_TYPE_INT, cfg->rate, + "channels", G_TYPE_INT, channels, + "mode", G_TYPE_STRING, mode_str, + "subbands", G_TYPE_INT, sbc->subbands, + "blocks", G_TYPE_INT, sbc->blocks, + "allocation", G_TYPE_STRING, allocation_str, + "bitpool", G_TYPE_INT, sbc->bitpool, + NULL); + + return caps; +} + -- cgit