more g722 fun

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5987 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-10-19 03:21:37 +00:00
parent 66501a6cdd
commit 7c3f707fef
17 changed files with 79 additions and 45 deletions

View File

@ -502,6 +502,8 @@ struct switch_codec_implementation {
char *fmtp; char *fmtp;
/*! samples transferred per second */ /*! samples transferred per second */
uint32_t samples_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 */ /*! bits transferred per second */
int bits_per_second; int bits_per_second;
/*! number of microseconds that denote one frame */ /*! number of microseconds that denote one frame */

View File

@ -4218,13 +4218,13 @@ SWITCH_STANDARD_APP(conference_function)
goto done; goto done;
} }
if (read_codec->implementation->samples_per_second != conference->rate) { if (read_codec->implementation->actual_samples_per_second != conference->rate) {
switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ? switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
&member.read_resampler : &member.mux_resampler; &member.read_resampler : &member.mux_resampler;
if (switch_resample_create(resampler, if (switch_resample_create(resampler,
read_codec->implementation->samples_per_second, read_codec->implementation->actual_samples_per_second,
read_codec->implementation->samples_per_second * 20, read_codec->implementation->actual_samples_per_second * 20,
conference->rate, conference->rate,
conference->rate * 20, conference->rate * 20,
member.pool) != SWITCH_STATUS_SUCCESS) { member.pool) != SWITCH_STATUS_SUCCESS) {

View File

@ -296,6 +296,7 @@ static switch_codec_implementation_t amr_implementation = {
/*.iananame */ "AMR", /*.iananame */ "AMR",
/*.fmtp */ "octet-align=0", /*.fmtp */ "octet-align=0",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 0, /*.bits_per_second */ 0,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -188,6 +188,7 @@ static switch_codec_implementation_t g711u_8k_120ms_implementation = {
/*.iananame */ "PCMU", /*.iananame */ "PCMU",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 120000, /*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 960, /*.samples_per_frame */ 960,
@ -208,6 +209,7 @@ static switch_codec_implementation_t g711u_8k_60ms_implementation = {
/*.iananame */ "PCMU", /*.iananame */ "PCMU",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 19200, /*.bits_per_second */ 19200,
/*.microseconds_per_frame */ 60000, /*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 480, /*.samples_per_frame */ 480,
@ -229,6 +231,7 @@ static switch_codec_implementation_t g711u_8k_30ms_implementation = {
/*.iananame */ "PCMU", /*.iananame */ "PCMU",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 96000, /*.bits_per_second */ 96000,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -250,6 +253,7 @@ static switch_codec_implementation_t g711u_8k_20ms_implementation = {
/*.iananame */ "PCMU", /*.iananame */ "PCMU",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -271,6 +275,7 @@ static switch_codec_implementation_t g711u_8k_10ms_implementation = {
/*.iananame */ "PCMU", /*.iananame */ "PCMU",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 10000, /*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80, /*.samples_per_frame */ 80,
@ -294,6 +299,7 @@ static switch_codec_implementation_t g711a_8k_120ms_implementation = {
/*.iananame */ "PCMA", /*.iananame */ "PCMA",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 120000, /*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 960, /*.samples_per_frame */ 960,
@ -314,6 +320,7 @@ static switch_codec_implementation_t g711a_8k_60ms_implementation = {
/*.iananame */ "PCMA", /*.iananame */ "PCMA",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 19200, /*.bits_per_second */ 19200,
/*.microseconds_per_frame */ 60000, /*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 480, /*.samples_per_frame */ 480,
@ -335,6 +342,7 @@ static switch_codec_implementation_t g711a_8k_30ms_implementation = {
/*.iananame */ "PCMA", /*.iananame */ "PCMA",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 96000, /*.bits_per_second */ 96000,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -356,6 +364,7 @@ static switch_codec_implementation_t g711a_8k_20ms_implementation = {
/*.iananame */ "PCMA", /*.iananame */ "PCMA",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -377,6 +386,7 @@ static switch_codec_implementation_t g711a_8k_10ms_implementation = {
/*.iananame */ "PCMA", /*.iananame */ "PCMA",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 10000, /*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80, /*.samples_per_frame */ 80,

View File

@ -54,14 +54,14 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} else { } else {
if (encoding) { if (encoding) {
if (codec->implementation->samples_per_second == 16000) { if (codec->implementation->actual_samples_per_second == 16000) {
g722_encode_init(&context->encoder_object, 64000, G722_PACKED); g722_encode_init(&context->encoder_object, 64000, G722_PACKED);
} else { } else {
g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000); g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000);
} }
} }
if (decoding) { if (decoding) {
if (codec->implementation->samples_per_second == 16000) { if (codec->implementation->actual_samples_per_second == 16000) {
g722_decode_init(&context->decoder_object, 64000, G722_PACKED); g722_decode_init(&context->decoder_object, 64000, G722_PACKED);
} else { } else {
g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000); g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000);
@ -124,6 +124,7 @@ static switch_codec_implementation_t g722_8k_implementation = {
/*.iananame */ "G722_8", /*.iananame */ "G722_8",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -143,7 +144,8 @@ static switch_codec_implementation_t g722_16k_implementation = {
/*.ianacode */ 9, /*.ianacode */ 9,
/*.iananame */ "G722", /*.iananame */ "G722",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 16000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -156,7 +158,7 @@ static switch_codec_implementation_t g722_16k_implementation = {
/*.encode */ switch_g722_encode, /*.encode */ switch_g722_encode,
/*.decode */ switch_g722_decode, /*.decode */ switch_g722_decode,
/*.destroy */ switch_g722_destroy, /*.destroy */ switch_g722_destroy,
/*.next */ &g722_8k_implementation /*.next */
}; };
SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load) SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load)
@ -164,7 +166,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load)
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *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", &g722_16k_implementation);
SWITCH_ADD_CODEC(codec_interface, "G722_8", &g722_8k_implementation);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;

View File

@ -175,6 +175,7 @@ static switch_codec_implementation_t g723_1_implementation = {
/*.iananame */ "G723", /*.iananame */ "G723",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 6300, /*.bits_per_second */ 6300,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,

View File

@ -94,7 +94,7 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
g726_init_state(&handle->context); g726_init_state(&handle->context);
codec->private_info = handle; codec->private_info = handle;
handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second)); 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")) handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551; ? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -210,6 +210,7 @@ static switch_codec_implementation_t g726_16k_implementation = {
/*.iananame */ "G726-16", /*.iananame */ "G726-16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 16000, /*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -231,6 +232,7 @@ static switch_codec_implementation_t g726_24k_implementation = {
/*.iananame */ "G726-24", /*.iananame */ "G726-24",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24000, /*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -251,6 +253,7 @@ static switch_codec_implementation_t g726_32k_implementation = {
/*.iananame */ "G726-32", /*.iananame */ "G726-32",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 32000, /*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -271,6 +274,7 @@ static switch_codec_implementation_t g726_40k_implementation = {
/*.iananame */ "G726-40", /*.iananame */ "G726-40",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 40000, /*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -293,6 +297,7 @@ static switch_codec_implementation_t aal2_g726_16k_implementation = {
/*.iananame */ "AAL2-G726-16", /*.iananame */ "AAL2-G726-16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 16000, /*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -314,6 +319,7 @@ static switch_codec_implementation_t aal2_g726_24k_implementation = {
/*.iananame */ "AAL2-G726-24", /*.iananame */ "AAL2-G726-24",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24000, /*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -334,6 +340,7 @@ static switch_codec_implementation_t aal2_g726_32k_implementation = {
/*.iananame */ "AAL2-G726-32", /*.iananame */ "AAL2-G726-32",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 32000, /*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -354,6 +361,7 @@ static switch_codec_implementation_t aal2_g726_40k_implementation = {
/*.iananame */ "AAL2-G726-40", /*.iananame */ "AAL2-G726-40",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 40000, /*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -218,6 +218,7 @@ static switch_codec_implementation_t g729_40ms_8k_implementation = {
/*.iananame */ "G729", /*.iananame */ "G729",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 128000, /*.bits_per_second */ 128000,
/*.microseconds_per_frame */ 40000, /*.microseconds_per_frame */ 40000,
/*.samples_per_frame */ 320, /*.samples_per_frame */ 320,
@ -238,6 +239,7 @@ static switch_codec_implementation_t g729_30ms_8k_implementation = {
/*.iananame */ "G729", /*.iananame */ "G729",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 96000, /*.bits_per_second */ 96000,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -259,6 +261,7 @@ static switch_codec_implementation_t g729_10ms_8k_implementation = {
/*.iananame */ "G729", /*.iananame */ "G729",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 32000, /*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 10000, /*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80, /*.samples_per_frame */ 80,
@ -280,6 +283,7 @@ static switch_codec_implementation_t g729_8k_implementation = {
/*.iananame */ "G729", /*.iananame */ "G729",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000, /*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -140,6 +140,7 @@ static switch_codec_implementation_t gsm_8k_implementation = {
/*.iananame */ "GSM", /*.iananame */ "GSM",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 13200, /*.bits_per_second */ 13200,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -81,6 +81,7 @@ static switch_codec_implementation_t h264_90000_implementation = {
/*.iananame */ "H264", /*.iananame */ "H264",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 90000, /*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0, /*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0, /*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0, /*.samples_per_frame = */ 0,
@ -102,6 +103,7 @@ static switch_codec_implementation_t h263_90000_implementation = {
/*.iananame */ "H263", /*.iananame */ "H263",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 90000, /*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0, /*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0, /*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0, /*.samples_per_frame = */ 0,
@ -123,6 +125,7 @@ static switch_codec_implementation_t h261_90000_implementation = {
/*.iananame */ "H261", /*.iananame */ "H261",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 90000, /*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0, /*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0, /*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0, /*.samples_per_frame = */ 0,

View File

@ -188,6 +188,7 @@ static switch_codec_implementation_t ilbc_8k_30ms_implementation = {
/*.iananame */ "iLBC", /*.iananame */ "iLBC",
/*.fmtp */ "mode=30", /*.fmtp */ "mode=30",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS, /*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -208,6 +209,7 @@ static switch_codec_implementation_t ilbc_8k_20ms_implementation = {
/*.iananame */ "iLBC", /*.iananame */ "iLBC",
/*.fmtp */ "mode=20", /*.fmtp */ "mode=20",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS, /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -231,6 +233,7 @@ static switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
/*.iananame */ "iLBC", /*.iananame */ "iLBC",
/*.fmtp */ "mode=30", /*.fmtp */ "mode=30",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS, /*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -251,6 +254,7 @@ static switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
/*.iananame */ "iLBC102", /*.iananame */ "iLBC102",
/*.fmtp */ "mode=20", /*.fmtp */ "mode=20",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS, /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,
@ -273,6 +277,7 @@ static switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
/*.iananame */ "iLBC20ms", /*.iananame */ "iLBC20ms",
/*.fmtp */ "mode=20", /*.fmtp */ "mode=20",
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS, /*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000, /*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -57,7 +57,7 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
{ {
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */ /* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) { if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
memcpy(encoded_data, decoded_data, decoded_data_len); memcpy(encoded_data, decoded_data, decoded_data_len);
*encoded_data_len = decoded_data_len; *encoded_data_len = decoded_data_len;
return SWITCH_STATUS_RESAMPLE; return SWITCH_STATUS_RESAMPLE;
@ -72,7 +72,7 @@ static switch_status_t switch_raw_decode(switch_codec_t *codec,
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
unsigned int *flag) unsigned int *flag)
{ {
if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) { if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
memcpy(decoded_data, encoded_data, encoded_data_len); memcpy(decoded_data, encoded_data, encoded_data_len);
*decoded_data_len = encoded_data_len; *decoded_data_len = encoded_data_len;
return SWITCH_STATUS_RESAMPLE; return SWITCH_STATUS_RESAMPLE;
@ -93,6 +93,7 @@ static switch_codec_implementation_t raw_32k_60ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 32000, /*.samples_per_second = */ 32000,
/*.actual_samples_per_second = */ 32000,
/*.bits_per_second = */ 512000, /*.bits_per_second = */ 512000,
/*.microseconds_per_frame = */ 60000, /*.microseconds_per_frame = */ 60000,
/*.samples_per_frame = */ 1920, /*.samples_per_frame = */ 1920,
@ -114,6 +115,7 @@ static switch_codec_implementation_t raw_32k_30ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 32000, /*.samples_per_second = */ 32000,
/*.actual_samples_per_second = */ 32000,
/*.bits_per_second = */ 512000, /*.bits_per_second = */ 512000,
/*.microseconds_per_frame = */ 30000, /*.microseconds_per_frame = */ 30000,
/*.samples_per_frame = */ 960, /*.samples_per_frame = */ 960,
@ -135,6 +137,7 @@ static switch_codec_implementation_t raw_32k_20ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 32000, /*.samples_per_second = */ 32000,
/*.actual_samples_per_second = */ 32000,
/*.bits_per_second = */ 512000, /*.bits_per_second = */ 512000,
/*.microseconds_per_frame = */ 20000, /*.microseconds_per_frame = */ 20000,
/*.samples_per_frame = */ 640, /*.samples_per_frame = */ 640,
@ -156,6 +159,7 @@ static switch_codec_implementation_t raw_32k_10ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 32000, /*.samples_per_second = */ 32000,
/*.actual_samples_per_second = */ 32000,
/*.bits_per_second = */ 512000, /*.bits_per_second = */ 512000,
/*.microseconds_per_frame = */ 10000, /*.microseconds_per_frame = */ 10000,
/*.samples_per_frame = */ 320, /*.samples_per_frame = */ 320,
@ -177,6 +181,7 @@ static switch_codec_implementation_t raw_22k_20ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 22050, /*.samples_per_second = */ 22050,
/*.actual_samples_per_second = */ 22050,
/*.bits_per_second = */ 352800, /*.bits_per_second = */ 352800,
/*.microseconds_per_frame = */ 20000, /*.microseconds_per_frame = */ 20000,
/*.samples_per_frame = */ 441, /*.samples_per_frame = */ 441,
@ -198,6 +203,7 @@ static switch_codec_implementation_t raw_16k_120ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 16000, /*.samples_per_second */ 16000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 256000, /*.bits_per_second */ 256000,
/*.microseconds_per_frame */ 120000, /*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 1920, /*.samples_per_frame */ 1920,
@ -219,6 +225,7 @@ static switch_codec_implementation_t raw_16k_60ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 16000, /*.samples_per_second */ 16000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 256000, /*.bits_per_second */ 256000,
/*.microseconds_per_frame */ 60000, /*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 960, /*.samples_per_frame */ 960,
@ -240,6 +247,7 @@ static switch_codec_implementation_t raw_16k_30ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 16000, /*.samples_per_second */ 16000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 256000, /*.bits_per_second */ 256000,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 480, /*.samples_per_frame */ 480,
@ -261,6 +269,7 @@ static switch_codec_implementation_t raw_16k_20ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 16000, /*.samples_per_second = */ 16000,
/*.actual_samples_per_second = */ 16000,
/*.bits_per_second = */ 256000, /*.bits_per_second = */ 256000,
/*.microseconds_per_frame = */ 20000, /*.microseconds_per_frame = */ 20000,
/*.samples_per_frame = */ 320, /*.samples_per_frame = */ 320,
@ -282,6 +291,7 @@ static switch_codec_implementation_t raw_16k_10ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 16000, /*.samples_per_second = */ 16000,
/*.actual_samples_per_second = */ 16000,
/*.bits_per_second = */ 256000, /*.bits_per_second = */ 256000,
/*.microseconds_per_frame = */ 10000, /*.microseconds_per_frame = */ 10000,
/*.samples_per_frame = */ 160, /*.samples_per_frame = */ 160,
@ -306,6 +316,7 @@ static switch_codec_implementation_t raw_8k_120ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 512000, /*.bits_per_second */ 512000,
/*.microseconds_per_frame */ 120000, /*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 960, /*.samples_per_frame */ 960,
@ -328,6 +339,7 @@ static switch_codec_implementation_t raw_8k_60ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 256000, /*.bits_per_second */ 256000,
/*.microseconds_per_frame */ 60000, /*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 480, /*.samples_per_frame */ 480,
@ -349,6 +361,7 @@ static switch_codec_implementation_t raw_8k_30ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 128000, /*.bits_per_second */ 128000,
/*.microseconds_per_frame */ 30000, /*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -369,6 +382,7 @@ static switch_codec_implementation_t raw_8k_20ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 8000, /*.samples_per_second = */ 8000,
/*.actual_samples_per_second = */ 8000,
/*.bits_per_second = */ 128000, /*.bits_per_second = */ 128000,
/*.microseconds_per_frame = */ 20000, /*.microseconds_per_frame = */ 20000,
/*.samples_per_frame = */ 160, /*.samples_per_frame = */ 160,
@ -392,6 +406,7 @@ static switch_codec_implementation_t raw_8k_10ms_implementation = {
/*.iananame */ "L16", /*.iananame */ "L16",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second = */ 8000, /*.samples_per_second = */ 8000,
/*.actual_samples_per_second = */ 8000,
/*.bits_per_second = */ 128000, /*.bits_per_second = */ 128000,
/*.microseconds_per_frame = */ 10000, /*.microseconds_per_frame = */ 10000,
/*.samples_per_frame = */ 80, /*.samples_per_frame = */ 80,

View File

@ -162,6 +162,7 @@ static switch_codec_implementation_t lpc10_implementation = {
/*.iananame */ "LPC", /*.iananame */ "LPC",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 240, /*.bits_per_second */ 240,
/*.microseconds_per_frame */ 22500, /*.microseconds_per_frame */ 22500,
/*.samples_per_frame */ 180, /*.samples_per_frame */ 180,

View File

@ -268,6 +268,7 @@ static switch_codec_implementation_t speex_32k_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 32000, /*.samples_per_second */ 32000,
/*.actual_samples_per_second */ 32000,
/*.bits_per_second */ 256000, /*.bits_per_second */ 256000,
/*.nanoseconds_per_frame */ 20000, /*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 640, /*.samples_per_frame */ 640,
@ -288,6 +289,7 @@ static switch_codec_implementation_t speex_16k_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 16000, /*.samples_per_second */ 16000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 22000, /*.bits_per_second */ 22000,
/*.nanoseconds_per_frame */ 20000, /*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 320, /*.samples_per_frame */ 320,
@ -310,6 +312,7 @@ static switch_codec_implementation_t speex_8k_60ms_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 3300, /*.bits_per_second */ 3300,
/*.nanoseconds_per_frame */ 60000, /*.nanoseconds_per_frame */ 60000,
/*.samples_per_frame */ 480, /*.samples_per_frame */ 480,
@ -331,6 +334,7 @@ static switch_codec_implementation_t speex_8k_40ms_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 22000, /*.bits_per_second */ 22000,
/*.nanoseconds_per_frame */ 40000, /*.nanoseconds_per_frame */ 40000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -354,6 +358,7 @@ static switch_codec_implementation_t speex_8k_30ms_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 1650, /*.bits_per_second */ 1650,
/*.nanoseconds_per_frame */ 30000, /*.nanoseconds_per_frame */ 30000,
/*.samples_per_frame */ 240, /*.samples_per_frame */ 240,
@ -375,6 +380,7 @@ static switch_codec_implementation_t speex_8k_20ms_implementation = {
/*.iananame */ "speex", /*.iananame */ "speex",
/*.fmtp */ NULL, /*.fmtp */ NULL,
/*.samples_per_second */ 8000, /*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 11000, /*.bits_per_second */ 11000,
/*.nanoseconds_per_frame */ 20000, /*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 160, /*.samples_per_frame */ 160,

View File

@ -122,9 +122,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por
if (tech_pvt->rm_encoding) { if (tech_pvt->rm_encoding) {
rate = tech_pvt->rm_rate; rate = tech_pvt->rm_rate;
if (tech_pvt->pt == 9) {
rate = 8000;
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate);
if (tech_pvt->fmtp_out) { if (tech_pvt->fmtp_out) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
@ -156,9 +153,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por
if (ptime && ptime != imp->microseconds_per_frame / 1000) { if (ptime && ptime != imp->microseconds_per_frame / 1000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
} }
if (imp->ianacode == 9) {
rate = 8000;
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate);
if (imp->fmtp) { if (imp->fmtp) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
@ -1251,10 +1245,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
continue; continue;
} }
if (imp->ianacode == 9) {
codec_rate = 8000;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u]/[%s:%d:%u]\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u]/[%s:%d:%u]\n",
rm_encoding, map->rm_pt, (int)map->rm_rate, imp->iananame, imp->ianacode, codec_rate); rm_encoding, map->rm_pt, (int)map->rm_rate, imp->iananame, imp->ianacode, codec_rate);
if (map->rm_pt < 96) { if (map->rm_pt < 96) {
@ -1307,11 +1297,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *) rm_encoding))) { if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *) rm_encoding))) {
char tmp[50]; char tmp[50];
tech_pvt->pt = (switch_payload_t) map->rm_pt; tech_pvt->pt = (switch_payload_t) map->rm_pt;
if (map->rm_pt == 9) {
tech_pvt->rm_rate = 16000; /* *stab* *stab* *stab* */
} else {
tech_pvt->rm_rate = map->rm_rate; tech_pvt->rm_rate = map->rm_rate;
}
tech_pvt->codec_ms = mimp->microseconds_per_frame / 1000; tech_pvt->codec_ms = mimp->microseconds_per_frame / 1000;
tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, (char *) connection->c_address); tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, (char *) connection->c_address);
tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp); tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);

View File

@ -178,9 +178,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
case SWITCH_STATUS_RESAMPLE: case SWITCH_STATUS_RESAMPLE:
if (!session->read_resampler) { if (!session->read_resampler) {
if (switch_resample_create(&session->read_resampler, if (switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->samples_per_second, read_frame->codec->implementation->actual_samples_per_second,
read_frame->codec->implementation->bytes_per_frame * 20, read_frame->codec->implementation->bytes_per_frame * 20,
session->read_codec->implementation->samples_per_second, session->read_codec->implementation->actual_samples_per_second,
session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) { session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
@ -458,9 +458,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
write_frame = &session->raw_write_frame; write_frame = &session->raw_write_frame;
if (!session->write_resampler) { if (!session->write_resampler) {
status = switch_resample_create(&session->write_resampler, status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->samples_per_second, frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->bytes_per_frame * 20, frame->codec->implementation->bytes_per_frame * 20,
session->write_codec->implementation->samples_per_second, session->write_codec->implementation->actual_samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20, session->pool); session->write_codec->implementation->bytes_per_frame * 20, session->pool);
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
goto done; goto done;
@ -680,10 +680,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
write_frame = &session->enc_write_frame; write_frame = &session->enc_write_frame;
if (!session->read_resampler) { if (!session->read_resampler) {
status = switch_resample_create(&session->read_resampler, status = switch_resample_create(&session->read_resampler,
frame->codec->implementation->samples_per_second, frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->bytes_per_frame * 20, frame->codec->implementation->bytes_per_frame * 20,
session->write_codec->implementation-> session->write_codec->implementation->actual_samples_per_second,
samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20, session->pool); session->write_codec->implementation->bytes_per_frame * 20, session->pool);
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
goto done; goto done;

View File

@ -846,13 +846,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
return -1; return -1;
} }
#if 1
if (rtp_session->recv_msg.header.pt == 9 /* && G722 RFC != LAME */) {
uint32_t rfc_sucks = ntohl(rtp_session->recv_msg.header.ts);
rfc_sucks *= 2;
rtp_session->recv_msg.header.ts = htonl(rfc_sucks);
}
#endif
if (rtp_session->jb && bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) { if (rtp_session->jb && bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) {
if (rtp_session->recv_msg.header.m) { if (rtp_session->recv_msg.header.m) {
stfu_n_reset(rtp_session->jb); stfu_n_reset(rtp_session->jb);
@ -1623,11 +1617,6 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
} }
send_msg = rtp_session->send_msg; send_msg = rtp_session->send_msg;
#if 1
if (payload == 9 /* && G722 RFC != LAME */) {
ts /= 2;
}
#endif
send_msg.header.seq = htons(mseq); send_msg.header.seq = htons(mseq);
send_msg.header.ts = htonl(ts); send_msg.header.ts = htonl(ts);
send_msg.header.ssrc = htonl(ssrc); send_msg.header.ssrc = htonl(ssrc);