freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
February 2008
- 12 participants
- 309 discussions
[Freeswitch-svn] [commit] r7457 - freeswitch/trunk/src/mod/codecs/mod_g722
by Freeswitch SVN 01 Feb '08
by Freeswitch SVN 01 Feb '08
01 Feb '08
Author: brian
Date: Fri Feb 1 10:06:22 2008
New Revision: 7457
Modified:
freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
Log:
tweak
Modified: freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c Fri Feb 1 10:06:22 2008
@@ -131,6 +131,12 @@
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
}
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 109, "G722_8", NULL, 8000, 8000, 64000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
1
0
[Freeswitch-svn] [commit] r7456 - freeswitch/trunk/conf/autoload_configs
by Freeswitch SVN 01 Feb '08
by Freeswitch SVN 01 Feb '08
01 Feb '08
Author: brian
Date: Fri Feb 1 09:34:13 2008
New Revision: 7456
Modified:
freeswitch/trunk/conf/autoload_configs/console.conf.xml
Log:
getting closer
Modified: freeswitch/trunk/conf/autoload_configs/console.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/console.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/console.conf.xml Fri Feb 1 09:34:13 2008
@@ -6,7 +6,7 @@
name can be a file name, function name or 'all'
value is one or more of debug,info,notice,warning,err,crit,alert,all
-->
- <map name="all" value="debug,info,notice,warning,err,crit,alert"/>
+ <map name="all" value="info,notice,warning,err,crit,alert"/>
</mappings>
<settings>
<!-- comment or set to false for no color logging -->
1
0
Author: anthm
Date: Fri Feb 1 09:24:35 2008
New Revision: 7455
Modified:
freeswitch/trunk/Makefile.am
Log:
update makefile
Modified: freeswitch/trunk/Makefile.am
==============================================================================
--- freeswitch/trunk/Makefile.am (original)
+++ freeswitch/trunk/Makefile.am Fri Feb 1 09:24:35 2008
@@ -287,6 +287,7 @@
speedy-sure: update-clean
$(MAKE) -j core
+ cd libs/sofia-sip && $(MAKE) -j
$(MAKE) -j modules
current: update-clean
@@ -294,6 +295,11 @@
$(MAKE) all
$(MAKE) install
+speedy-current: update-clean
+ svn update
+ $(MAKE) speedy-sure
+ $(MAKE) install
+
wayclean: clean
modules: libfreeswitch.la
1
0
[Freeswitch-svn] [commit] r7454 - freeswitch/trunk/src/mod/codecs/mod_g726
by Freeswitch SVN 01 Feb '08
by Freeswitch SVN 01 Feb '08
01 Feb '08
Author: brian
Date: Fri Feb 1 01:36:42 2008
New Revision: 7454
Modified:
freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c
Log:
wth was I thinking here hehe
Modified: freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c Fri Feb 1 01:36:42 2008
@@ -51,23 +51,7 @@
packing = G726_PACKING_LEFT;
}
- switch (codec->implementation->bits_per_second) {
- case 40000:
- g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
- break;
- case 32000:
- g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
- break;
- case 24000:
- g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
- break;
- case 16000:
- g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
- break;
- default:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
- return SWITCH_STATUS_FALSE;
- }
+ g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
1
0
01 Feb '08
Author: brian
Date: Fri Feb 1 01:25:48 2008
New Revision: 7453
Removed:
freeswitch/trunk/libs/codec/g726/
Log:
remove old g726 we no longer use
1
0
01 Feb '08
Author: brian
Date: Fri Feb 1 01:22:13 2008
New Revision: 7452
Modified:
freeswitch/trunk/src/include/switch_loadable_module.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c
freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c
freeswitch/trunk/src/mod/codecs/mod_g726/Makefile
freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c
freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c
freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c
freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c
freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
freeswitch/trunk/src/mod/codecs/mod_lpc10/mod_lpc10.c
freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
Log:
Massive codec update. I have also switched G726 to use Steve Underwoods code as it passes all the tests. G726 tested in AAL2 mode with Sipura and G726-32 tested with Snom which does proper bitpacking. Be sure to "make current" before you continue.
/b
Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h (original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h Fri Feb 1 01:22:13 2008
@@ -42,6 +42,7 @@
#define SWITCH_LOADABLE_MODULE_H
#include <switch.h>
+#include <switch_module_interfaces.h>
SWITCH_BEGIN_EXTERN_C
/*!
@@ -305,14 +306,79 @@
break; \
}
-#define SWITCH_ADD_CODEC(codec_int, int_name, implementation) \
+#define SWITCH_ADD_CODEC(codec_int, int_name) \
for (;;) { \
codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
- codec_int->implementations = implementation; \
codec_int->interface_name = int_name; \
break; \
}
+
+static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool,
+ switch_codec_interface_t *codec_interface,
+ /*! enumeration defining the type of the codec */
+ const switch_codec_type_t codec_type,
+ /*! the IANA code number */
+ switch_payload_t ianacode,
+ /*! the IANA code name */
+ char *iananame,
+ /*! default fmtp to send (can be overridden by the init function) */
+ char *fmtp,
+ /*! samples transferred per second */
+ uint32_t samples_per_second,
+ /*! actual samples transferred per second for those who are not moron g722 RFC writers*/
+ uint32_t actual_samples_per_second,
+ /*! bits transferred per second */
+ int bits_per_second,
+ /*! number of microseconds that denote one frame */
+ int microseconds_per_frame,
+ /*! number of samples that denote one frame */
+ uint32_t samples_per_frame,
+ /*! number of bytes that denote one frame decompressed */
+ uint32_t bytes_per_frame,
+ /*! number of bytes that denote one frame compressed */
+ uint32_t encoded_bytes_per_frame,
+ /*! number of channels represented */
+ uint8_t number_of_channels,
+ /*! number of frames to send in one netowrk packet */
+ int pref_frames_per_packet,
+ /*! max number of frames to send in one network packet */
+ int max_frames_per_packet,
+ /*! function to initialize a codec handle using this implementation */
+ switch_core_codec_init_func_t init,
+ /*! function to encode raw data into encoded data */
+ switch_core_codec_encode_func_t encode,
+ /*! function to decode encoded data into raw data */
+ switch_core_codec_decode_func_t decode,
+ /*! deinitalize a codec handle using this implementation */
+ switch_core_codec_destroy_func_t destroy)
+{
+
+ switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
+ impl->codec_type = codec_type;
+ impl->ianacode = ianacode;
+ impl->iananame = iananame;
+ impl->fmtp = fmtp;
+ impl->samples_per_second = samples_per_second;
+ impl->actual_samples_per_second = actual_samples_per_second;
+ impl->bits_per_second = bits_per_second;
+ impl->microseconds_per_frame = microseconds_per_frame;
+ impl->samples_per_frame = samples_per_frame;
+ impl->bytes_per_frame = bytes_per_frame;
+ impl->encoded_bytes_per_frame = encoded_bytes_per_frame;
+ impl->number_of_channels = number_of_channels;
+ impl->pref_frames_per_packet = pref_frames_per_packet;
+ impl->max_frames_per_packet = max_frames_per_packet;
+ impl->init = init;
+ impl->encode = encode;
+ impl->decode = decode;
+ impl->destroy = destroy;
+
+ impl->next = codec_interface->implementations;
+ codec_interface->implementations = impl;
+
+}
+
///\}
#define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut) void init(void) { \
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Fri Feb 1 01:22:13 2008
@@ -514,7 +514,7 @@
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
struct switch_codec_implementation {
/*! enumeration defining the type of the codec */
- const switch_codec_type_t codec_type;
+ switch_codec_type_t codec_type;
/*! the IANA code number */
switch_payload_t ianacode;
/*! the IANA code name */
@@ -542,21 +542,13 @@
/*! max number of frames to send in one network packet */
int max_frames_per_packet;
/*! function to initialize a codec handle using this implementation */
- switch_status_t (*init) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
+ switch_core_codec_init_func_t init;
/*! function to encode raw data into encoded data */
- switch_status_t (*encode) (switch_codec_t *codec,
- switch_codec_t *other_codec,
- void *decoded_data,
- uint32_t decoded_data_len,
- uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag);
+ switch_core_codec_encode_func_t encode;
/*! function to decode encoded data into raw data */
- switch_status_t (*decode) (switch_codec_t *codec,
- switch_codec_t *other_codec,
- void *encoded_data,
- uint32_t encoded_data_len,
- uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag);
+ switch_core_codec_decode_func_t decode;
/*! deinitalize a codec handle using this implementation */
- switch_status_t (*destroy) (switch_codec_t *);
+ switch_core_codec_destroy_func_t destroy;
struct switch_codec_implementation *next;
};
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Fri Feb 1 01:22:13 2008
@@ -1123,6 +1123,34 @@
typedef struct switch_media_bug switch_media_bug_t;
typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
+
+typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *codec,
+ switch_codec_t *other_codec,
+ void *decoded_data,
+ uint32_t decoded_data_len,
+ uint32_t decoded_rate,
+ void *encoded_data,
+ uint32_t * encoded_data_len,
+ uint32_t * encoded_rate,
+ unsigned int *flag);
+
+
+typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *codec,
+ switch_codec_t *other_codec,
+ void *encoded_data,
+ uint32_t encoded_data_len,
+ uint32_t encoded_rate,
+ void *decoded_data,
+ uint32_t * decoded_data_len,
+ uint32_t * decoded_rate,
+ unsigned int *flag);
+
+typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
+typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
+
+
+
+
typedef void (*switch_application_function_t) (switch_core_session_t *, const char *);
#define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data)
Modified: freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c Fri Feb 1 01:22:13 2008
@@ -31,6 +31,7 @@
* mod_amr.c -- GSM-AMR Codec Module
*
*/
+
#include "switch.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load);
@@ -284,28 +285,6 @@
}
/* Registration */
-
-static switch_codec_implementation_t amr_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 96,
- /*.iananame */ "AMR",
- /*.fmtp */ "octet-align=0",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 0,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_amr_init,
- /*.encode */ switch_amr_encode,
- /*.decode */ switch_amr_decode,
- /*.destroy */ switch_amr_destroy,
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
{
switch_codec_interface_t *codec_interface;
@@ -331,8 +310,12 @@
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "GSM-AMR", &amr_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "GSM-AMR");
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200,
+ 20000, 160, 320, 0, 1, 1, 1,
+ switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c Fri Feb 1 01:22:13 2008
@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct(a)yahoo.com>
*
*
- * mod_g711.c -- G711 Ulaw/Alaw Codec Module
+ * mod_g711.c -- G.711 Ulaw/Alaw Codec Module
*
*/
+
#include <switch.h>
#include <g7xx/g711.h>
@@ -176,233 +177,28 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-
-static switch_codec_implementation_t g711u_8k_120ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 0,
- /*.iananame */ "PCMU",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 120000,
- /*.samples_per_frame */ 960,
- /*.bytes_per_frame */ 1920,
- /*.encoded_bytes_per_frame */ 960,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711u_init,
- /*.encode */ switch_g711u_encode,
- /*.decode */ switch_g711u_decode,
- /*.destroy */ switch_g711u_destroy
-};
-
-static switch_codec_implementation_t g711u_8k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 0,
- /*.iananame */ "PCMU",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 60000,
- /*.samples_per_frame */ 480,
- /*.bytes_per_frame */ 960,
- /*.encoded_bytes_per_frame */ 480,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711u_init,
- /*.encode */ switch_g711u_encode,
- /*.decode */ switch_g711u_decode,
- /*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_8k_120ms_implementation
-};
-
-static switch_codec_implementation_t g711u_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 0,
- /*.iananame */ "PCMU",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 240,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711u_init,
- /*.encode */ switch_g711u_encode,
- /*.decode */ switch_g711u_decode,
- /*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_8k_60ms_implementation
-};
-
-static switch_codec_implementation_t g711u_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 0,
- /*.iananame */ "PCMU",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 160,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711u_init,
- /*.encode */ switch_g711u_encode,
- /*.decode */ switch_g711u_decode,
- /*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_8k_30ms_implementation
-};
-
-static switch_codec_implementation_t g711u_8k_10ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 0,
- /*.iananame */ "PCMU",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 10000,
- /*.samples_per_frame */ 80,
- /*.bytes_per_frame */ 160,
- /*.encoded_bytes_per_frame */ 80,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711u_init,
- /*.encode */ switch_g711u_encode,
- /*.decode */ switch_g711u_decode,
- /*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_8k_20ms_implementation
-};
-
-static switch_codec_implementation_t g711a_8k_120ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 8,
- /*.iananame */ "PCMA",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 120000,
- /*.samples_per_frame */ 960,
- /*.bytes_per_frame */ 1920,
- /*.encoded_bytes_per_frame */ 960,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711a_init,
- /*.encode */ switch_g711a_encode,
- /*.decode */ switch_g711a_decode,
- /*.destroy */ switch_g711a_destroy
-};
-
-static switch_codec_implementation_t g711a_8k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 8,
- /*.iananame */ "PCMA",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 60000,
- /*.samples_per_frame */ 480,
- /*.bytes_per_frame */ 960,
- /*.encoded_bytes_per_frame */ 480,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711a_init,
- /*.encode */ switch_g711a_encode,
- /*.decode */ switch_g711a_decode,
- /*.destroy */ switch_g711a_destroy,
- /*.next */ &g711a_8k_120ms_implementation
-};
-
-static switch_codec_implementation_t g711a_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 8,
- /*.iananame */ "PCMA",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 240,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711a_init,
- /*.encode */ switch_g711a_encode,
- /*.decode */ switch_g711a_decode,
- /*.destroy */ switch_g711a_destroy,
- /*.next */ &g711a_8k_60ms_implementation
-};
-
-static switch_codec_implementation_t g711a_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 8,
- /*.iananame */ "PCMA",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 160,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711a_init,
- /*.encode */ switch_g711a_encode,
- /*.decode */ switch_g711a_decode,
- /*.destroy */ switch_g711a_destroy,
- /*.next */ &g711a_8k_30ms_implementation
-};
-
-static switch_codec_implementation_t g711a_8k_10ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 8,
- /*.iananame */ "PCMA",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 10000,
- /*.samples_per_frame */ 80,
- /*.bytes_per_frame */ 160,
- /*.encoded_bytes_per_frame */ 80,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g711a_init,
- /*.encode */ switch_g711a_encode,
- /*.decode */ switch_g711a_decode,
- /*.destroy */ switch_g711a_destroy,
- /*.next */ &g711a_8k_20ms_implementation
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_g711_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "g711 ulaw", &g711u_8k_10ms_implementation);
- SWITCH_ADD_CODEC(codec_interface, "g711 alaw", &g711a_8k_10ms_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
+ }
+
+ SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c Fri Feb 1 01:22:13 2008
@@ -27,9 +27,10 @@
* Anthony Minessale II <anthmct(a)yahoo.com>
* Michael Jerris <mike(a)jerris.com>
*
- * mod_g722.c -- G722 Codec Module
+ * mod_g722.c -- G.722 Codec Module
*
*/
+
#include <switch.h>
#include "g7xx/g722.h"
@@ -115,58 +116,21 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-
-static switch_codec_implementation_t g722_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 109,
- /*.iananame */ "G722_8",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 160,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g722_init,
- /*.encode */ switch_g722_encode,
- /*.decode */ switch_g722_decode,
- /*.destroy */ switch_g722_destroy
-};
-
-static switch_codec_implementation_t g722_16k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 9,
- /*.iananame */ "G722",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 16000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 160,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g722_init,
- /*.encode */ switch_g722_encode,
- /*.decode */ switch_g722_decode,
- /*.destroy */ switch_g722_destroy,
- /*.next */
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 320, ebpf = 80, count;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "G722", &g722_16k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G722_8", &g722_8k_implementation);
+
+ SWITCH_ADD_CODEC(codec_interface, "G.722");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 9, "G722", NULL, 8000, 16000, 64000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c Fri Feb 1 01:22:13 2008
@@ -31,6 +31,7 @@
* mod_g723_1.c -- G723.1 Codec Module
*
*/
+
#include "switch.h"
#ifndef G723_PASSTHROUGH
@@ -166,36 +167,19 @@
#endif
}
-/* Registration */
-
-static switch_codec_implementation_t g723_1_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 4,
- /*.iananame */ "G723",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 6300,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 24,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 4,
- /*.init */ switch_g723_init,
- /*.encode */ switch_g723_encode,
- /*.decode */ switch_g723_decode,
- /*.destroy */ switch_g723_destroy,
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 30000, spf = 240, bpf = 480, ebpf = 24, count;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "g723.1 6.3k", &g723_1_implementation);
-
+ SWITCH_ADD_CODEC(codec_interface, "G.723.1 6.3k");
+ for (count = 1; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 4,
+ switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/codecs/mod_g726/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g726/Makefile (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g726/Makefile Fri Feb 1 01:22:13 2008
@@ -1,10 +1,10 @@
BASE=../../../..
-G726_DIR=$(BASE)/libs/codec/g726
-G726LA=$(G726_DIR)/libg726.la
-LOCAL_CFLAGS=-I$(G726_DIR)/src
-LOCAL_LIBADD=$(G726LA)
+G7XX_DIR=$(BASE)/libs/codec/g7xx
+G7XXLA=$(G7XX_DIR)/libg7xx.la
+LOCAL_CFLAGS=-I$(G7XX_DIR)/src/include/
+LOCAL_LIBADD=$(G7XXLA)
include $(BASE)/build/modmake.rules
-$(G726LA): $(G726_DIR) $(G726_DIR)/.update
- cd $(G726_DIR) && $(MAKE)
+$(G7XXLA): $(G7XX_DIR) $(G7XX_DIR)/.update
+ cd $(G7XX_DIR) && $(MAKE)
$(TOUCH_TARGET)
Modified: freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c Fri Feb 1 01:22:13 2008
@@ -30,72 +30,46 @@
*
*/
#include "switch.h"
-#include "g72x.h"
-#include "switch_bitpack.h"
+#include "g7xx/g726.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_g726_load);
SWITCH_MODULE_DEFINITION(mod_g726, mod_g726_load, NULL, NULL);
-typedef int (*encoder_t) (int, int, g726_state *);
-typedef int (*decoder_t) (int, int, g726_state *);
-
-typedef struct {
- g726_state context;
- switch_byte_t bits_per_frame;
- encoder_t encoder;
- decoder_t decoder;
- switch_bitpack_t pack;
- switch_bitpack_t unpack;
- switch_bitpack_mode_t mode;
- switch_byte_t loops;
- switch_byte_t bytes;
- switch_byte_t buf[160];
-} g726_handle_t;
-
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
{
uint32_t encoding, decoding;
- g726_handle_t *handle;
+ int packing = G726_PACKING_RIGHT;
+ g726_state_t *context;
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
- if (!(encoding || decoding) || (!(handle = switch_core_alloc(codec->memory_pool, sizeof(*handle))))) {
+ if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
} else {
- handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
-
- switch (handle->bytes) {
- case 100:
- handle->encoder = g726_40_encoder;
- handle->decoder = g726_40_decoder;
- handle->loops = 160;
+ if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
+ packing = G726_PACKING_LEFT;
+ }
+
+ switch (codec->implementation->bits_per_second) {
+ case 40000:
+ g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
break;
- case 80:
- handle->encoder = g726_32_encoder;
- handle->decoder = g726_32_decoder;
- handle->loops = 40;
+ case 32000:
+ g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
break;
- case 60:
- handle->encoder = g726_24_encoder;
- handle->decoder = g726_24_decoder;
- handle->loops = 160;
+ case 24000:
+ g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
break;
- case 40:
- handle->encoder = g726_16_encoder;
- handle->decoder = g726_16_decoder;
- handle->loops = 160;
+ case 16000:
+ g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
return SWITCH_STATUS_FALSE;
}
- g726_init_state(&handle->context);
- codec->private_info = handle;
- handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->actual_samples_per_second));
- handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
- ? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
+ codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
}
@@ -113,38 +87,13 @@
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate,
unsigned int *flag)
{
- g726_handle_t *handle = codec->private_info;
- g726_state *context = &handle->context;
- uint32_t len = codec->implementation->bytes_per_frame;
+ g726_state_t *context = codec->private_info;
if (!context) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error!\n");
return SWITCH_STATUS_FALSE;
}
- if (decoded_data_len % len == 0) {
- uint32_t new_len = 0;
- int16_t *ddp = decoded_data;
- switch_byte_t *edp = encoded_data;
- uint32_t x, loops = decoded_data_len / (sizeof(*ddp));
-
- switch_bitpack_init(&handle->pack, handle->bits_per_frame, edp, *encoded_data_len, handle->mode);
-
- for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
- int edata = handle->encoder(*ddp, AUDIO_ENCODING_LINEAR, context);
- switch_bitpack_in(&handle->pack, (switch_byte_t) edata);
- ddp++;
- }
- switch_bitpack_done(&handle->pack);
- new_len = handle->pack.bytes;
-
- if (new_len <= *encoded_data_len) {
- *encoded_data_len = new_len;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
- return SWITCH_STATUS_FALSE;
- }
- }
+ *encoded_data_len = g726_encode(context, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
return SWITCH_STATUS_SUCCESS;
}
@@ -156,222 +105,90 @@
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
unsigned int *flag)
{
- g726_handle_t *handle = codec->private_info;
- g726_state *context = &handle->context;
- int16_t *ddp = decoded_data;
- uint32_t new_len = 0, z = 0, y;
-
- switch_byte_t *in = (switch_byte_t *) encoded_data;
+ g726_state_t *context = codec->private_info;
- if (!handle || !context) {
+ if (!context) {
return SWITCH_STATUS_FALSE;
}
- while (z < encoded_data_len && new_len <= *decoded_data_len) {
- switch_bitpack_init(&handle->unpack, handle->bits_per_frame, handle->buf, sizeof(handle->buf), handle->mode);
- for (y = 0; y < handle->loops; y++) {
- switch_bitpack_out(&handle->unpack, in[z++]);
- }
- for (y = 0; y < handle->bytes; y++) {
- *ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
- new_len += 2;
- }
- switch_bitpack_done(&handle->unpack);
- }
-
- if (new_len <= *decoded_data_len) {
- *decoded_data_len = new_len;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!!\n");
- return SWITCH_STATUS_FALSE;
- }
+ *decoded_data_len = (2 * g726_decode(context, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-
-static switch_codec_implementation_t g726_16k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 127,
- /*.iananame */ "G726-16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 16000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 40,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t g726_24k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 126,
- /*.iananame */ "G726-24",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 60,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t g726_32k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 2,
- /*.iananame */ "G726-32",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 32000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 80,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t g726_40k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 125,
- /*.iananame */ "G726-40",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 40000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 100,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t aal2_g726_16k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 124,
- /*.iananame */ "AAL2-G726-16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 16000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 40,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t aal2_g726_24k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 123,
- /*.iananame */ "AAL2-G726-24",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 60,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t aal2_g726_32k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 2,
- /*.iananame */ "AAL2-G726-32",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 32000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 80,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
-static switch_codec_implementation_t aal2_g726_40k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 122,
- /*.iananame */ "AAL2-G726-40",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 40000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 100,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g726_init,
- /*.encode */ switch_g726_encode,
- /*.decode */ switch_g726_decode,
- /*.destroy */ switch_g726_destroy,
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_g726_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 160, ebpf = 20, count;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "G.726 40k (aal2)", &aal2_g726_40k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 32k (aal2)", &aal2_g726_32k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 24k (aal2)", &aal2_g726_24k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 16k (aal2)", &aal2_g726_16k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 40k", &g726_40k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 32k", &g726_32k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 24k", &g726_24k_implementation);
- SWITCH_ADD_CODEC(codec_interface, "G.726 16k", &g726_16k_implementation);
+
+ SWITCH_ADD_CODEC(codec_interface, "G.726 16k (AAL2)");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 124, "AAL2-G726-16", NULL, 8000, 8000, 16000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 127, "G726-16", NULL, 8000, 8000, 16000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ /* Increase encoded bytes per frame by 10 */
+ ebpf = ebpf + 10;
+
+ SWITCH_ADD_CODEC(codec_interface, "G.726 24k (AAL2)");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 123, "AAL2-G726-24", NULL, 8000, 8000, 24000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 126, "G726-24", NULL, 8000, 8000, 24000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ /* Increase encoded bytes per frame by 10 */
+ ebpf = ebpf + 10;
+
+ SWITCH_ADD_CODEC(codec_interface, "G.726 32k (AAL2)");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 2, "AAL2-G726-32", NULL, 8000, 8000, 32000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 2, "G726-32", NULL, 8000, 8000, 32000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ /* Increase encoded bytes per frame by 10 */
+ ebpf = ebpf + 10;
+
+ SWITCH_ADD_CODEC(codec_interface, "G.726 40k (AAL2)");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 122, "AAL2-G726-40", NULL, 8000, 8000, 40000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
+ SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 125, "G726-40", NULL, 8000, 8000, 40000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c Fri Feb 1 01:22:13 2008
@@ -28,9 +28,10 @@
*
* The g729 codec itself is not distributed with this module.
*
- * mod_g729.c -- G729 Codec Module
+ * mod_g729.c -- G.729 Codec Module
*
*/
+
#include "switch.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load);
@@ -205,102 +206,21 @@
#endif
}
-/* Registration */
-
-static switch_codec_implementation_t g729_40ms_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 18,
- /*.iananame */ "G729",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 128000,
- /*.microseconds_per_frame */ 40000,
- /*.samples_per_frame */ 320,
- /*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 40,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g729_init,
- /*.encode */ switch_g729_encode,
- /*.decode */ switch_g729_decode,
- /*.destroy */ switch_g729_destroy,
-};
-
-static switch_codec_implementation_t g729_30ms_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 18,
- /*.iananame */ "G729",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 96000,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 30,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g729_init,
- /*.encode */ switch_g729_encode,
- /*.decode */ switch_g729_decode,
- /*.destroy */ switch_g729_destroy,
- /*.next */ &g729_40ms_8k_implementation
-};
-
-static switch_codec_implementation_t g729_10ms_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 18,
- /*.iananame */ "G729",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 32000,
- /*.microseconds_per_frame */ 10000,
- /*.samples_per_frame */ 80,
- /*.bytes_per_frame */ 160,
- /*.encoded_bytes_per_frame */ 10,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g729_init,
- /*.encode */ switch_g729_encode,
- /*.decode */ switch_g729_decode,
- /*.destroy */ switch_g729_destroy,
- /*.next */ &g729_30ms_8k_implementation
-};
-
-static switch_codec_implementation_t g729_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 18,
- /*.iananame */ "G729",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 64000,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 20,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_g729_init,
- /*.encode */ switch_g729_encode,
- /*.decode */ switch_g729_decode,
- /*.destroy */ switch_g729_destroy,
- /*.next */ &g729_10ms_8k_implementation
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 160, ebpf = 10, count;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "g729", &g729_8k_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "G.729");
+ for (count = 12; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 18, "G729", NULL, 8000, 8000, 8000,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+ switch_g729_init, switch_g729_encode, switch_g729_decode, switch_g729_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c Fri Feb 1 01:22:13 2008
@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct(a)yahoo.com>
* Michael Jerris <mike(a)jerris.com>
*
- * mod_gsm.c -- gsm Codec Module
+ * mod_gsm.c -- GSM-FR Codec Module
*
*/
+
#include "switch.h"
#include "gsm.h"
@@ -136,34 +137,20 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-static switch_codec_implementation_t gsm_8k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 3,
- /*.iananame */ "GSM",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 13200,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 33,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_gsm_init,
- /*.encode */ switch_gsm_encode,
- /*.decode */ switch_gsm_decode,
- /*.destroy */ switch_gsm_destroy,
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_gsm_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 20000, spf = 160, bpf = 320, ebpf = 33, count;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "gsm", &gsm_8k_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "GSM-FR");
+ for (count = 6; count > 0; count--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 3, "GSM", NULL, 8000, 8000, 13200,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 6,
+ switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c Fri Feb 1 01:22:13 2008
@@ -29,6 +29,7 @@
* mod_h26x.c -- H26X Signed Linear Codec
*
*/
+
#include <switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load);
@@ -68,85 +69,29 @@
return SWITCH_STATUS_FALSE;
}
-
static switch_status_t switch_h26x_destroy(switch_codec_t *codec)
{
return SWITCH_STATUS_SUCCESS;
}
-static switch_codec_implementation_t h264_90000_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
- /*.ianacode */ 99,
- /*.iananame */ "H264",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 90000,
- /*.actual_samples_per_second = */ 90000,
- /*.bits_per_second = */ 0,
- /*.microseconds_per_frame = */ 0,
- /*.samples_per_frame = */ 0,
- /*.bytes_per_frame = */ 0,
- /*.encoded_bytes_per_frame = */ 0,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_h26x_init,
- /*.encode = */ switch_h26x_encode,
- /*.decode = */ switch_h26x_decode,
- /*.destroy = */ switch_h26x_destroy
- /*.next = */
-};
-
-static switch_codec_implementation_t h263_90000_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
- /*.ianacode */ 34,
- /*.iananame */ "H263",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 90000,
- /*.actual_samples_per_second = */ 90000,
- /*.bits_per_second = */ 0,
- /*.microseconds_per_frame = */ 0,
- /*.samples_per_frame = */ 0,
- /*.bytes_per_frame = */ 0,
- /*.encoded_bytes_per_frame = */ 0,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_h26x_init,
- /*.encode = */ switch_h26x_encode,
- /*.decode = */ switch_h26x_decode,
- /*.destroy = */ switch_h26x_destroy,
- /*.next = */&h264_90000_implementation
-};
-
-static switch_codec_implementation_t h261_90000_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
- /*.ianacode */ 31,
- /*.iananame */ "H261",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 90000,
- /*.actual_samples_per_second = */ 90000,
- /*.bits_per_second = */ 0,
- /*.microseconds_per_frame = */ 0,
- /*.samples_per_frame = */ 0,
- /*.bytes_per_frame = */ 0,
- /*.encoded_bytes_per_frame = */ 0,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_h26x_init,
- /*.encode = */ switch_h26x_encode,
- /*.decode = */ switch_h26x_decode,
- /*.destroy = */ switch_h26x_destroy,
- /*.next = */&h263_90000_implementation
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load)
{
switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "h26x video (passthru)", &h261_90000_implementation);
-
+ SWITCH_ADD_CODEC(codec_interface, "H.26x Video (passthru)");
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0,
+ 0, 0, 0, 0, 1, 1, 1,
+ switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_VIDEO, 34, "H263", NULL, 90000, 90000, 0,
+ 0, 0, 0, 0, 1, 1, 1,
+ switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_VIDEO, 31, "H261", NULL, 90000, 90000, 0,
+ 0, 0, 0, 0, 1, 1, 1,
+ switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c Fri Feb 1 01:22:13 2008
@@ -29,6 +29,7 @@
* mod_ilbc.c -- ilbc Codec Module
*
*/
+
#include "switch.h"
#include "iLBC_encode.h"
#include "iLBC_decode.h"
@@ -176,123 +177,41 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-
-static switch_codec_implementation_t ilbc_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 97,
- /*.iananame */ "iLBC",
- /*.fmtp */ "mode=30",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_ilbc_init,
- /*.encode */ switch_ilbc_encode,
- /*.decode */ switch_ilbc_decode,
- /*.destroy */ switch_ilbc_destroy
-};
-
-static switch_codec_implementation_t ilbc_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 97,
- /*.iananame */ "iLBC",
- /*.fmtp */ "mode=20",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_ilbc_init,
- /*.encode */ switch_ilbc_encode,
- /*.decode */ switch_ilbc_decode,
- /*.destroy */ switch_ilbc_destroy,
- /*.next */ &ilbc_8k_30ms_implementation
-};
-
-static switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 102,
- /*.iananame */ "iLBC",
- /*.fmtp */ "mode=30",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_ilbc_init,
- /*.encode */ switch_ilbc_encode,
- /*.decode */ switch_ilbc_decode,
- /*.destroy */ switch_ilbc_destroy
-};
-
-static switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 102,
- /*.iananame */ "iLBC102",
- /*.fmtp */ "mode=20",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_ilbc_init,
- /*.encode */ switch_ilbc_encode,
- /*.decode */ switch_ilbc_decode,
- /*.destroy */ switch_ilbc_destroy,
- /*.next */ &ilbc_102_8k_30ms_implementation
-};
-
-static switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 97,
- /*.iananame */ "iLBC20ms",
- /*.fmtp */ "mode=20",
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
- /*.microseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_ilbc_init,
- /*.encode */ switch_ilbc_encode,
- /*.decode */ switch_ilbc_decode,
- /*.destroy */ switch_ilbc_destroy
-};
SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
{
switch_codec_interface_t *codec_interface;
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_8k_20ms_implementation);
- SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_102_8k_20ms_implementation);
- SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_8k_20ms_nonext_implementation);
+
+ SWITCH_ADD_CODEC(codec_interface, "iLBC");
+
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 97, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+ 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+ 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC102", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+ 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC20ms", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+ 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+ /* 30ms variants */
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 98, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+ 30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+ 30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
+ switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c Fri Feb 1 01:22:13 2008
@@ -29,6 +29,7 @@
* mod_l16.c -- Raw Signed Linear Codec
*
*/
+
#include <switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_l16_load);
@@ -86,345 +87,35 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_codec_implementation_t raw_32k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 119,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 32000,
- /*.actual_samples_per_second = */ 32000,
- /*.bits_per_second = */ 512000,
- /*.microseconds_per_frame = */ 60000,
- /*.samples_per_frame = */ 1920,
- /*.bytes_per_frame = */ 3840,
- /*.encoded_bytes_per_frame = */ 3840,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy
- /*.next = */
-};
-
-static switch_codec_implementation_t raw_32k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 119,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 32000,
- /*.actual_samples_per_second = */ 32000,
- /*.bits_per_second = */ 512000,
- /*.microseconds_per_frame = */ 30000,
- /*.samples_per_frame = */ 960,
- /*.bytes_per_frame = */ 1920,
- /*.encoded_bytes_per_frame = */ 1920,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_32k_60ms_implementation
-};
-
-static switch_codec_implementation_t raw_32k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 119,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 32000,
- /*.actual_samples_per_second = */ 32000,
- /*.bits_per_second = */ 512000,
- /*.microseconds_per_frame = */ 20000,
- /*.samples_per_frame = */ 640,
- /*.bytes_per_frame = */ 1280,
- /*.encoded_bytes_per_frame = */ 1280,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_32k_30ms_implementation
-};
-
-static switch_codec_implementation_t raw_32k_10ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 119,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 32000,
- /*.actual_samples_per_second = */ 32000,
- /*.bits_per_second = */ 512000,
- /*.microseconds_per_frame = */ 10000,
- /*.samples_per_frame = */ 320,
- /*.bytes_per_frame = */ 640,
- /*.encoded_bytes_per_frame = */ 640,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_32k_20ms_implementation
-};
-
-static switch_codec_implementation_t raw_22k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 118,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 22050,
- /*.actual_samples_per_second = */ 22050,
- /*.bits_per_second = */ 352800,
- /*.microseconds_per_frame = */ 20000,
- /*.samples_per_frame = */ 441,
- /*.bytes_per_frame = */ 882,
- /*.encoded_bytes_per_frame = */ 882,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_32k_10ms_implementation
-};
-
-static switch_codec_implementation_t raw_16k_120ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 117,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 16000,
- /*.actual_samples_per_second */ 16000,
- /*.bits_per_second */ 256000,
- /*.microseconds_per_frame */ 120000,
- /*.samples_per_frame */ 1920,
- /*.bytes_per_frame */ 3840,
- /*.encoded_bytes_per_frame */ 3840,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_22k_20ms_implementation
-};
-
-static switch_codec_implementation_t raw_16k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 117,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 16000,
- /*.actual_samples_per_second */ 16000,
- /*.bits_per_second */ 256000,
- /*.microseconds_per_frame */ 60000,
- /*.samples_per_frame */ 960,
- /*.bytes_per_frame */ 1920,
- /*.encoded_bytes_per_frame */ 1920,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_16k_120ms_implementation
-};
-
-static switch_codec_implementation_t raw_16k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 117,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 16000,
- /*.actual_samples_per_second */ 16000,
- /*.bits_per_second */ 256000,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 480,
- /*.bytes_per_frame */ 960,
- /*.encoded_bytes_per_frame */ 960,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_16k_60ms_implementation
-};
-
-static switch_codec_implementation_t raw_16k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 117,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 16000,
- /*.actual_samples_per_second = */ 16000,
- /*.bits_per_second = */ 256000,
- /*.microseconds_per_frame = */ 20000,
- /*.samples_per_frame = */ 320,
- /*.bytes_per_frame = */ 640,
- /*.encoded_bytes_per_frame = */ 640,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_16k_30ms_implementation
-};
-
-static switch_codec_implementation_t raw_16k_10ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 117,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 16000,
- /*.actual_samples_per_second = */ 16000,
- /*.bits_per_second = */ 256000,
- /*.microseconds_per_frame = */ 10000,
- /*.samples_per_frame = */ 160,
- /*.bytes_per_frame = */ 320,
- /*.encoded_bytes_per_frame = */ 320,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next = */ &raw_16k_20ms_implementation
-};
-
-///////////////////////////////
-
-static switch_codec_implementation_t raw_8k_120ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 512000,
- /*.microseconds_per_frame */ 120000,
- /*.samples_per_frame */ 960,
- /*.bytes_per_frame */ 1920,
- /*.encoded_bytes_per_frame */ 1920,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_16k_10ms_implementation
-};
-
-static switch_codec_implementation_t raw_8k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 256000,
- /*.microseconds_per_frame */ 60000,
- /*.samples_per_frame */ 480,
- /*.bytes_per_frame */ 960,
- /*.encoded_bytes_per_frame */ 960,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_8k_120ms_implementation
-};
-
-static switch_codec_implementation_t raw_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 128000,
- /*.microseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 480,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_raw_init,
- /*.encode */ switch_raw_encode,
- /*.decode */ switch_raw_decode,
- /*.destroy */ switch_raw_destroy,
- /*.next */ &raw_8k_60ms_implementation
-};
-
-static switch_codec_implementation_t raw_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 8000,
- /*.actual_samples_per_second = */ 8000,
- /*.bits_per_second = */ 128000,
- /*.microseconds_per_frame = */ 20000,
- /*.samples_per_frame = */ 160,
- /*.bytes_per_frame = */ 320,
- /*.encoded_bytes_per_frame = */ 320,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next */ &raw_8k_30ms_implementation
-};
-
-static switch_codec_implementation_t raw_8k_10ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 10,
- /*.iananame */ "L16",
- /*.fmtp */ NULL,
- /*.samples_per_second = */ 8000,
- /*.actual_samples_per_second = */ 8000,
- /*.bits_per_second = */ 128000,
- /*.microseconds_per_frame = */ 10000,
- /*.samples_per_frame = */ 80,
- /*.bytes_per_frame = */ 160,
- /*.encoded_bytes_per_frame = */ 160,
- /*.number_of_channels = */ 1,
- /*.pref_frames_per_packet = */ 1,
- /*.max_frames_per_packet = */ 1,
- /*.init = */ switch_raw_init,
- /*.encode = */ switch_raw_encode,
- /*.decode = */ switch_raw_decode,
- /*.destroy = */ switch_raw_destroy,
- /*.next */ &raw_8k_20ms_implementation
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_l16_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 160, ebpf = 160, bps = 128000, rate = 8000, counta, countb;
+ int ianacode[4] = { 0, 10, 117, 119 };
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "raw signed linear (16 bit)", &raw_8k_10ms_implementation);
-
+ SWITCH_ADD_CODEC(codec_interface, "RAW Signed Linear (16 bit)");
+ for (counta = 1; counta <= 3; counta++) {
+ for (countb = 12; countb > 0; countb--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "L16", NULL, rate, rate, bps,
+ mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 12,
+ switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+ }
+ rate = rate * 2;
+ bps = bps * 2;
+ spf = spf * 2;
+ bpf = bpf * 2;
+ ebpf = ebpf * 2;
+ }
+
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
+ 20000, 441, 882, 882, 1, 1, 1,
+ switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/codecs/mod_lpc10/mod_lpc10.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_lpc10/mod_lpc10.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_lpc10/mod_lpc10.c Fri Feb 1 01:22:13 2008
@@ -156,36 +156,17 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-
-static switch_codec_implementation_t lpc10_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 7,
- /*.iananame */ "LPC",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 240,
- /*.microseconds_per_frame */ 22500,
- /*.samples_per_frame */ 180,
- /*.bytes_per_frame */ 360,
- /*.encoded_bytes_per_frame */ 7,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_lpc10_init,
- /*.encode */ switch_lpc10_encode,
- /*.decode */ switch_lpc10_decode,
- /*.destroy */ switch_lpc10_destroy,
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_lpc10_load)
{
switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "LPC-10 2.4kbps", &lpc10_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "LPC-10 2.4kbps");
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
+ 22500, 180, 360, 7, 1, 1, 1,
+ switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c Fri Feb 1 01:22:13 2008
@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct(a)yahoo.com>
*
*
- * mod_speexcodec.c -- Speex Codec Module
+ * mod_speex.c -- Speex Codec Module
*
*/
+
#include <switch.h>
#include <speex/speex.h>
#include <speex/speex_preprocess.h>
@@ -260,145 +261,30 @@
return SWITCH_STATUS_SUCCESS;
}
-/* Registration */
-static switch_codec_implementation_t speex_32k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 102,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 32000,
- /*.actual_samples_per_second */ 32000,
- /*.bits_per_second */ 44000,
- /*.nanoseconds_per_frame */ 20000,
- /*.samples_per_frame */ 640,
- /*.bytes_per_frame */ 1280,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy
-};
-
-static switch_codec_implementation_t speex_16k_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 99,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 16000,
- /*.actual_samples_per_second */ 16000,
- /*.bits_per_second */ 42200,
- /*.nanoseconds_per_frame */ 20000,
- /*.samples_per_frame */ 320,
- /*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy,
- /*.next */ &speex_32k_implementation
-};
-
-static switch_codec_implementation_t speex_8k_60ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 98,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24600,
- /*.nanoseconds_per_frame */ 60000,
- /*.samples_per_frame */ 480,
- /*.bytes_per_frame */ 960,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy,
- /*.next */ &speex_16k_implementation
-};
-
-static switch_codec_implementation_t speex_8k_40ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 98,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24600,
- /*.nanoseconds_per_frame */ 40000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy,
- /*.next */ &speex_8k_60ms_implementation
-
-};
-
-static switch_codec_implementation_t speex_8k_30ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 98,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24600,
- /*.nanoseconds_per_frame */ 30000,
- /*.samples_per_frame */ 240,
- /*.bytes_per_frame */ 480,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy,
- /*.next */ &speex_8k_40ms_implementation
-};
-
-static switch_codec_implementation_t speex_8k_20ms_implementation = {
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.ianacode */ 98,
- /*.iananame */ "speex",
- /*.fmtp */ NULL,
- /*.samples_per_second */ 8000,
- /*.actual_samples_per_second */ 8000,
- /*.bits_per_second */ 24600,
- /*.nanoseconds_per_frame */ 20000,
- /*.samples_per_frame */ 160,
- /*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 0,
- /*.number_of_channels */ 1,
- /*.pref_frames_per_packet */ 1,
- /*.max_frames_per_packet */ 1,
- /*.init */ switch_speex_init,
- /*.encode */ switch_speex_encode,
- /*.decode */ switch_speex_decode,
- /*.destroy */ switch_speex_destroy,
- /*.next */ &speex_8k_30ms_implementation
-};
-
SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
{
switch_codec_interface_t *codec_interface;
+ int mpf = 10000, spf = 80, bpf = 160, ebpf = 0, rate = 8000, counta, countb;
+ int ianacode[4] = { 0, 98, 99, 103};
+ int bps[4] = { 0, 24600, 42200, 44000 };
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_CODEC(codec_interface, "speex", &speex_8k_20ms_implementation);
+ SWITCH_ADD_CODEC(codec_interface, "Speex");
+ for (counta = 1; counta <= 3; counta++) {
+ for (countb = 6; countb > 0; countb--) {
+ switch_core_codec_add_implementation(pool, codec_interface,
+ SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "speex", NULL, rate, rate, bps[counta],
+ mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 6,
+ switch_speex_init, switch_speex_encode, switch_speex_decode, switch_speex_destroy);
+ }
+ rate = rate * 2;
+ spf = spf * 2;
+ bpf = bpf * 2;
+ ebpf = ebpf * 2;
+ }
+
+
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
1
0
Author: brian
Date: Thu Jan 31 23:41:57 2008
New Revision: 7451
Modified:
freeswitch/trunk/src/switch_resample.c
Log:
left over commit from tony's conf refactor
Modified: freeswitch/trunk/src/switch_resample.c
==============================================================================
--- freeswitch/trunk/src/switch_resample.c (original)
+++ freeswitch/trunk/src/switch_resample.c Thu Jan 31 23:41:57 2008
@@ -77,9 +77,9 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,
resampler->factor);
resampler->from_size = resample_buffer(to_rate, from_rate, (uint32_t)from_size);
- resampler->from = (float *) switch_core_alloc(pool, resampler->from_size);
+ resampler->from = (float *) switch_core_alloc(pool, resampler->from_size * sizeof(float));
resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t)to_size); ;
- resampler->to = (float *) switch_core_alloc(pool, resampler->to_size);
+ resampler->to = (float *) switch_core_alloc(pool, resampler->to_size * sizeof(float));
*new_resampler = resampler;
return SWITCH_STATUS_SUCCESS;
1
0
[Freeswitch-svn] [commit] r7450 - freeswitch/trunk/src/mod/applications/mod_conference
by Freeswitch SVN 01 Feb '08
by Freeswitch SVN 01 Feb '08
01 Feb '08
Author: mikej
Date: Thu Jan 31 23:13:18 2008
New Revision: 7450
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
whitespace cleanup (tabs not spaces)
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Jan 31 23:13:18 2008
@@ -726,7 +726,7 @@
switch_event_t *event;
uint8_t *file_frame;
uint8_t *async_file_frame;
-
+
file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
async_file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
@@ -763,53 +763,49 @@
/* Read one frame of audio from each member channel and save it for redistribution */
for (imember = conference->members; imember; imember = imember->next) {
- uint32_t buf_read = 0;
- uint32_t buf_read_max = imember->framelen;
- total++;
- imember->read = 0;
-
- //memset(imember->frame, 255, bytes);
- switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
+ uint32_t buf_read = 0;
+ uint32_t buf_read_max = imember->framelen;
+ total++;
+ imember->read = 0;
+
+ switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
switch_mutex_lock(imember->audio_in_mutex);
-
- if (imember->read_resampler) {
- buf_read_max = bytes;
- }
- if ((buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, buf_read_max))) {
+ if (imember->read_resampler) {
+ buf_read_max = bytes;
+ }
+
+ if ((buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, buf_read_max))) {
/* If the caller is not at the right sample rate resample him to suit and buffer accordingly */
- if (imember->mux_resampler) {
+ switch_audio_resampler_t *mux_resampler = imember->mux_resampler;
+ if (mux_resampler) {
int16_t *bptr = (int16_t *) imember->frame;
- switch_assert(buf_read <= imember->mux_resampler->from_size);
- imember->mux_resampler->from_len = switch_short_to_float(bptr, imember->mux_resampler->from, (int) buf_read / 2);
- imember->mux_resampler->to_len = switch_resample_process(imember->mux_resampler,
- imember->mux_resampler->from,
- imember->mux_resampler->from_len,
- imember->mux_resampler->to,
- imember->mux_resampler->to_size, 0);
-
-
- switch_float_to_short(imember->mux_resampler->to, imember->resample_out, imember->mux_resampler->to_len);
- switch_buffer_write(imember->resample_buffer, imember->resample_out, imember->mux_resampler->to_len * 2);
-
- if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
- if ((imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes))) {
- switch_set_flag(imember, MFLAG_HAS_AUDIO);
- ready++;
- }
- }
-
+ switch_assert(buf_read <= mux_resampler->from_size);
+ mux_resampler->from_len = switch_short_to_float(bptr, mux_resampler->from, (int) buf_read / 2);
+ mux_resampler->to_len = switch_resample_process(mux_resampler,
+ mux_resampler->from,
+ mux_resampler->from_len,
+ mux_resampler->to,
+ mux_resampler->to_size, 0);
+
+ switch_float_to_short(mux_resampler->to, imember->resample_out, mux_resampler->to_len);
+ switch_buffer_write(imember->resample_buffer, imember->resample_out, mux_resampler->to_len * 2);
+
+ if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
+ if ((imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes))) {
+ switch_set_flag(imember, MFLAG_HAS_AUDIO);
+ ready++;
+ }
+ }
} else {
- //printf("DOH %d %d %s\n", (int) buf_read, (int) bytes, switch_channel_get_name(switch_core_session_get_channel(imember->session)));
- imember->read = buf_read;
- switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
+ imember->read = buf_read;
+ switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
ready++;
}
}
-
switch_mutex_unlock(imember->audio_in_mutex);
}
-
+
/* If a file or speech event is being played */
if (conference->fnode) {
/* Lead in time */
@@ -872,70 +868,69 @@
}
if (ready) {
- int nt = 0;
+ int nt = 0;
/* Build a muxed frame for every member that contains the mixed audio of everyone else */
for (omember = conference->members; omember; omember = omember->next) {
- omember->read = bytes;
+ omember->read = bytes;
if (has_file_data && file_sample_len) {
memcpy(omember->mux_frame, file_frame, file_sample_len * 2);
} else {
memset(omember->mux_frame, 0, omember->read);
}
for (imember = conference->members; imember; imember = imember->next) {
- uint32_t x;
- int16_t *bptr, *muxed;
+ uint32_t x;
+ int16_t *bptr, *muxed;
if (imember == omember || !imember->read) {
/* Don't add audio from yourself or if you didnt read any */
continue;
}
- /* If they are not supposed to talk to us then don't let them */
- if (omember->relationships) {
- conference_relationship_t *rel;
-
- if ((rel = member_get_relationship(omember, imember))) {
- if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) {
- continue;
- }
- }
- }
-
- /* If we are not supposed to hear them then don't let it happen */
- if (imember->relationships) {
- conference_relationship_t *rel;
-
- if ((rel = member_get_relationship(imember, omember))) {
- if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
- continue;
- }
- }
- }
-
- if (nt && conference->not_talking_buf_len && !switch_test_flag(omember, MFLAG_HAS_AUDIO)) {
- memcpy(omember->mux_frame, conference->not_talking_buf, conference->not_talking_buf_len);
- continue;
- }
-
-
- bptr = (int16_t *) imember->frame;
- muxed = (int16_t *) omember->mux_frame;
-
- for (x = 0; x < imember->read / 2; x++) {
- int32_t z = muxed[x] + bptr[x];
- switch_normalize_to_16bit(z);
- muxed[x] = (int16_t) z;
- }
-
- if (total - ready > 1) {
- conference->not_talking_buf_len = imember->read;
- if (!conference->not_talking_buf) {
- conference->not_talking_buf = switch_core_alloc(conference->pool, imember->read + 128);
- }
- memcpy(conference->not_talking_buf, muxed, conference->not_talking_buf_len);
- nt++;
- }
- }
+ /* If they are not supposed to talk to us then don't let them */
+ if (omember->relationships) {
+ conference_relationship_t *rel;
+
+ if ((rel = member_get_relationship(omember, imember))) {
+ if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) {
+ continue;
+ }
+ }
+ }
+
+ /* If we are not supposed to hear them then don't let it happen */
+ if (imember->relationships) {
+ conference_relationship_t *rel;
+
+ if ((rel = member_get_relationship(imember, omember))) {
+ if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
+ continue;
+ }
+ }
+ }
+
+ if (nt && conference->not_talking_buf_len && !switch_test_flag(omember, MFLAG_HAS_AUDIO)) {
+ memcpy(omember->mux_frame, conference->not_talking_buf, conference->not_talking_buf_len);
+ continue;
+ }
+
+ bptr = (int16_t *) imember->frame;
+ muxed = (int16_t *) omember->mux_frame;
+
+ for (x = 0; x < imember->read / 2; x++) {
+ int32_t z = muxed[x] + bptr[x];
+ switch_normalize_to_16bit(z);
+ muxed[x] = (int16_t) z;
+ }
+
+ if (total - ready > 1) {
+ conference->not_talking_buf_len = imember->read;
+ if (!conference->not_talking_buf) {
+ conference->not_talking_buf = switch_core_alloc(conference->pool, imember->read + 128);
+ }
+ memcpy(conference->not_talking_buf, muxed, conference->not_talking_buf_len);
+ nt++;
+ }
+ }
}
/* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */
@@ -970,7 +965,6 @@
pool = fnode->pool;
fnode = NULL;
switch_core_destroy_memory_pool(&pool);
-
}
switch_mutex_unlock(conference->mutex);
@@ -1341,7 +1335,7 @@
switch_channel_t *channel;
switch_status_t status;
switch_frame_t *read_frame = NULL;
-
+
switch_codec_t *read_codec;
uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
uint8_t talking = 0;
@@ -1354,7 +1348,7 @@
switch_assert(read_codec != NULL);
/* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it
- and mux it with any audio from other channels. */
+ and mux it with any audio from other channels. */
while (switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
/* Read a frame. */
@@ -1399,7 +1393,7 @@
if (!(divisor = read_codec->implementation->actual_samples_per_second / 8000)) {
divisor = 1;
}
-
+
if ((samples = read_frame->datalen / sizeof(*data))) {
for (i = 0; i < samples; i++) {
@@ -1408,7 +1402,7 @@
}
score = energy / (samples / divisor);
}
-
+
if (score > energy_level) {
uint32_t diff = score - energy_level;
if (hangover_hits) {
@@ -1451,29 +1445,29 @@
/* skip frames that are not actual media or when we are muted or silent */
if ((talking || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK)) {
- void *data;
- uint32_t datalen;
+ switch_audio_resampler_t *read_resampler = member->read_resampler;
+ void *data;
+ uint32_t datalen;
- if (member->read_resampler) {
+ if (read_resampler) {
int16_t *bptr = (int16_t *) read_frame->data;
int len = (int) read_frame->datalen;
-
- member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
- member->read_resampler->to_len = switch_resample_process(member->read_resampler,
- member->read_resampler->from,
- member->read_resampler->from_len,
- member->read_resampler->to,
- member->read_resampler->to_size, 0);
-
- switch_float_to_short(member->read_resampler->to, member->resample_out, member->read_resampler->to_len);
- len = member->read_resampler->to_len * 2;
+ read_resampler->from_len = switch_short_to_float(bptr, read_resampler->from, (int) len / 2);
+ read_resampler->to_len = switch_resample_process(read_resampler,
+ read_resampler->from,
+ read_resampler->from_len,
+ read_resampler->to,
+ read_resampler->to_size, 0);
+
+ switch_float_to_short(read_resampler->to, member->resample_out, read_resampler->to_len);
+ len = read_resampler->to_len * 2;
datalen = len;
- data = member->resample_out;
+ data = member->resample_out;
} else {
- data = read_frame->data;
- datalen = read_frame->datalen;
- }
+ data = read_frame->data;
+ datalen = read_frame->datalen;
+ }
/* Check for input volume adjustments */
if (member->volume_in_level) {
1
0
[Freeswitch-svn] [commit] r7449 - freeswitch/trunk/src/mod/applications/mod_conference
by Freeswitch SVN 01 Feb '08
by Freeswitch SVN 01 Feb '08
01 Feb '08
Author: anthm
Date: Thu Jan 31 20:56:12 2008
New Revision: 7449
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
reduce, reuse, refactor
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Jan 31 20:56:12 2008
@@ -252,11 +252,11 @@
switch_codec_t write_codec;
char *rec_path;
uint8_t *frame;
+ uint32_t frame_size;
uint8_t *mux_frame;
uint32_t buflen;
uint32_t framelen;
uint32_t read;
- uint32_t len;
int32_t energy_level;
int32_t volume_in_level;
int32_t volume_out_level;
@@ -764,39 +764,49 @@
/* Read one frame of audio from each member channel and save it for redistribution */
for (imember = conference->members; imember; imember = imember->next) {
uint32_t buf_read = 0;
+ uint32_t buf_read_max = imember->framelen;
total++;
imember->read = 0;
-
+
+ //memset(imember->frame, 255, bytes);
switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
switch_mutex_lock(imember->audio_in_mutex);
- if ((buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->framelen))) {
+
+ if (imember->read_resampler) {
+ buf_read_max = bytes;
+ }
+
+ if ((buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, buf_read_max))) {
/* If the caller is not at the right sample rate resample him to suit and buffer accordingly */
if (imember->mux_resampler) {
int16_t *bptr = (int16_t *) imember->frame;
-
+ switch_assert(buf_read <= imember->mux_resampler->from_size);
imember->mux_resampler->from_len = switch_short_to_float(bptr, imember->mux_resampler->from, (int) buf_read / 2);
imember->mux_resampler->to_len = switch_resample_process(imember->mux_resampler,
imember->mux_resampler->from,
imember->mux_resampler->from_len,
imember->mux_resampler->to,
imember->mux_resampler->to_size, 0);
-
+
switch_float_to_short(imember->mux_resampler->to, imember->resample_out, imember->mux_resampler->to_len);
switch_buffer_write(imember->resample_buffer, imember->resample_out, imember->mux_resampler->to_len * 2);
-
- if ((imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, imember->buflen))) {
- switch_set_flag(imember, MFLAG_HAS_AUDIO);
- ready++;
+ if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
+ if ((imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes))) {
+ switch_set_flag(imember, MFLAG_HAS_AUDIO);
+ ready++;
+ }
}
} else {
+ //printf("DOH %d %d %s\n", (int) buf_read, (int) bytes, switch_channel_get_name(switch_core_session_get_channel(imember->session)));
imember->read = buf_read;
switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
ready++;
}
}
+
switch_mutex_unlock(imember->audio_in_mutex);
}
@@ -865,82 +875,74 @@
int nt = 0;
/* Build a muxed frame for every member that contains the mixed audio of everyone else */
for (omember = conference->members; omember; omember = omember->next) {
- omember->len = bytes;
- if (has_file_data) {
+ omember->read = bytes;
+ if (has_file_data && file_sample_len) {
memcpy(omember->mux_frame, file_frame, file_sample_len * 2);
} else {
- memset(omember->mux_frame, 255, bytes);
+ memset(omember->mux_frame, 0, omember->read);
}
for (imember = conference->members; imember; imember = imember->next) {
+ uint32_t x;
+ int16_t *bptr, *muxed;
- if (imember == omember) {
- /* Don't add audio from yourself */
+ if (imember == omember || !imember->read) {
+ /* Don't add audio from yourself or if you didnt read any */
continue;
}
- if (imember->read) { /* mux the frame with the collective */
- uint32_t x;
- int16_t *bptr, *muxed;
-
- /* If they are not supposed to talk to us then don't let them */
- if (omember->relationships) {
- conference_relationship_t *rel;
-
- if ((rel = member_get_relationship(omember, imember))) {
- if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) {
- continue;
- }
- }
- }
-
- /* If we are not supposed to hear them then don't let it happen */
- if (imember->relationships) {
- conference_relationship_t *rel;
-
- if ((rel = member_get_relationship(imember, omember))) {
- if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
- continue;
- }
- }
- }
+ /* If they are not supposed to talk to us then don't let them */
+ if (omember->relationships) {
+ conference_relationship_t *rel;
- if (nt && conference->not_talking_buf_len && !switch_test_flag(omember, MFLAG_HAS_AUDIO)) {
- memcpy(omember->mux_frame, conference->not_talking_buf, conference->not_talking_buf_len);
- continue;
+ if ((rel = member_get_relationship(omember, imember))) {
+ if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) {
+ continue;
+ }
}
+ }
+ /* If we are not supposed to hear them then don't let it happen */
+ if (imember->relationships) {
+ conference_relationship_t *rel;
+
+ if ((rel = member_get_relationship(imember, omember))) {
+ if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
+ continue;
+ }
+ }
+ }
+
+ if (nt && conference->not_talking_buf_len && !switch_test_flag(omember, MFLAG_HAS_AUDIO)) {
+ memcpy(omember->mux_frame, conference->not_talking_buf, conference->not_talking_buf_len);
+ continue;
+ }
- if (imember->read > imember->len) {
- imember->len = imember->read;
- }
-
- bptr = (int16_t *) imember->frame;
- muxed = (int16_t *) omember->mux_frame;
+ bptr = (int16_t *) imember->frame;
+ muxed = (int16_t *) omember->mux_frame;
- for (x = 0; x < imember->read / 2; x++) {
- int32_t z = muxed[x] + bptr[x];
- switch_normalize_to_16bit(z);
- muxed[x] = (int16_t) z;
- }
+ for (x = 0; x < imember->read / 2; x++) {
+ int32_t z = muxed[x] + bptr[x];
+ switch_normalize_to_16bit(z);
+ muxed[x] = (int16_t) z;
+ }
- if (total - ready > 1) {
- conference->not_talking_buf_len = imember->read;
- if (!conference->not_talking_buf) {
- conference->not_talking_buf = switch_core_alloc(conference->pool, imember->read + 128);
- }
- memcpy(conference->not_talking_buf, muxed, conference->not_talking_buf_len);
- nt++;
+ if (total - ready > 1) {
+ conference->not_talking_buf_len = imember->read;
+ if (!conference->not_talking_buf) {
+ conference->not_talking_buf = switch_core_alloc(conference->pool, imember->read + 128);
}
- }
- }
+ memcpy(conference->not_talking_buf, muxed, conference->not_talking_buf_len);
+ nt++;
+ }
+ }
}
/* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */
for (imember = conference->members; imember; imember = imember->next) {
if (switch_test_flag(imember, MFLAG_RUNNING)) {
switch_mutex_lock(imember->audio_out_mutex);
- switch_buffer_write(imember->mux_buffer, imember->mux_frame, imember->len);
+ switch_buffer_write(imember->mux_buffer, imember->mux_frame, imember->read);
switch_mutex_unlock(imember->audio_out_mutex);
}
}
@@ -1339,6 +1341,7 @@
switch_channel_t *channel;
switch_status_t status;
switch_frame_t *read_frame = NULL;
+
switch_codec_t *read_codec;
uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
uint8_t talking = 0;
@@ -1448,26 +1451,38 @@
/* skip frames that are not actual media or when we are muted or silent */
if ((talking || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+ void *data;
+ uint32_t datalen;
+
if (member->read_resampler) {
int16_t *bptr = (int16_t *) read_frame->data;
int len = (int) read_frame->datalen;
+
+
member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
- member->read_resampler->to_len =
- switch_resample_process(member->read_resampler, member->read_resampler->from,
- member->read_resampler->from_len, member->read_resampler->to, member->read_resampler->to_size, 0);
- switch_float_to_short(member->read_resampler->to, read_frame->data, len);
+ member->read_resampler->to_len = switch_resample_process(member->read_resampler,
+ member->read_resampler->from,
+ member->read_resampler->from_len,
+ member->read_resampler->to,
+ member->read_resampler->to_size, 0);
+
+ switch_float_to_short(member->read_resampler->to, member->resample_out, member->read_resampler->to_len);
len = member->read_resampler->to_len * 2;
- read_frame->datalen = len;
- read_frame->samples = len / 2;
- }
+ datalen = len;
+ data = member->resample_out;
+ } else {
+ data = read_frame->data;
+ datalen = read_frame->datalen;
+ }
+
/* Check for input volume adjustments */
if (member->volume_in_level) {
- switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, member->volume_in_level);
+ switch_change_sln_volume(data, datalen / 2, member->volume_in_level);
}
/* Write the audio into the input buffer */
switch_mutex_lock(member->audio_in_mutex);
- switch_buffer_write(member->audio_buffer, read_frame->data, read_frame->datalen);
+ switch_buffer_write(member->audio_buffer, data, datalen);
switch_mutex_unlock(member->audio_in_mutex);
}
}
@@ -1754,7 +1769,7 @@
write_frame.data = data;
use_buffer = member->mux_buffer;
low_count = 0;
-
+ use_timer = 1;
if ((write_frame.datalen = (uint32_t) switch_buffer_read(use_buffer, write_frame.data, bytes))) {
if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
write_frame.samples = write_frame.datalen / 2;
@@ -1769,7 +1784,7 @@
}
switch_mutex_unlock(member->audio_out_mutex);
- use_timer = 1;
+
} else {
if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
@@ -3853,6 +3868,10 @@
char *dpin = NULL;
conf_xml_cfg_t xml_cfg = { 0 };
switch_event_t *params = NULL;
+ uint32_t buflen;
+ uint32_t rinterval;
+
+
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
@@ -4103,17 +4122,10 @@
read_codec->implementation->actual_samples_per_second,
read_codec->implementation->microseconds_per_frame / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
- uint32_t buflen = switch_bytes_per_frame(conference->rate, conference->interval) * 2;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
- member.frame = switch_core_alloc(member.pool, buflen);
- member.mux_frame = switch_core_alloc(member.pool, buflen);
- member.buflen = buflen;
- member.framelen = member.read_codec.implementation->bytes_per_frame *
- conference->interval / (read_codec->implementation->microseconds_per_frame / 1000);
-
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
@@ -4121,6 +4133,16 @@
goto done;
}
+ buflen = switch_bytes_per_frame(conference->rate, conference->interval);
+ rinterval = read_codec->implementation->microseconds_per_frame / 1000;
+
+ member.framelen = member.read_codec.implementation->bytes_per_frame * ((conference->interval > rinterval) ? conference->interval / rinterval : 1);
+ member.buflen = buflen;
+ member.frame_size = (member.framelen + member.buflen) * 4;
+
+ member.frame = switch_core_alloc(member.pool, member.frame_size);
+ member.mux_frame = switch_core_alloc(member.pool, member.frame_size);
+
if (read_codec->implementation->actual_samples_per_second != conference->rate) {
@@ -4129,20 +4151,18 @@
if (switch_resample_create(resampler,
read_codec->implementation->actual_samples_per_second,
- read_codec->implementation->actual_samples_per_second * 10,
+ member.frame_size,
conference->rate,
- conference->rate * 10,
+ member.frame_size,
member.pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
goto done;
}
- if (member.mux_resampler) {
- member.resample_out = switch_core_alloc(member.pool, conference->rate * 10);
- member.resample_out_len = conference->rate * 10;
- }
-
+ member.resample_out = switch_core_alloc(member.pool, member.frame_size);
+ member.resample_out_len = member.frame_size;
+
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
!= SWITCH_STATUS_SUCCESS) {
@@ -4150,6 +4170,8 @@
goto done;
}
}
+
+
/* Setup a Signed Linear codec for writing audio. */
if (switch_core_codec_init(&member.write_codec,
"L16",
1
0