diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-10-29 15:02:26 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-10-29 15:02:26 +0000 |
commit | ea39736b353ba409d03e8f86b7ca6ca1e746fecd (patch) | |
tree | 09f978819246b2c25cb0a1bb53da66cafce5df61 | |
parent | 973d90d520edc392c458c556d9f1a3e242a1f080 (diff) |
Add bitpool capability.
-rw-r--r-- | audio/gsta2dpsink.c | 7 | ||||
-rw-r--r-- | audio/gstsbcenc.c | 7 | ||||
-rw-r--r-- | audio/gstsbcparse.c | 23 | ||||
-rw-r--r-- | audio/gstsbcutil.c | 9 | ||||
-rw-r--r-- | audio/gstsbcutil.h | 2 |
5 files changed, 42 insertions, 6 deletions
diff --git a/audio/gsta2dpsink.c b/audio/gsta2dpsink.c index 0ed39a66..be81efe8 100644 --- a/audio/gsta2dpsink.c +++ b/audio/gsta2dpsink.c @@ -112,7 +112,8 @@ static GstStaticPadTemplate a2dp_sink_factory = "mode = (string) { mono, dual, stereo, joint }, " "blocks = (int) { 4, 8, 12, 16 }, " "subbands = (int) { 4, 8 }, " - "allocation = (string) { snr, loudness }; " + "allocation = (string) { snr, loudness }," + "bitpool = (int) [ 2, 64 ]; " "audio/mpeg, " "mpegversion = (int) 1, " "layer = (int) [ 1, 3 ], " @@ -335,7 +336,9 @@ static gboolean gst_a2dp_sink_init_pkt_conf(GstA2dpSink *sink, value = gst_structure_get_value(structure, "blocks"); sbc->blocks = g_value_get_int(value); - sbc->bitpool = 32; + + value = gst_structure_get_value(structure, "bitpool"); + sbc->bitpool = g_value_get_int(value); pkt->length = sizeof(*cfg) + sizeof(*sbc); pkt->type = PKT_TYPE_CFG_REQ; diff --git a/audio/gstsbcenc.c b/audio/gstsbcenc.c index 628d15c9..69e67aeb 100644 --- a/audio/gstsbcenc.c +++ b/audio/gstsbcenc.c @@ -33,6 +33,7 @@ #define SBC_ENC_DEFAULT_MODE CFG_MODE_AUTO #define SBC_ENC_DEFAULT_BLOCKS 16 #define SBC_ENC_DEFAULT_SUB_BANDS 8 +#define SBC_ENC_DEFAULT_BITPOOL 53 #define SBC_ENC_DEFAULT_ALLOCATION CFG_ALLOCATION_AUTO GST_DEBUG_CATEGORY_STATIC(sbc_enc_debug); @@ -111,7 +112,8 @@ static GstStaticPadTemplate sbc_enc_src_factory = "mode = (string) { mono, dual, stereo, joint }, " "blocks = (int) { 4, 8, 12, 16 }, " "subbands = (int) { 4, 8 }, " - "allocation = (string) { snr, loudness }")); + "allocation = (string) { snr, loudness }," + "bitpool = (int) [ 2, 64 ]")); static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc, GstCaps *caps) @@ -145,6 +147,8 @@ static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc, GstCaps *caps) else enc->sbc.allocation = enc->allocation; + enc->sbc.bitpool = SBC_ENC_DEFAULT_BITPOOL; + mode = gst_sbc_get_mode_string(enc->sbc.joint); allocation = gst_sbc_get_allocation_string(enc->sbc.allocation); @@ -155,6 +159,7 @@ static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc, GstCaps *caps) "subbands", G_TYPE_INT, enc->sbc.subbands, "blocks", G_TYPE_INT, enc->sbc.blocks, "allocation", G_TYPE_STRING, allocation, + "bitpool", G_TYPE_INT, enc->sbc.bitpool, NULL); return src_caps; diff --git a/audio/gstsbcparse.c b/audio/gstsbcparse.c index a15a75fb..42ae9550 100644 --- a/audio/gstsbcparse.c +++ b/audio/gstsbcparse.c @@ -53,16 +53,17 @@ static GstStaticPadTemplate sbc_parse_src_factory = "mode = (string) { mono, dual, stereo, joint }, " "blocks = (int) { 4, 8, 12, 16 }, " "subbands = (int) { 4, 8 }, " - "allocation = (string) { snr, loudness }")); + "allocation = (string) { snr, loudness }," + "bitpool = (int) [ 2, 64 ]")); -/* reates a fixed caps from the caps given. */ +/* Creates a fixed caps from the caps given. */ static GstCaps* sbc_parse_select_caps(GstSbcParse *parse, GstCaps *caps) { GstCaps *result; GstStructure *structure; const GValue *value; gboolean error = FALSE; - gint temp, rate, channels, blocks, subbands; + gint temp, rate, channels, blocks, subbands, bitpool; const gchar* allocation = NULL; const gchar* mode = NULL; const gchar* error_message = NULL; @@ -133,6 +134,20 @@ static GstCaps* sbc_parse_select_caps(GstSbcParse *parse, GstCaps *caps) subbands = temp; } + if (!gst_structure_has_field(structure, "bitpool")) { + error = TRUE; + error_message = "no bitpool"; + goto error; + } else { + value = gst_structure_get_value(structure, "bitpool"); + if (GST_VALUE_HOLDS_INT_RANGE(value)) { + temp = gst_sbc_select_bitpool_from_range(value); + } else { + temp = g_value_get_int(value); + } + bitpool = temp; + } + if (!gst_structure_has_field(structure, "allocation")) { error = TRUE; error_message = "no allocation."; @@ -173,11 +188,13 @@ error: "blocks", G_TYPE_INT, blocks, "subbands", G_TYPE_INT, subbands, "allocation", G_TYPE_STRING, allocation, + "bitpool", G_TYPE_INT, bitpool, NULL); parse->sbc.rate = rate; parse->sbc.channels = channels; parse->sbc.blocks = blocks; parse->sbc.subbands = subbands; + parse->sbc.bitpool = bitpool; parse->sbc.joint = gst_sbc_get_mode_int(mode); parse->sbc.allocation = gst_sbc_get_allocation_mode_int(allocation); diff --git a/audio/gstsbcutil.c b/audio/gstsbcutil.c index c795aedc..e55220c3 100644 --- a/audio/gstsbcutil.c +++ b/audio/gstsbcutil.c @@ -105,6 +105,15 @@ gint gst_sbc_select_subbands_from_range(const GValue *value) } /* + * Selects one bitpool option from a range + * TODO - use a better approach to this (it is selecting the maximum value) + */ +gint gst_sbc_select_bitpool_from_range(const GValue *value) +{ + return gst_value_get_int_range_max(value); +} + +/* * Selects one allocation mode from the ones on the list * TODO - use a better approach */ diff --git a/audio/gstsbcutil.h b/audio/gstsbcutil.h index 70169a74..98f202f0 100644 --- a/audio/gstsbcutil.h +++ b/audio/gstsbcutil.h @@ -35,6 +35,8 @@ gint gst_sbc_select_blocks_from_range(const GValue *value); gint gst_sbc_select_subbands_from_list(const GValue *value); gint gst_sbc_select_subbands_from_range(const GValue *value); +gint gst_sbc_select_bitpool_from_range(const GValue *value); + const gchar *gst_sbc_get_allocation_from_list(const GValue *value); gint gst_sbc_get_allocation_mode_int(const gchar *allocation); const gchar *gst_sbc_get_allocation_string(int alloc); |