sbc: Update gstreamer plugin to use new sbc API.

This commit is contained in:
Luiz Augusto von Dentz 2008-02-19 19:49:24 +00:00 committed by Tim-Philipp Müller
parent ccf5d9ea7e
commit 834a9b193b
5 changed files with 205 additions and 198 deletions

View file

@ -96,8 +96,10 @@ sbc_dec_chain (GstPad * pad, GstBuffer * buffer)
/* we will reuse the same caps object */ /* we will reuse the same caps object */
if (dec->outcaps == NULL) { if (dec->outcaps == NULL) {
caps = gst_caps_new_simple ("audio/x-raw-int", caps = gst_caps_new_simple ("audio/x-raw-int",
"rate", G_TYPE_INT, dec->sbc.rate, "rate", G_TYPE_INT,
"channels", G_TYPE_INT, dec->sbc.channels, NULL); 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); template = gst_static_pad_template_get (&sbc_dec_src_factory);

View file

@ -24,6 +24,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "sbc.h" #include "sbc.h"
#include "gstsbcutil.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -27,14 +27,13 @@
#include <string.h> #include <string.h>
#include "ipc.h"
#include "gstsbcenc.h" #include "gstsbcenc.h"
#include "gstsbcutil.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_BLOCKS 0
#define SBC_ENC_DEFAULT_SUB_BANDS 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_RATE 0
#define SBC_ENC_DEFAULT_CHANNELS 0 #define SBC_ENC_DEFAULT_CHANNELS 0
@ -54,11 +53,11 @@ gst_sbc_mode_get_type (void)
{ {
static GType sbc_mode_type = 0; static GType sbc_mode_type = 0;
static GEnumValue sbc_modes[] = { static GEnumValue sbc_modes[] = {
{0, "Auto", "auto"}, {SBC_MODE_MONO, "Mono", "mono"},
{1, "Mono", "mono"}, {SBC_MODE_DUAL_CHANNEL, "Dual Channel", "dual"},
{2, "Dual Channel", "dual"}, {SBC_MODE_STEREO, "Stereo", "stereo"},
{3, "Stereo", "stereo"}, {SBC_MODE_JOINT_STEREO, "Joint Stereo", "joint"},
{4, "Joint Stereo", "joint"}, {SBC_MODE_AUTO, "Auto", "auto"},
{-1, NULL, NULL} {-1, NULL, NULL}
}; };
@ -75,8 +74,9 @@ gst_sbc_allocation_get_type (void)
{ {
static GType sbc_allocation_type = 0; static GType sbc_allocation_type = 0;
static GEnumValue sbc_allocations[] = { static GEnumValue sbc_allocations[] = {
{BT_A2DP_ALLOCATION_LOUDNESS, "Loudness", "loudness"}, {SBC_AM_LOUDNESS, "Loudness", "loudness"},
{BT_A2DP_ALLOCATION_SNR, "SNR", "snr"}, {SBC_AM_SNR, "SNR", "snr"},
{SBC_AM_AUTO, "Auto", "auto"},
{-1, NULL, NULL} {-1, NULL, NULL}
}; };
@ -174,7 +174,6 @@ sbc_enc_generate_srcpad_caps (GstSbcEnc * enc)
GstStructure *structure; GstStructure *structure;
GEnumValue *enum_value; GEnumValue *enum_value;
GEnumClass *enum_class; GEnumClass *enum_class;
gchar *temp;
GValue *value; GValue *value;
src_caps = gst_caps_copy (gst_pad_get_pad_template_caps (enc->srcpad)); src_caps = gst_caps_copy (gst_pad_get_pad_template_caps (enc->srcpad));
@ -209,7 +208,7 @@ sbc_enc_generate_srcpad_caps (GstSbcEnc * enc)
g_type_class_unref (enum_class); 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_class = g_type_class_ref (GST_TYPE_SBC_ALLOCATION);
enum_value = g_enum_get_value (enum_class, enc->allocation); enum_value = g_enum_get_value (enum_class, enc->allocation);
gst_sbc_util_set_structure_string_param (structure, "allocation", gst_sbc_util_set_structure_string_param (structure, "allocation",
@ -217,9 +216,6 @@ sbc_enc_generate_srcpad_caps (GstSbcEnc * enc)
g_type_class_unref (enum_class); 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); g_free (value);
return src_caps; return src_caps;
@ -248,7 +244,6 @@ sbc_enc_src_setcaps (GstPad * pad, GstCaps * caps)
static GstCaps * static GstCaps *
sbc_enc_src_caps_fixate (GstSbcEnc * enc, GstCaps * caps) sbc_enc_src_caps_fixate (GstSbcEnc * enc, GstCaps * caps)
{ {
gchar *error_message = NULL; gchar *error_message = NULL;
GstCaps *result; GstCaps *result;
@ -323,8 +318,6 @@ sbc_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
gboolean gboolean
gst_sbc_enc_fill_sbc_params (GstSbcEnc * enc, GstCaps * caps) gst_sbc_enc_fill_sbc_params (GstSbcEnc * enc, GstCaps * caps)
{ {
gint mode;
if (!gst_caps_is_fixed (caps)) { if (!gst_caps_is_fixed (caps)) {
GST_DEBUG_OBJECT (enc, "didn't receive fixed caps, " "returning false"); GST_DEBUG_OBJECT (enc, "didn't receive fixed caps, " "returning false");
return FALSE; return FALSE;
@ -333,24 +326,26 @@ gst_sbc_enc_fill_sbc_params (GstSbcEnc * enc, GstCaps * caps)
if (!gst_sbc_util_fill_sbc_params (&enc->sbc, caps)) if (!gst_sbc_util_fill_sbc_params (&enc->sbc, caps))
return FALSE; 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; 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; 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; 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; goto fail;
mode = gst_sbc_get_mode_int_from_sbc_t (&enc->sbc); if (enc->mode != SBC_ENC_DEFAULT_MODE && enc->sbc.mode != enc->mode)
if (enc->mode != SBC_ENC_DEFAULT_MODE && mode != enc->mode)
goto fail; goto fail;
if (enc->allocation != SBC_ENC_DEFAULT_ALLOCATION && if (enc->allocation != SBC_AM_AUTO && enc->sbc.allocation != enc->allocation)
enc->sbc.allocation != enc->allocation)
goto fail; goto fail;
if (enc->bitpool != SBC_ENC_BITPOOL_AUTO && enc->sbc.bitpool != enc->bitpool) if (enc->bitpool != SBC_ENC_BITPOOL_AUTO && enc->sbc.bitpool != enc->bitpool)
@ -360,8 +355,8 @@ gst_sbc_enc_fill_sbc_params (GstSbcEnc * enc, GstCaps * caps)
enc->frame_length = sbc_get_frame_length (&enc->sbc); enc->frame_length = sbc_get_frame_length (&enc->sbc);
enc->frame_duration = sbc_get_frame_duration (&enc->sbc); enc->frame_duration = sbc_get_frame_duration (&enc->sbc);
GST_DEBUG ("codesize: %d, frame_length: %d, frame_duration: %d", GST_DEBUG_OBJECT (enc, "codesize: %d, frame_length: %d, frame_duration:"
enc->codesize, enc->frame_length, enc->frame_duration); " %d", enc->codesize, enc->frame_length, enc->frame_duration);
return TRUE; return TRUE;
@ -383,7 +378,7 @@ sbc_enc_chain (GstPad * pad, GstBuffer * buffer)
GstBuffer *output; GstBuffer *output;
GstCaps *caps; GstCaps *caps;
const guint8 *data; const guint8 *data;
int consumed; gint consumed;
caps = GST_PAD_CAPS (enc->srcpad); caps = GST_PAD_CAPS (enc->srcpad);
res = gst_pad_alloc_buffer_and_set_caps (enc->srcpad, res = gst_pad_alloc_buffer_and_set_caps (enc->srcpad,
@ -392,11 +387,12 @@ sbc_enc_chain (GstPad * pad, GstBuffer * buffer)
goto done; goto done;
data = gst_adapter_peek (adapter, enc->codesize); data = gst_adapter_peek (adapter, enc->codesize);
consumed = sbc_encode (&enc->sbc, (gpointer) data, consumed = sbc_encode (&enc->sbc, (gpointer) data,
enc->codesize, enc->codesize,
GST_BUFFER_DATA (output), GST_BUFFER_SIZE (output), NULL); GST_BUFFER_DATA (output), GST_BUFFER_SIZE (output), NULL);
if (consumed <= 0) { if (consumed <= 0) {
GST_ERROR ("comsumed < 0, codesize: %d", enc->codesize); GST_DEBUG_OBJECT (enc, "comsumed < 0, codesize: %d", enc->codesize);
break; break;
} }
gst_adapter_flush (adapter, consumed); gst_adapter_flush (adapter, consumed);
@ -406,6 +402,7 @@ sbc_enc_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_DURATION (output) = enc->frame_duration; GST_BUFFER_DURATION (output) = enc->frame_duration;
res = gst_pad_push (enc->srcpad, output); res = gst_pad_push (enc->srcpad, output);
if (res != GST_FLOW_OK) if (res != GST_FLOW_OK)
goto done; goto done;
} }

View file

@ -25,7 +25,6 @@
#include <config.h> #include <config.h>
#endif #endif
#include "ipc.h"
#include <math.h> #include <math.h>
#include "gstsbcutil.h" #include "gstsbcutil.h"
@ -127,131 +126,183 @@ gst_sbc_get_mode_from_list (const GValue * list, gint channels)
return "joint"; return "joint";
else if (stereo) else if (stereo)
return "stereo"; return "stereo";
} else if (dual)
return NULL;
}
gint
gst_sbc_get_allocation_mode_int (const gchar * allocation)
{
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;
}
gint
gst_sbc_get_mode_int (const gchar * mode)
{
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
return -1;
}
/* FIXME add dual when sbc_t supports it */
gboolean
gst_sbc_get_mode_int_for_sbc_t (const gchar * 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;
}
gint
gst_sbc_get_mode_int_from_sbc_t (const sbc_t * sbc)
{
/* TODO define constants */
if (sbc->channels == 2 && sbc->joint == 1)
return 4;
else if (sbc->channels == 2 && sbc->joint == 0)
return 3;
else if (sbc->channels == 1)
return 1;
else
return -1;
}
const gchar *
gst_sbc_get_mode_string (gint joint)
{
switch (joint) {
case BT_A2DP_CHANNEL_MODE_MONO:
return "mono";
case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
return "dual"; return "dual";
case BT_A2DP_CHANNEL_MODE_STEREO: }
return "stereo";
case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
return "joint";
default:
return NULL; return NULL;
}
gint
gst_sbc_parse_rate_from_sbc (gint frequency)
{
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_parse_rate_to_sbc (gint rate)
{
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;
}
}
gint
gst_sbc_get_channel_number (gint mode)
{
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_parse_subbands_from_sbc (gint subbands)
{
switch (subbands) {
case SBC_SB_4:
return 4;
case SBC_SB_8:
return 8;
default:
return 0;
}
}
gint
gst_sbc_parse_subbands_to_sbc (gint subbands)
{
switch (subbands) {
case 4:
return SBC_SB_4;
case 8:
return SBC_SB_8;
default:
return -1;
}
}
gint
gst_sbc_parse_blocks_from_sbc (gint blocks)
{
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 0;
}
}
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 * const gchar *
gst_sbc_get_allocation_string (gint alloc) gst_sbc_parse_mode_from_sbc (gint mode)
{ {
switch (alloc) { switch (mode) {
case BT_A2DP_ALLOCATION_LOUDNESS: case SBC_MODE_MONO:
return "loudness";
case BT_A2DP_ALLOCATION_SNR:
return "snr";
default:
return NULL;
}
}
/* 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
const gchar *
gst_sbc_get_mode_string_from_sbc_t (gint channels, gint joint)
{
if (channels == 2 && joint == 1)
return "joint";
else if (channels == 2 && joint == 0)
return "stereo";
else if (channels == 1 && joint == 0)
return "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; return NULL;
}
}
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 * const gchar *
gst_sbc_get_allocation_string_from_sbc_t (gint alloc) gst_sbc_parse_allocation_from_sbc (gint alloc)
{ {
switch (alloc) { switch (alloc) {
case SBC_AM_LOUDNESS: case SBC_AM_LOUDNESS:
return "loudness"; return "loudness";
case SBC_AM_SNR: case SBC_AM_SNR:
return "snr"; return "snr";
case SBC_AM_AUTO:
return "loudness";
default: default:
return NULL; return NULL;
} }
} }
gint
gst_sbc_parse_allocation_to_sbc (const gchar * allocation)
{
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 * GstCaps *
gst_sbc_parse_caps_from_sbc (sbc_t * sbc) gst_sbc_parse_caps_from_sbc (sbc_t * sbc)
{ {
@ -259,42 +310,24 @@ gst_sbc_parse_caps_from_sbc (sbc_t * sbc)
const gchar *mode_str; const gchar *mode_str;
const gchar *allocation_str; const gchar *allocation_str;
mode_str = gst_sbc_get_mode_string_from_sbc_t (sbc->channels, sbc->joint); mode_str = gst_sbc_parse_mode_from_sbc (sbc->mode);
allocation_str = gst_sbc_get_allocation_string_from_sbc_t (sbc->allocation); allocation_str = gst_sbc_parse_allocation_from_sbc (sbc->allocation);
caps = gst_caps_new_simple ("audio/x-sbc", caps = gst_caps_new_simple ("audio/x-sbc",
"rate", G_TYPE_INT, sbc->rate, "rate", G_TYPE_INT,
"channels", G_TYPE_INT, sbc->channels, 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, "mode", G_TYPE_STRING, mode_str,
"subbands", G_TYPE_INT, sbc->subbands, "subbands", G_TYPE_INT,
"blocks", G_TYPE_INT, sbc->blocks, 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, "allocation", G_TYPE_STRING, allocation_str,
"bitpool", G_TYPE_INT, sbc->bitpool, NULL); "bitpool", G_TYPE_INT, sbc->bitpool, NULL);
return caps; return caps;
} }
GstCaps *
gst_sbc_caps_from_sbc (sbc_capabilities_t * sbc, gint channels)
{
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);
caps = gst_caps_new_simple ("audio/x-sbc",
"rate", G_TYPE_INT, sbc->frequency,
"channels", G_TYPE_INT, channels,
"mode", G_TYPE_STRING, mode_str,
"subbands", G_TYPE_INT, sbc->subbands,
"blocks", G_TYPE_INT, sbc->block_length,
"allocation", G_TYPE_STRING, allocation_str,
"bitpool", G_TYPE_INT, sbc->max_bitpool, NULL);
return caps;
}
/* /*
* Given a GstCaps, this will return a fixed GstCaps on sucessfull conversion. * Given a GstCaps, this will return a fixed GstCaps on sucessfull conversion.
* If an error occurs, it will return NULL and error_message will contain the * If an error occurs, it will return NULL and error_message will contain the
@ -409,10 +442,9 @@ gst_sbc_util_caps_fixate (GstCaps * caps, gchar ** error_message)
/* perform validation /* perform validation
* if channels is 1, we must have channel mode = mono * 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)) || if ((channels == 1 && (strcmp (mode, "mono") != 0)) ||
(channels == 2 && (strcmp (mode, "mono") == 0 || (channels == 2 && (strcmp (mode, "mono") == 0))) {
strcmp (mode, "dual") == 0))) {
*error_message = g_strdup_printf ("Invalid combination of " *error_message = g_strdup_printf ("Invalid combination of "
"channels (%d) and channel mode (%s)", channels, mode); "channels (%d) and channel mode (%s)", channels, mode);
error = TRUE; error = TRUE;
@ -492,46 +524,15 @@ gst_sbc_util_fill_sbc_params (sbc_t * sbc, GstCaps * caps)
if (!(allocation = gst_structure_get_string (structure, "allocation"))) if (!(allocation = gst_structure_get_string (structure, "allocation")))
return FALSE; return FALSE;
sbc->rate = rate; if (channels == 1 && strcmp (mode, "mono") != 0)
sbc->channels = channels; return FALSE;
sbc->blocks = blocks;
sbc->subbands = subbands; 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->bitpool = bitpool;
sbc->joint = gst_sbc_get_mode_int_for_sbc_t (mode); sbc->mode = gst_sbc_parse_mode_to_sbc (mode);
sbc->allocation = gst_sbc_get_allocation_mode_int (allocation); sbc->allocation = gst_sbc_parse_allocation_to_sbc (allocation);
return TRUE; 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;
}

View file

@ -24,7 +24,10 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "sbc.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); 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); gint gst_sbc_select_bitpool_from_range(const GValue *value);
const gchar *gst_sbc_get_allocation_from_list(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); 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_parse_caps_from_sbc(sbc_t *sbc);
GstCaps* gst_sbc_util_caps_fixate(GstCaps *caps, gchar** error_message); GstCaps* gst_sbc_util_caps_fixate(GstCaps *caps, gchar** error_message);
@ -62,10 +75,3 @@ void gst_sbc_util_set_structure_string_param(GstStructure *structure,
gboolean gst_sbc_util_fill_sbc_params(sbc_t *sbc, GstCaps *caps); 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);