summaryrefslogtreecommitdiff
path: root/codecs
diff options
context:
space:
mode:
authorMichal Labedzki <michal.labedzki@tieto.com>2012-09-14 15:08:17 +0200
committerEvan Huus <eapache@gmail.com>2014-02-12 01:36:02 +0000
commit10084c344c89fdadc915e47bcece84a2ac511dc5 (patch)
treecf48eed191bfd99bd2087f2d7cb3a13fa3049047 /codecs
parentab3348eeb412d45acd89ffb7d0b39189b36399ce (diff)
downloadwireshark-10084c344c89fdadc915e47bcece84a2ac511dc5.tar.gz
RTP: Add support for SBC codec in RTP Player
Add optional dependancy to libsbc to play Bluetooth SBC in A2DP payload. Also simplify RTP Player and extent codec interface. Change-Id: I52e1fce9c82e2885736354fe73c6c37168a4fda3 Reviewed-on: https://code.wireshark.org/review/19 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'codecs')
-rw-r--r--codecs/G711a/G711adecode.c68
-rw-r--r--codecs/G711a/G711adecode.h21
-rw-r--r--codecs/G711a/G711atable.h78
-rw-r--r--codecs/G711u/G711udecode.c69
-rw-r--r--codecs/G711u/G711udecode.h21
-rw-r--r--codecs/G711u/G711utable.h13
-rw-r--r--codecs/G722/G722decode.c42
-rw-r--r--codecs/G722/G722decode.h24
-rw-r--r--codecs/G726/G726decode.c41
-rw-r--r--codecs/G726/G726decode.h24
-rw-r--r--codecs/Makefile.common2
-rw-r--r--codecs/codecs.c172
-rw-r--r--codecs/codecs.h27
-rw-r--r--codecs/sbc/sbc.c37
-rw-r--r--codecs/sbc/sbc_private.h (renamed from codecs/sbc/sbc.h)21
15 files changed, 506 insertions, 154 deletions
diff --git a/codecs/G711a/G711adecode.c b/codecs/G711a/G711adecode.c
index 10fe3e2cc1..e5518932cc 100644
--- a/codecs/G711a/G711adecode.c
+++ b/codecs/G711a/G711adecode.c
@@ -22,21 +22,67 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h"
+
#include <glib.h>
+
#include "G711adecode.h"
#include "G711atable.h"
+void *
+codec_g711a_init(void)
+{
+ return NULL;
+}
+
+void
+codec_g711a_release(void *ctx _U_)
+{
+
+}
+
+int
+codec_g711a_get_channels(void *ctx _U_)
+{
+ return 1;
+}
+
+int
+codec_g711a_get_frequency(void *ctx _U_)
+{
+ return 8000;
+}
+
int
-decodeG711a(void *input, int inputSizeBytes, void *output, int *outputSizeBytes)
+codec_g711a_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes)
{
- guint8 *dataIn = (guint8 *)input;
- gint16 *dataOut = (gint16 *)output;
- int i;
-
- for (i=0; i<inputSizeBytes; i++)
- {
- dataOut[i] = alaw_exp_table[dataIn[i]];
- }
- *outputSizeBytes = inputSizeBytes * 2;
- return 0;
+ const guint8 *dataIn = (const guint8 *) input;
+ gint16 *dataOut = (gint16 *) output;
+ int i;
+
+ if (!output || !outputSizeBytes) {
+ return inputSizeBytes * 2;
+ }
+
+ for (i = 0; i < inputSizeBytes; i++)
+ {
+ dataOut[i] = alaw_exp_table[dataIn[i]];
+ }
+
+ *outputSizeBytes = inputSizeBytes * 2;
+ return inputSizeBytes * 2;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G711a/G711adecode.h b/codecs/G711a/G711adecode.h
index 4acdca31bd..b7ccd3ffaa 100644
--- a/codecs/G711a/G711adecode.h
+++ b/codecs/G711a/G711adecode.h
@@ -25,7 +25,24 @@
#ifndef __CODECS_G711ADECODE_H__
#define __CODECS_G711ADECODE_H__
-int
-decodeG711a(void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+void *codec_g711a_init(void);
+void codec_g711a_release(void *ctx);
+int codec_g711a_get_channels(void *ctx);
+int codec_g711a_get_frequency(void *ctx);
+int codec_g711a_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes);
#endif /* G711adecode.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G711a/G711atable.h b/codecs/G711a/G711atable.h
index 5c5e042127..19f2d0069d 100644
--- a/codecs/G711a/G711atable.h
+++ b/codecs/G711a/G711atable.h
@@ -23,35 +23,49 @@
*/
gint16 alaw_exp_table[256] = {
- -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
- -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
- -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
- -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
- -22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,
- -30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,
- -11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472,
- -15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,
- -344, -328, -376, -360, -280, -264, -312, -296,
- -472, -456, -504, -488, -408, -392, -440, -424,
- -88, -72, -120, -104, -24, -8, -56, -40,
- -216, -200, -248, -232, -152, -136, -184, -168,
- -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
- -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
- -688, -656, -752, -720, -560, -528, -624, -592,
- -944, -912, -1008, -976, -816, -784, -880, -848,
- 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
- 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
- 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
- 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
- 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
- 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
- 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
- 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
- 344, 328, 376, 360, 280, 264, 312, 296,
- 472, 456, 504, 488, 408, 392, 440, 424,
- 88, 72, 120, 104, 24, 8, 56, 40,
- 216, 200, 248, 232, 152, 136, 184, 168,
- 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
- 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
- 688, 656, 752, 720, 560, 528, 624, 592,
- 944, 912, 1008, 976, 816, 784, 880, 848};
+ -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
+ -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
+ -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
+ -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
+ -22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,
+ -30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,
+ -11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472,
+ -15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,
+ -344, -328, -376, -360, -280, -264, -312, -296,
+ -472, -456, -504, -488, -408, -392, -440, -424,
+ -88, -72, -120, -104, -24, -8, -56, -40,
+ -216, -200, -248, -232, -152, -136, -184, -168,
+ -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
+ -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
+ -688, -656, -752, -720, -560, -528, -624, -592,
+ -944, -912, -1008, -976, -816, -784, -880, -848,
+ 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
+ 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
+ 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
+ 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
+ 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
+ 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
+ 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
+ 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
+ 344, 328, 376, 360, 280, 264, 312, 296,
+ 472, 456, 504, 488, 408, 392, 440, 424,
+ 88, 72, 120, 104, 24, 8, 56, 40,
+ 216, 200, 248, 232, 152, 136, 184, 168,
+ 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
+ 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
+ 688, 656, 752, 720, 560, 528, 624, 592,
+ 944, 912, 1008, 976, 816, 784, 880, 848};
+
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G711u/G711udecode.c b/codecs/G711u/G711udecode.c
index c56018ad32..369e47df3f 100644
--- a/codecs/G711u/G711udecode.c
+++ b/codecs/G711u/G711udecode.c
@@ -22,21 +22,68 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h"
+
#include <glib.h>
+
#include "G711udecode.h"
#include "G711utable.h"
+void *
+codec_g711u_init(void)
+{
+ return NULL;
+}
+
+void
+codec_g711u_release(void *ctx _U_)
+{
+
+}
+
+int
+codec_g711u_get_channels(void *ctx _U_)
+{
+ return 1;
+}
+
int
-decodeG711u(void *input, int inputSizeBytes, void *output, int *outputSizeBytes)
+codec_g711u_get_frequency(void *ctx _U_)
{
- guint8 *dataIn = (guint8 *)input;
- gint16 *dataOut = (gint16 *)output;
- int i;
-
- for (i=0; i<inputSizeBytes; i++)
- {
- dataOut[i] = ulaw_exp_table[dataIn[i]];
- }
- *outputSizeBytes = inputSizeBytes * 2;
- return 0;
+ return 8000;
}
+
+int
+codec_g711u_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes)
+{
+ const guint8 *dataIn = (const guint8 *) input;
+ gint16 *dataOut = (gint16 *) output;
+ int i;
+
+ if (!output || !outputSizeBytes) {
+ return inputSizeBytes * 2;
+ }
+
+ for (i = 0; i < inputSizeBytes; i++)
+ {
+ dataOut[i] = ulaw_exp_table[dataIn[i]];
+ }
+
+ *outputSizeBytes = inputSizeBytes * 2;
+ return inputSizeBytes * 2;
+}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
+
diff --git a/codecs/G711u/G711udecode.h b/codecs/G711u/G711udecode.h
index 529d6b31fe..81cd379139 100644
--- a/codecs/G711u/G711udecode.h
+++ b/codecs/G711u/G711udecode.h
@@ -25,7 +25,24 @@
#ifndef __CODECS_G711UDECODE_H__
#define __CODECS_G711UDECODE_H__
-int
-decodeG711u(void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+void *codec_g711u_init(void);
+void codec_g711u_release(void *ctx);
+int codec_g711u_get_channels(void *ctx);
+int codec_g711u_get_frequency(void *ctx);
+int codec_g711u_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes);
#endif /* G711udecode.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G711u/G711utable.h b/codecs/G711u/G711utable.h
index 58daff053c..7e11118aef 100644
--- a/codecs/G711u/G711utable.h
+++ b/codecs/G711u/G711utable.h
@@ -55,3 +55,16 @@ gint16 ulaw_exp_table[256] = {
244, 228, 212, 196, 180, 164, 148, 132,
120, 112, 104, 96, 88, 80, 72, 64,
56, 48, 40, 32, 24, 16, 8, 0};
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G722/G722decode.c b/codecs/G722/G722decode.c
index b668b2bf57..746d150947 100644
--- a/codecs/G722/G722decode.c
+++ b/codecs/G722/G722decode.c
@@ -33,19 +33,53 @@
static g722_decode_state_t state;
-void
-initG722(void)
+void *
+codec_g722_init(void)
{
memset (&state, 0, sizeof (state));
g722_decode_init(&state, 64000, 0);
+
+ return NULL;
+}
+
+void
+codec_g722_release(void *ctx _U_)
+{
+
+}
+
+int
+codec_g722_get_channels(void *ctx _U_)
+{
+ return 1;
+}
+
+int
+codec_g722_get_frequency(void *ctx _U_)
+{
+ return 64000;
}
int
-decodeG722(void *input _U_NOSPANDSP_, int inputSizeBytes _U_NOSPANDSP_,
- void *output _U_NOSPANDSP_, int *outputSizeBytes _U_NOSPANDSP_)
+codec_g722_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes)
{
*outputSizeBytes = g722_decode(&state, output, input, inputSizeBytes);
return 0;
}
#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
+
diff --git a/codecs/G722/G722decode.h b/codecs/G722/G722decode.h
index 255092190a..0b5d8d0f88 100644
--- a/codecs/G722/G722decode.h
+++ b/codecs/G722/G722decode.h
@@ -25,10 +25,24 @@
#ifndef __CODECS_G722DECODE_H__
#define __CODECS_G722DECODE_H__
-void
-initG722(void);
-
-int
-decodeG722(void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+void *codec_g722_init(void);
+void codec_g722_release(void *ctx);
+int codec_g722_get_channels(void *ctx);
+int codec_g722_get_frequency(void *ctx);
+int codec_g722_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes);
#endif /* G722decode.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G726/G726decode.c b/codecs/G726/G726decode.c
index bcc2cd1fdc..7961364d41 100644
--- a/codecs/G726/G726decode.c
+++ b/codecs/G726/G726decode.c
@@ -37,21 +37,56 @@
static g726_state_t state;
/* Currently, only G.726-32, linear encoding, left packed is supported */
-void initG726_32(void)
+void *
+codec_g726_init(void)
{
memset (&state, 0, sizeof (state));
g726_init(&state, 32000, 0, 1);
+
+ return NULL;
+}
+
+void
+codec_g726_release(void *ctx _U_)
+{
+
+}
+
+int
+codec_g726_get_channels(void *ctx _U_)
+{
+ return 1;
+}
+
+int
+codec_g726_get_frequency(void *ctx _U_)
+{
+ return 32000;
}
/* Packing should be user defined (via the decode dialog) since due to historical reasons two diverging
* de facto standards are in use today (see RFC3551).
*/
int
-decodeG726_32(void *input, int inputSizeBytes,
- void *output, int *outputSizeBytes)
+codec_g726_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes)
{
*outputSizeBytes = 2 * g726_decode(&state, output, (void*) input, inputSizeBytes);
return 0;
}
#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
+
diff --git a/codecs/G726/G726decode.h b/codecs/G726/G726decode.h
index 3858ae33b1..a61ec9b237 100644
--- a/codecs/G726/G726decode.h
+++ b/codecs/G726/G726decode.h
@@ -25,10 +25,24 @@
#ifndef __CODECS_G726DECODE_H__
#define __CODECS_G726DECODE_H__
-void
-initG726_32(void);
-
-int
-decodeG726_32(void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+void *codec_g726_init(void);
+void codec_g726_release(void *ctx);
+int codec_g726_get_channels(void *ctx);
+int codec_g726_get_frequency(void *ctx);
+int codec_g726_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
+ int *outputSizeBytes);
#endif /* G726decode.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/Makefile.common b/codecs/Makefile.common
index 42009472c0..7f35b87d2e 100644
--- a/codecs/Makefile.common
+++ b/codecs/Makefile.common
@@ -37,5 +37,5 @@ noinst_HEADERS = \
G711u/G711udecode.h G711u/G711utable.h \
G722/G722decode.h \
G726/G726decode.h \
- sbc/sbc.h
+ sbc/sbc_private.h
diff --git a/codecs/codecs.c b/codecs/codecs.c
index 6f622bbe16..68def22dc4 100644
--- a/codecs/codecs.c
+++ b/codecs/codecs.c
@@ -26,6 +26,14 @@
#include <glib.h>
#include "codecs.h"
+#include "config.h"
+
+#include "G711a/G711adecode.h"
+#include "G711u/G711udecode.h"
+
+#ifdef HAVE_SBC
+#include "sbc/sbc_private.h"
+#endif
#ifdef HAVE_PLUGINS
@@ -37,7 +45,7 @@
* List of codec plugins.
*/
typedef struct {
- void (*register_codec_module)(void); /* routine to call to register a codec */
+ void (*register_codec_module)(void); /* routine to call to register a codec */
} codec_plugin;
static GSList *codec_plugins = NULL;
@@ -48,44 +56,44 @@ static GSList *codec_plugins = NULL;
static gboolean
check_for_codec_plugin(GModule *handle)
{
- gpointer gp;
- void (*register_codec_module)(void);
- codec_plugin *plugin;
-
- /*
- * Do we have a register_codec_module routine?
- */
- if (!g_module_symbol(handle, "register_codec_module", &gp)) {
- /* No, so this isn't a codec plugin. */
- return FALSE;
- }
-
- /*
- * Yes - this plugin includes one or more codecs.
- */
- register_codec_module = (void (*)(void))gp;
-
- /*
- * Add this one to the list of codec plugins.
- */
- plugin = (codec_plugin *)g_malloc(sizeof (codec_plugin));
- plugin->register_codec_module = register_codec_module;
- codec_plugins = g_slist_append(codec_plugins, plugin);
- return TRUE;
+ gpointer gp;
+ void (*register_codec_module)(void);
+ codec_plugin *plugin;
+
+ /*
+ * Do we have a register_codec_module routine?
+ */
+ if (!g_module_symbol(handle, "register_codec_module", &gp)) {
+ /* No, so this isn't a codec plugin. */
+ return FALSE;
+ }
+
+ /*
+ * Yes - this plugin includes one or more codecs.
+ */
+ register_codec_module = (void (*)(void))gp;
+
+ /*
+ * Add this one to the list of codec plugins.
+ */
+ plugin = (codec_plugin *)g_malloc(sizeof (codec_plugin));
+ plugin->register_codec_module = register_codec_module;
+ codec_plugins = g_slist_append(codec_plugins, plugin);
+ return TRUE;
}
void
codec_register_plugin_types(void)
{
- add_plugin_type("codec", check_for_codec_plugin);
+ add_plugin_type("codec", check_for_codec_plugin);
}
static void
register_codec_plugin(gpointer data, gpointer user_data _U_)
{
- codec_plugin *plugin = (codec_plugin *)data;
+ codec_plugin *plugin = (codec_plugin *)data;
- (plugin->register_codec_module)();
+ (plugin->register_codec_module)();
}
/*
@@ -94,15 +102,32 @@ register_codec_plugin(gpointer data, gpointer user_data _U_)
void
register_all_codecs(void)
{
- g_slist_foreach(codec_plugins, register_codec_plugin, NULL);
+ register_codec("g711U", codec_g711u_init, codec_g711u_release,
+ codec_g711u_get_channels, codec_g711u_get_frequency, codec_g711u_decode);
+ register_codec("g711A", codec_g711a_init, codec_g711a_release,
+ codec_g711a_get_channels, codec_g711a_get_frequency, codec_g711a_decode);
+#ifdef HAVE_SPANDSP
+ register_codec("g722", codec_g722_init, codec_g722_release,
+ codec_g722_get_channels, codec_g722_get_frequency, codec_g722_decode);
+ register_codec("g726", codec_g726_init, codec_g726_release,
+ codec_g726_get_channels, codec_g726_get_frequency, codec_g726_decode);
+#endif
+#ifdef HAVE_SBC
+ register_codec("SBC", codec_sbc_init, codec_sbc_release,
+ codec_sbc_get_channels, codec_sbc_get_frequency, codec_sbc_decode);
+#endif
+
+ g_slist_foreach(codec_plugins, register_codec_plugin, NULL);
}
#endif /* HAVE_PLUGINS */
struct codec_handle {
- const char *name;
- codec_init_fn init_fn;
- codec_release_fn release_fn;
- codec_decode_fn decode_fn;
+ const char *name;
+ codec_init_fn init_fn;
+ codec_release_fn release_fn;
+ codec_get_channels_fn channels_fn;
+ codec_get_frequency_fn frequency_fn;
+ codec_decode_fn decode_fn;
};
/*
@@ -115,47 +140,76 @@ static GHashTable *registered_codecs = NULL;
codec_handle_t
find_codec(const char *name)
{
- return (registered_codecs) ? (codec_handle_t)g_hash_table_lookup(registered_codecs, name) : NULL;
+ return (registered_codecs) ? (codec_handle_t)g_hash_table_lookup(registered_codecs, name) : NULL;
}
/* Register a codec by name. */
gboolean
-register_codec(const char *name, codec_init_fn init_fn, codec_release_fn release_fn, codec_decode_fn decode_fn)
+register_codec(const char *name, codec_init_fn init_fn, codec_release_fn release_fn,
+ codec_get_channels_fn channels_fn, codec_get_frequency_fn frequency_fn,
+ codec_decode_fn decode_fn)
{
- struct codec_handle *handle;
-
- /* Create our hash table if it doesn't already exist */
- if (registered_codecs == NULL)
- registered_codecs = g_hash_table_new(g_str_hash, g_str_equal);
-
- /* Make sure the registration is unique */
- if (g_hash_table_lookup(registered_codecs, name) != NULL)
- return FALSE; /* report an error, or have our caller do it? */
-
- handle = (struct codec_handle *)g_malloc(sizeof (struct codec_handle));
- handle->name = name;
- handle->init_fn = init_fn;
- handle->release_fn = release_fn;
- handle->decode_fn = decode_fn;
-
- g_hash_table_insert(registered_codecs, (gpointer)name, (gpointer) handle);
- return TRUE;
+ struct codec_handle *handle;
+
+ /* Create our hash table if it doesn't already exist */
+ if (registered_codecs == NULL)
+ registered_codecs = g_hash_table_new(g_str_hash, g_str_equal);
+
+ /* Make sure the registration is unique */
+ if (g_hash_table_lookup(registered_codecs, name) != NULL)
+ return FALSE; /* report an error, or have our caller do it? */
+
+ handle = (struct codec_handle *)g_malloc(sizeof (struct codec_handle));
+ handle->name = name;
+ handle->init_fn = init_fn;
+ handle->release_fn = release_fn;
+ handle->channels_fn = channels_fn;
+ handle->frequency_fn = frequency_fn;
+ handle->decode_fn = decode_fn;
+
+ g_hash_table_insert(registered_codecs, (gpointer)name, (gpointer) handle);
+ return TRUE;
}
void *codec_init(codec_handle_t codec)
{
- if (!codec) return NULL;
- return (codec->init_fn)();
+ if (!codec) return NULL;
+ return (codec->init_fn)();
}
void codec_release(codec_handle_t codec, void *context)
{
- if (!codec) return;
- (codec->release_fn)(context);
+ if (!codec) return;
+ (codec->release_fn)(context);
+}
+
+int codec_get_channels(codec_handle_t codec, void *context)
+{
+ if (!codec) return 0;
+ return (codec->channels_fn)(context);
+}
+
+int codec_get_frequency(codec_handle_t codec, void *context)
+{
+ if (!codec) return 0;
+ return (codec->frequency_fn)(context);
}
int codec_decode(codec_handle_t codec, void *context, const void *input, int inputSizeBytes, void *output, int *outputSizeBytes)
{
- if (!codec) return 0;
- return (codec->decode_fn)(context, input, inputSizeBytes, output, outputSizeBytes);
+ if (!codec) return 0;
+ return (codec->decode_fn)(context, input, inputSizeBytes, output, outputSizeBytes);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/codecs.h b/codecs/codecs.h
index 6093b5559c..29ec7e7faa 100644
--- a/codecs/codecs.h
+++ b/codecs/codecs.h
@@ -44,16 +44,37 @@ typedef struct codec_handle *codec_handle_t;
typedef void *(*codec_init_fn)(void);
typedef void (*codec_release_fn)(void *context);
-typedef int (*codec_decode_fn)(void *context, const void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+typedef int (*codec_get_channels_fn)(void *context);
+typedef int (*codec_get_frequency_fn)(void *context);
+typedef int (*codec_decode_fn)(void *context, const void *input, int inputSizeBytes,
+ void *output, int *outputSizeBytes);
-extern gboolean register_codec(const char *name, codec_init_fn init_fn, codec_release_fn release_fn, codec_decode_fn decode_fn);
+extern gboolean register_codec(const char *name, codec_init_fn init_fn,
+ codec_release_fn release_fn, codec_get_channels_fn channels_fn,
+ codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
extern codec_handle_t find_codec(const char *name);
extern void *codec_init(codec_handle_t codec);
extern void codec_release(codec_handle_t codec, void *context);
-extern int codec_decode(codec_handle_t codec, void *context, const void *input, int inputSizeBytes, void *output, int *outputSizeBytes);
+extern int codec_get_channels(codec_handle_t codec, void *context);
+extern int codec_get_frequency(codec_handle_t codec, void *context);
+extern int codec_decode(codec_handle_t codec, void *context, const void *input,
+ int inputSizeBytes, void *output, int *outputSizeBytes);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _CODECS_H_ */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/sbc/sbc.c b/codecs/sbc/sbc.c
index b14b5bb681..786144f640 100644
--- a/codecs/sbc/sbc.c
+++ b/codecs/sbc/sbc.c
@@ -31,7 +31,7 @@
#include <glib.h>
#include <sbc/sbc.h>
-#include "sbc.h"
+#include "sbc_private.h"
#define SBC_BUFFER 8192
@@ -40,7 +40,7 @@ codec_sbc_init(void)
{
sbc_t *sbc;
- sbc = g_malloc(sizeof(sbc_t));
+ sbc = (sbc_t *) g_malloc(sizeof(sbc_t));
sbc_init(sbc, 0L);
return sbc;
@@ -98,16 +98,16 @@ int
codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
int *outputSizeBytes)
{
- size_t size_in = (size_t) inputSizeBytes;
- size_t size_out = SBC_BUFFER;
- size_t len;
- int framelen;
- int xframe_pos = 0;
- guint8 *data_in = (guint8 *) input;
- guint8 *data_out = (guint8 *) output;
- sbc_t *sbc = (sbc_t *) ctx;
- guint8 *i_data;
- guint8 tmp;
+ size_t size_in = (size_t) inputSizeBytes;
+ size_t size_out = SBC_BUFFER;
+ size_t len;
+ int framelen;
+ int xframe_pos = 0;
+ const guint8 *data_in = (const guint8 *) input;
+ guint8 *data_out = (guint8 *) output;
+ sbc_t *sbc = (sbc_t *) ctx;
+ guint8 *i_data;
+ guint8 tmp;
if (!output || !outputSizeBytes) {
return size_out;
@@ -136,3 +136,16 @@ codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
}
#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/sbc/sbc.h b/codecs/sbc/sbc_private.h
index 5cc8ad0927..71f643532b 100644
--- a/codecs/sbc/sbc.h
+++ b/codecs/sbc/sbc_private.h
@@ -28,10 +28,23 @@
#define __CODECS_SBC_H__
void *codec_sbc_init(void);
-void codec_sbc_release(void *ctx);
-int codec_sbc_get_channels(void *ctx);
-int codec_sbc_get_frequency(void *ctx);
-int codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
+void codec_sbc_release(void *ctx);
+int codec_sbc_get_channels(void *ctx);
+int codec_sbc_get_frequency(void *ctx);
+int codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output,
int *outputSizeBytes);
#endif /* sbc.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */