summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/gsta2dpsink.c1
-rw-r--r--audio/gstavdtpsink.c1
-rw-r--r--audio/gstbluetooth.c2
-rw-r--r--audio/gstrtpsbcpay.c3
-rw-r--r--audio/gstsbcdec.c8
-rw-r--r--audio/gstsbcdec.h1
-rw-r--r--audio/gstsbcenc.c57
-rw-r--r--audio/gstsbcutil.c283
-rw-r--r--audio/gstsbcutil.h35
9 files changed, 199 insertions, 192 deletions
diff --git a/audio/gsta2dpsink.c b/audio/gsta2dpsink.c
index 9ce73345..0b61e826 100644
--- a/audio/gsta2dpsink.c
+++ b/audio/gsta2dpsink.c
@@ -28,7 +28,6 @@
#include <unistd.h>
#include <pthread.h>
-#include "gstsbcutil.h"
#include "gsta2dpsink.h"
GST_DEBUG_CATEGORY_STATIC(gst_a2dp_sink_debug);
diff --git a/audio/gstavdtpsink.c b/audio/gstavdtpsink.c
index 8c8a7465..4c453ae9 100644
--- a/audio/gstavdtpsink.c
+++ b/audio/gstavdtpsink.c
@@ -39,7 +39,6 @@
#include "ipc.h"
#include "rtp.h"
-#include "gstsbcutil.h"
#include "gstavdtpsink.h"
diff --git a/audio/gstbluetooth.c b/audio/gstbluetooth.c
index b6b95e43..ffc69768 100644
--- a/audio/gstbluetooth.c
+++ b/audio/gstbluetooth.c
@@ -27,6 +27,8 @@
#include <gst/gst.h>
+#include <string.h>
+
#include "gstsbcutil.h"
#include <sbc.h>
diff --git a/audio/gstrtpsbcpay.c b/audio/gstrtpsbcpay.c
index 235ad6bb..70f5bef2 100644
--- a/audio/gstrtpsbcpay.c
+++ b/audio/gstrtpsbcpay.c
@@ -217,9 +217,10 @@ static GstFlowReturn gst_rtp_sbc_pay_handle_buffer(GstBaseRTPPayload *payload,
/* FIXME check for negotiation */
sbcpay = GST_RTP_SBC_PAY(payload);
+ sbcpay->timestamp = GST_BUFFER_TIMESTAMP(buffer);
+
gst_adapter_push(sbcpay->adapter, gst_buffer_copy(buffer));
- sbcpay->timestamp = GST_BUFFER_TIMESTAMP(buffer);
available = gst_adapter_available(sbcpay->adapter);
if (available + RTP_SBC_HEADER_TOTAL >=
GST_BASE_RTP_PAYLOAD_MTU(sbcpay) ||
diff --git a/audio/gstsbcdec.c b/audio/gstsbcdec.c
index d6777117..43a40f44 100644
--- a/audio/gstsbcdec.c
+++ b/audio/gstsbcdec.c
@@ -99,8 +99,12 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
/* we will reuse the same caps object */
if (dec->outcaps == NULL) {
caps = gst_caps_new_simple("audio/x-raw-int",
- "rate", G_TYPE_INT, dec->sbc.rate,
- "channels", G_TYPE_INT, dec->sbc.channels,
+ "rate", G_TYPE_INT,
+ gst_sbc_parse_rate_from_sbc(
+ dec->sbc.frequency),
+ "channels", G_TYPE_INT,
+ gst_sbc_get_channel_number(
+ dec->sbc.mode),
NULL);
template = gst_static_pad_template_get(&sbc_dec_src_factory);
diff --git a/audio/gstsbcdec.h b/audio/gstsbcdec.h
index e8ff9cf5..df687933 100644
--- a/audio/gstsbcdec.h
+++ b/audio/gstsbcdec.h
@@ -24,6 +24,7 @@
#include <gst/gst.h>
#include "sbc.h"
+#include "gstsbcutil.h"
G_BEGIN_DECLS
diff --git a/audio/gstsbcenc.c b/audio/gstsbcenc.c
index 7777084c..03423ecf 100644
--- a/audio/gstsbcenc.c
+++ b/audio/gstsbcenc.c
@@ -27,14 +27,13 @@
#include <string.h>
-#include "ipc.h"
#include "gstsbcenc.h"
#include "gstsbcutil.h"
-#define SBC_ENC_DEFAULT_MODE BT_A2DP_CHANNEL_MODE_JOINT_STEREO
+#define SBC_ENC_DEFAULT_MODE SBC_MODE_AUTO
#define SBC_ENC_DEFAULT_BLOCKS 0
#define SBC_ENC_DEFAULT_SUB_BANDS 0
-#define SBC_ENC_DEFAULT_ALLOCATION BT_A2DP_ALLOCATION_LOUDNESS
+#define SBC_ENC_DEFAULT_ALLOCATION SBC_AM_AUTO
#define SBC_ENC_DEFAULT_RATE 0
#define SBC_ENC_DEFAULT_CHANNELS 0
@@ -53,11 +52,11 @@ static GType gst_sbc_mode_get_type(void)
{
static GType sbc_mode_type = 0;
static GEnumValue sbc_modes[] = {
- { 0, "Auto", "auto" },
- { 1, "Mono", "mono" },
- { 2, "Dual Channel", "dual" },
- { 3, "Stereo", "stereo" },
- { 4, "Joint Stereo", "joint" },
+ { SBC_MODE_MONO, "Mono", "mono" },
+ { SBC_MODE_DUAL_CHANNEL, "Dual Channel", "dual" },
+ { SBC_MODE_STEREO, "Stereo", "stereo"},
+ { SBC_MODE_JOINT_STEREO, "Joint Stereo", "joint" },
+ { SBC_MODE_AUTO, "Auto", "auto" },
{ -1, NULL, NULL}
};
@@ -73,8 +72,9 @@ static GType gst_sbc_allocation_get_type(void)
{
static GType sbc_allocation_type = 0;
static GEnumValue sbc_allocations[] = {
- { BT_A2DP_ALLOCATION_LOUDNESS, "Loudness", "loudness" },
- { BT_A2DP_ALLOCATION_SNR, "SNR", "snr" },
+ { SBC_AM_LOUDNESS, "Loudness", "loudness" },
+ { SBC_AM_SNR, "SNR", "snr" },
+ { SBC_AM_AUTO, "Auto", "auto" },
{ -1, NULL, NULL}
};
@@ -172,7 +172,6 @@ static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc)
GstStructure *structure;
GEnumValue *enum_value;
GEnumClass *enum_class;
- gchar* temp;
GValue *value;
src_caps = gst_caps_copy(gst_pad_get_pad_template_caps(enc->srcpad));
@@ -208,7 +207,7 @@ static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc)
g_type_class_unref(enum_class);
}
- if (enc->allocation != SBC_ENC_DEFAULT_ALLOCATION) {
+ if (enc->allocation != SBC_AM_AUTO) {
enum_class = g_type_class_ref(GST_TYPE_SBC_ALLOCATION);
enum_value = g_enum_get_value(enum_class, enc->allocation);
gst_sbc_util_set_structure_string_param(structure, "allocation",
@@ -216,9 +215,6 @@ static GstCaps* sbc_enc_generate_srcpad_caps(GstSbcEnc *enc)
g_type_class_unref(enum_class);
}
- temp = gst_caps_to_string(src_caps);
- GST_DEBUG_OBJECT(enc, "Srcpad caps: %s", temp);
- g_free(temp);
g_free(value);
return src_caps;
@@ -244,7 +240,6 @@ static gboolean sbc_enc_src_setcaps (GstPad *pad, GstCaps *caps)
static GstCaps* sbc_enc_src_caps_fixate(GstSbcEnc *enc, GstCaps *caps)
{
-
gchar *error_message = NULL;
GstCaps* result;
@@ -316,8 +311,6 @@ static gboolean sbc_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
gboolean gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)
{
- gint mode;
-
if (!gst_caps_is_fixed(caps)) {
GST_DEBUG_OBJECT(enc, "didn't receive fixed caps, "
"returning false");
@@ -327,23 +320,26 @@ gboolean gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)
if (!gst_sbc_util_fill_sbc_params(&enc->sbc, caps))
return FALSE;
- if (enc->rate != 0 && enc->sbc.rate != enc->rate)
+ if (enc->rate != 0 && gst_sbc_parse_rate_from_sbc(enc->sbc.frequency)
+ != enc->rate)
goto fail;
- if (enc->channels != 0 && enc->sbc.channels != enc->channels)
+ if (enc->channels != 0 && gst_sbc_get_channel_number(enc->sbc.mode)
+ != enc->channels)
goto fail;
- if (enc->blocks != 0 && enc->sbc.blocks != enc->blocks)
+ if (enc->blocks != 0 && gst_sbc_parse_blocks_from_sbc(enc->sbc.blocks)
+ != enc->blocks)
goto fail;
- if (enc->subbands != 0 && enc->sbc.subbands != enc->subbands)
+ if (enc->subbands != 0 && gst_sbc_parse_subbands_from_sbc(
+ enc->sbc.subbands) != enc->subbands)
goto fail;
- mode = gst_sbc_get_mode_int_from_sbc_t(&enc->sbc);
- if (enc->mode != SBC_ENC_DEFAULT_MODE && mode != enc->mode)
+ if (enc->mode != SBC_ENC_DEFAULT_MODE && enc->sbc.mode != enc->mode)
goto fail;
- if (enc->allocation != SBC_ENC_DEFAULT_ALLOCATION &&
+ if (enc->allocation != SBC_AM_AUTO &&
enc->sbc.allocation != enc->allocation)
goto fail;
@@ -355,8 +351,9 @@ gboolean gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)
enc->frame_length = sbc_get_frame_length(&enc->sbc);
enc->frame_duration = sbc_get_frame_duration(&enc->sbc);
- GST_DEBUG("codesize: %d, frame_length: %d, frame_duration: %d",
- enc->codesize, enc->frame_length, enc->frame_duration);
+ GST_DEBUG_OBJECT(enc, "codesize: %d, frame_length: %d, frame_duration:"
+ " %d", enc->codesize, enc->frame_length,
+ enc->frame_duration);
return TRUE;
@@ -378,7 +375,7 @@ static GstFlowReturn sbc_enc_chain(GstPad *pad, GstBuffer *buffer)
GstBuffer *output;
GstCaps *caps;
const guint8 *data;
- int consumed;
+ gint consumed;
caps = GST_PAD_CAPS(enc->srcpad);
res = gst_pad_alloc_buffer_and_set_caps(enc->srcpad,
@@ -389,12 +386,13 @@ static GstFlowReturn sbc_enc_chain(GstPad *pad, GstBuffer *buffer)
goto done;
data = gst_adapter_peek(adapter, enc->codesize);
+
consumed = sbc_encode(&enc->sbc, (gpointer) data,
enc->codesize,
GST_BUFFER_DATA(output),
GST_BUFFER_SIZE(output), NULL);
if (consumed <= 0) {
- GST_ERROR ("comsumed < 0, codesize: %d",
+ GST_DEBUG_OBJECT (enc, "comsumed < 0, codesize: %d",
enc->codesize);
break;
}
@@ -405,6 +403,7 @@ static GstFlowReturn sbc_enc_chain(GstPad *pad, GstBuffer *buffer)
GST_BUFFER_DURATION(output) = enc->frame_duration;
res = gst_pad_push(enc->srcpad, output);
+
if (res != GST_FLOW_OK)
goto done;
}
diff --git a/audio/gstsbcutil.c b/audio/gstsbcutil.c
index de48838f..5d646cfb 100644
--- a/audio/gstsbcutil.c
+++ b/audio/gstsbcutil.c
@@ -25,7 +25,6 @@
#include <config.h>
#endif
-#include "ipc.h"
#include <math.h>
#include "gstsbcutil.h"
@@ -120,163 +119,192 @@ const gchar *gst_sbc_get_mode_from_list(const GValue *list, gint channels)
return "joint";
else if (stereo)
return "stereo";
+ else if (dual)
+ return "dual";
}
return NULL;
}
-gint gst_sbc_get_allocation_mode_int(const gchar *allocation)
+gint gst_sbc_parse_rate_from_sbc(gint frequency)
{
- if (g_ascii_strcasecmp(allocation, "loudness") == 0)
- return BT_A2DP_ALLOCATION_LOUDNESS;
- else if (g_ascii_strcasecmp(allocation, "snr") == 0)
- return BT_A2DP_ALLOCATION_SNR;
- else
- return -1;
+ switch (frequency) {
+ case SBC_FREQ_16000:
+ return 16000;
+ case SBC_FREQ_32000:
+ return 32000;
+ case SBC_FREQ_44100:
+ return 44100;
+ case SBC_FREQ_48000:
+ return 48000;
+ default:
+ return 0;
+ }
}
-gint gst_sbc_get_mode_int(const gchar *mode)
+gint gst_sbc_parse_rate_to_sbc(gint rate)
{
- if (g_ascii_strcasecmp(mode, "joint") == 0)
- return BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
- else if (g_ascii_strcasecmp(mode, "stereo") == 0)
- return BT_A2DP_CHANNEL_MODE_STEREO;
- else if (g_ascii_strcasecmp(mode, "dual") == 0)
- return BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
- else if (g_ascii_strcasecmp(mode, "mono") == 0)
- return BT_A2DP_CHANNEL_MODE_MONO;
- else
+ switch (rate) {
+ case 16000:
+ return SBC_FREQ_16000;
+ case 32000:
+ return SBC_FREQ_32000;
+ case 44100:
+ return SBC_FREQ_44100;
+ case 48000:
+ return SBC_FREQ_48000;
+ default:
return -1;
+ }
}
-/* FIXME add dual when sbc_t supports it */
-gboolean gst_sbc_get_mode_int_for_sbc_t(const gchar *mode)
+gint gst_sbc_get_channel_number(gint mode)
{
- if (g_ascii_strcasecmp(mode, "joint") == 0)
- return TRUE;
- else if (g_ascii_strcasecmp(mode, "stereo") == 0)
- return FALSE;
- else if (g_ascii_strcasecmp(mode, "mono") == 0)
- return FALSE;
- else
- return -1;
+ switch (mode) {
+ case SBC_MODE_JOINT_STEREO:
+ case SBC_MODE_STEREO:
+ case SBC_MODE_DUAL_CHANNEL:
+ return 2;
+ case SBC_MODE_MONO:
+ return 1;
+ default:
+ return 0;
+ }
}
-gint gst_sbc_get_mode_int_from_sbc_t(const sbc_t *sbc)
+gint gst_sbc_parse_subbands_from_sbc(gint subbands)
{
- /* TODO define constants */
- if (sbc->channels == 2 && sbc->joint == 1)
+ switch (subbands) {
+ case SBC_SB_4:
return 4;
- else if (sbc->channels == 2 && sbc->joint == 0)
- return 3;
- else if (sbc->channels == 1)
- return 1;
- else
- return -1;
+ case SBC_SB_8:
+ return 8;
+ default:
+ return 0;
+ }
}
-const gchar *gst_sbc_get_mode_string(gint joint)
+gint gst_sbc_parse_subbands_to_sbc(gint subbands)
{
- switch (joint) {
- case BT_A2DP_CHANNEL_MODE_MONO:
- return "mono";
- case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
- return "dual";
- case BT_A2DP_CHANNEL_MODE_STEREO:
- return "stereo";
- case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
- return "joint";
+ switch (subbands) {
+ case 4:
+ return SBC_SB_4;
+ case 8:
+ return SBC_SB_8;
default:
- return NULL;
+ return -1;
}
}
-const gchar *gst_sbc_get_allocation_string(gint alloc)
+gint gst_sbc_parse_blocks_from_sbc(gint blocks)
{
- switch (alloc) {
- case BT_A2DP_ALLOCATION_LOUDNESS:
- return "loudness";
- case BT_A2DP_ALLOCATION_SNR:
- return "snr";
+ switch (blocks) {
+ case SBC_BLK_4:
+ return 4;
+ case SBC_BLK_8:
+ return 8;
+ case SBC_BLK_12:
+ return 12;
+ case SBC_BLK_16:
+ return 16;
default:
- return NULL;
+ return 0;
}
}
-/* channel mode */
-#define SBC_CM_MONO 0x00
-#define SBC_CM_DUAL_CHANNEL 0x01
-#define SBC_CM_STEREO 0x02
-#define SBC_CM_JOINT_STEREO 0x03
-
-/* allocation mode */
-#define SBC_AM_LOUDNESS 0x00
-#define SBC_AM_SNR 0x01
+gint gst_sbc_parse_blocks_to_sbc(gint blocks)
+{
+ switch (blocks) {
+ case 4:
+ return SBC_BLK_4;
+ case 8:
+ return SBC_BLK_8;
+ case 12:
+ return SBC_BLK_12;
+ case 16:
+ return SBC_BLK_16;
+ default:
+ return -1;
+ }
+}
-const gchar *gst_sbc_get_mode_string_from_sbc_t(gint channels, gint joint)
+const gchar *gst_sbc_parse_mode_from_sbc(gint mode)
{
- if (channels == 2 && joint == 1)
- return "joint";
- else if (channels == 2 && joint == 0)
- return "stereo";
- else if (channels == 1 && joint == 0)
+ switch (mode) {
+ case SBC_MODE_MONO:
return "mono";
- else
+ case SBC_MODE_DUAL_CHANNEL:
+ return "dual";
+ case SBC_MODE_STEREO:
+ return "stereo";
+ case SBC_MODE_JOINT_STEREO:
+ case SBC_MODE_AUTO:
+ return "joint";
+ default:
return NULL;
+ }
}
-const gchar *gst_sbc_get_allocation_string_from_sbc_t(gint alloc)
+gint gst_sbc_parse_mode_to_sbc(const gchar *mode)
+{
+ if (g_ascii_strcasecmp(mode, "joint") == 0)
+ return SBC_MODE_JOINT_STEREO;
+ else if (g_ascii_strcasecmp(mode, "stereo") == 0)
+ return SBC_MODE_STEREO;
+ else if (g_ascii_strcasecmp(mode, "dual") == 0)
+ return SBC_MODE_DUAL_CHANNEL;
+ else if (g_ascii_strcasecmp(mode, "mono") == 0)
+ return SBC_MODE_MONO;
+ else if (g_ascii_strcasecmp(mode, "auto") == 0)
+ return SBC_MODE_JOINT_STEREO;
+ else
+ return -1;
+}
+
+const gchar *gst_sbc_parse_allocation_from_sbc(gint alloc)
{
switch (alloc) {
case SBC_AM_LOUDNESS:
return "loudness";
case SBC_AM_SNR:
return "snr";
+ case SBC_AM_AUTO:
+ return "loudness";
default:
return NULL;
}
}
-GstCaps* gst_sbc_parse_caps_from_sbc(sbc_t *sbc)
+gint gst_sbc_parse_allocation_to_sbc(const gchar *allocation)
{
- GstCaps *caps;
- const gchar *mode_str;
- const gchar *allocation_str;
-
- mode_str = gst_sbc_get_mode_string_from_sbc_t(sbc->channels,
- sbc->joint);
- allocation_str = gst_sbc_get_allocation_string_from_sbc_t(
- sbc->allocation);
- caps = gst_caps_new_simple("audio/x-sbc",
- "rate", G_TYPE_INT, sbc->rate,
- "channels", G_TYPE_INT, sbc->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;
+ if (g_ascii_strcasecmp(allocation, "loudness") == 0)
+ return SBC_AM_LOUDNESS;
+ else if (g_ascii_strcasecmp(allocation, "snr") == 0)
+ return SBC_AM_SNR;
+ else
+ return SBC_AM_LOUDNESS;
}
-GstCaps* gst_sbc_caps_from_sbc(sbc_capabilities_t *sbc, gint channels)
+GstCaps* gst_sbc_parse_caps_from_sbc(sbc_t *sbc)
{
GstCaps *caps;
const gchar *mode_str;
const gchar *allocation_str;
- mode_str = gst_sbc_get_mode_string(sbc->channel_mode);
- allocation_str = gst_sbc_get_allocation_string(sbc->allocation_method);
-
+ mode_str = gst_sbc_parse_mode_from_sbc(sbc->mode);
+ allocation_str = gst_sbc_parse_allocation_from_sbc(sbc->allocation);
caps = gst_caps_new_simple("audio/x-sbc",
- "rate", G_TYPE_INT, sbc->frequency,
- "channels", G_TYPE_INT, channels,
+ "rate", G_TYPE_INT,
+ gst_sbc_parse_rate_from_sbc(sbc->frequency),
+ "channels", G_TYPE_INT,
+ gst_sbc_get_channel_number(sbc->mode),
"mode", G_TYPE_STRING, mode_str,
- "subbands", G_TYPE_INT, sbc->subbands,
- "blocks", G_TYPE_INT, sbc->block_length,
+ "subbands", G_TYPE_INT,
+ gst_sbc_parse_subbands_from_sbc(sbc->subbands),
+ "blocks", G_TYPE_INT,
+ gst_sbc_parse_blocks_from_sbc(sbc->blocks),
"allocation", G_TYPE_STRING, allocation_str,
- "bitpool", G_TYPE_INT, sbc->max_bitpool,
+ "bitpool", G_TYPE_INT, sbc->bitpool,
NULL);
return caps;
@@ -393,12 +421,11 @@ GstCaps* gst_sbc_util_caps_fixate(GstCaps *caps, gchar** error_message)
mode = g_value_get_string(value);
}
- /* perform validation
+ /* perform validation
* if channels is 1, we must have channel mode = mono
- * if channels is 2, we can't have channel mode = mono, dual */
+ * if channels is 2, we can't have channel mode = mono */
if ( (channels == 1 && (strcmp(mode, "mono") != 0) ) ||
- ( channels == 2 && ( strcmp(mode, "mono") == 0 ||
- strcmp(mode, "dual") == 0 ) )) {
+ ( channels == 2 && ( strcmp(mode, "mono") == 0))) {
*error_message = g_strdup_printf("Invalid combination of "
"channels (%d) and channel mode (%s)",
channels, mode);
@@ -479,46 +506,16 @@ gboolean gst_sbc_util_fill_sbc_params(sbc_t *sbc, GstCaps *caps)
if (!(allocation = gst_structure_get_string(structure, "allocation")))
return FALSE;
- sbc->rate = rate;
- sbc->channels = channels;
- sbc->blocks = blocks;
- sbc->subbands = subbands;
+ if (channels == 1 && strcmp(mode, "mono") != 0)
+ return FALSE;
+
+ sbc->frequency = gst_sbc_parse_rate_to_sbc(rate);
+ sbc->blocks = gst_sbc_parse_blocks_to_sbc(blocks);
+ sbc->subbands = gst_sbc_parse_subbands_to_sbc(subbands);
sbc->bitpool = bitpool;
- sbc->joint = gst_sbc_get_mode_int_for_sbc_t(mode);
- sbc->allocation = gst_sbc_get_allocation_mode_int(allocation);
+ sbc->mode = gst_sbc_parse_mode_to_sbc(mode);
+ sbc->allocation = gst_sbc_parse_allocation_to_sbc(allocation);
return TRUE;
}
-gint gst_sbc_util_calc_frame_len(gint subbands, gint channels,
- gint blocks, gint bitpool, gint channel_mode)
-{
- gint len;
- gint join;
- len = 4 + (4 * subbands * channels)/8;
-
- if (channel_mode == BT_A2DP_CHANNEL_MODE_MONO ||
- channel_mode == BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
- len += ((blocks * channels * bitpool)+7) / 8;
- else {
- join = channel_mode == BT_A2DP_CHANNEL_MODE_JOINT_STEREO
- ? 1 : 0;
- len += ((join * subbands + blocks * bitpool)+7)/8;
- }
-
- return len;
-}
-
-gint gst_sbc_util_calc_bitrate(gint frame_len, gint rate, gint subbands,
- gint blocks)
-{
- return (((frame_len * 8 * rate / subbands) / blocks) / 1000);
-}
-
-gint64 gst_sbc_util_calc_frame_duration(gint rate, gint blocks, gint subbands)
-{
- gint64 res = 1000000;
- return res * blocks * subbands / rate;
-}
-
-
diff --git a/audio/gstsbcutil.h b/audio/gstsbcutil.h
index c0e876fd..a3cf937c 100644
--- a/audio/gstsbcutil.h
+++ b/audio/gstsbcutil.h
@@ -24,7 +24,10 @@
#include <gst/gst.h>
#include "sbc.h"
-#include "ipc.h"
+#include <string.h>
+
+#define SBC_AM_AUTO 0x02
+#define SBC_MODE_AUTO 0x04
gint gst_sbc_select_rate_from_list(const GValue *value);
@@ -39,15 +42,25 @@ gint gst_sbc_select_bitpool_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);
const gchar *gst_sbc_get_mode_from_list(const GValue *value, gint channels);
-gint gst_sbc_get_mode_int(const gchar *mode);
-gint gst_sbc_get_mode_int_from_sbc_t(const sbc_t *sbc);
-const gchar *gst_sbc_get_mode_string(int joint);
-GstCaps* gst_sbc_caps_from_sbc(sbc_capabilities_t *sbc, gint channels);
+gint gst_sbc_get_channel_number(gint mode);
+gint gst_sbc_parse_rate_from_sbc(gint frequency);
+gint gst_sbc_parse_rate_to_sbc(gint rate);
+
+gint gst_sbc_parse_subbands_from_sbc(gint subbands);
+gint gst_sbc_parse_subbands_to_sbc(gint subbands);
+
+gint gst_sbc_parse_blocks_from_sbc(gint blocks);
+gint gst_sbc_parse_blocks_to_sbc(gint blocks);
+
+const gchar *gst_sbc_parse_mode_from_sbc(gint mode);
+gint gst_sbc_parse_mode_to_sbc(const gchar *mode);
+
+const gchar *gst_sbc_parse_allocation_from_sbc(gint alloc);
+gint gst_sbc_parse_allocation_to_sbc(const gchar *allocation);
+
GstCaps* gst_sbc_parse_caps_from_sbc(sbc_t *sbc);
GstCaps* gst_sbc_util_caps_fixate(GstCaps *caps, gchar** error_message);
@@ -62,11 +75,3 @@ void gst_sbc_util_set_structure_string_param(GstStructure *structure,
gboolean gst_sbc_util_fill_sbc_params(sbc_t *sbc, GstCaps *caps);
-gint gst_sbc_util_calc_frame_len(gint subbands, gint channels,
- gint blocks, gint bitpool, gint channel_mode);
-
-gint gst_sbc_util_calc_bitrate(gint frame_len, gint rate, gint subbands,
- gint blocks);
-
-gint64 gst_sbc_util_calc_frame_duration(gint rate, gint blocks, gint subbands);
-