diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index a24125624d..e60631539a 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -502,6 +502,8 @@ struct switch_codec_implementation { 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 */ diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 57d257b498..1ee84dc3bc 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -4218,13 +4218,13 @@ SWITCH_STANDARD_APP(conference_function) 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 ? &member.read_resampler : &member.mux_resampler; if (switch_resample_create(resampler, - read_codec->implementation->samples_per_second, - read_codec->implementation->samples_per_second * 20, + read_codec->implementation->actual_samples_per_second, + read_codec->implementation->actual_samples_per_second * 20, conference->rate, conference->rate * 20, member.pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/codecs/mod_amr/mod_amr.c b/src/mod/codecs/mod_amr/mod_amr.c index 7f2552f7f1..640a0625cc 100644 --- a/src/mod/codecs/mod_amr/mod_amr.c +++ b/src/mod/codecs/mod_amr/mod_amr.c @@ -296,6 +296,7 @@ static switch_codec_implementation_t amr_implementation = { /*.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, diff --git a/src/mod/codecs/mod_g711/mod_g711.c b/src/mod/codecs/mod_g711/mod_g711.c index becc713f75..0656a05211 100644 --- a/src/mod/codecs/mod_g711/mod_g711.c +++ b/src/mod/codecs/mod_g711/mod_g711.c @@ -188,6 +188,7 @@ static switch_codec_implementation_t g711u_8k_120ms_implementation = { /*.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, @@ -208,6 +209,7 @@ static switch_codec_implementation_t g711u_8k_60ms_implementation = { /*.iananame */ "PCMU", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 19200, /*.microseconds_per_frame */ 60000, /*.samples_per_frame */ 480, @@ -229,6 +231,7 @@ static switch_codec_implementation_t g711u_8k_30ms_implementation = { /*.iananame */ "PCMU", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 96000, /*.microseconds_per_frame */ 30000, /*.samples_per_frame */ 240, @@ -250,6 +253,7 @@ static switch_codec_implementation_t g711u_8k_20ms_implementation = { /*.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, @@ -271,6 +275,7 @@ static switch_codec_implementation_t g711u_8k_10ms_implementation = { /*.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, @@ -294,6 +299,7 @@ static switch_codec_implementation_t g711a_8k_120ms_implementation = { /*.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, @@ -314,6 +320,7 @@ static switch_codec_implementation_t g711a_8k_60ms_implementation = { /*.iananame */ "PCMA", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 19200, /*.microseconds_per_frame */ 60000, /*.samples_per_frame */ 480, @@ -335,6 +342,7 @@ static switch_codec_implementation_t g711a_8k_30ms_implementation = { /*.iananame */ "PCMA", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 96000, /*.microseconds_per_frame */ 30000, /*.samples_per_frame */ 240, @@ -356,6 +364,7 @@ static switch_codec_implementation_t g711a_8k_20ms_implementation = { /*.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, @@ -377,6 +386,7 @@ static switch_codec_implementation_t g711a_8k_10ms_implementation = { /*.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, diff --git a/src/mod/codecs/mod_g722/mod_g722.c b/src/mod/codecs/mod_g722/mod_g722.c index 86ccd1856b..f7040c66b8 100644 --- a/src/mod/codecs/mod_g722/mod_g722.c +++ b/src/mod/codecs/mod_g722/mod_g722.c @@ -54,14 +54,14 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag return SWITCH_STATUS_FALSE; } else { 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); } else { g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000); } } 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); } else { 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", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 64000, /*.microseconds_per_frame */ 20000, /*.samples_per_frame */ 160, @@ -143,7 +144,8 @@ static switch_codec_implementation_t g722_16k_implementation = { /*.ianacode */ 9, /*.iananame */ "G722", /*.fmtp */ NULL, - /*.samples_per_second */ 16000, + /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 16000, /*.bits_per_second */ 64000, /*.microseconds_per_frame */ 20000, /*.samples_per_frame */ 160, @@ -156,7 +158,7 @@ static switch_codec_implementation_t g722_16k_implementation = { /*.encode */ switch_g722_encode, /*.decode */ switch_g722_decode, /*.destroy */ switch_g722_destroy, - /*.next */ &g722_8k_implementation + /*.next */ }; SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load) @@ -164,7 +166,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g722_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, "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 */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/codecs/mod_g723_1/mod_g723_1.c b/src/mod/codecs/mod_g723_1/mod_g723_1.c index 111508b4db..2dcb16913d 100644 --- a/src/mod/codecs/mod_g723_1/mod_g723_1.c +++ b/src/mod/codecs/mod_g723_1/mod_g723_1.c @@ -175,6 +175,7 @@ static switch_codec_implementation_t g723_1_implementation = { /*.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, diff --git a/src/mod/codecs/mod_g726/mod_g726.c b/src/mod/codecs/mod_g726/mod_g726.c index b98b1f58c9..11d4781d49 100644 --- a/src/mod/codecs/mod_g726/mod_g726.c +++ b/src/mod/codecs/mod_g726/mod_g726.c @@ -94,7 +94,7 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag g726_init_state(&handle->context); 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")) ? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551; return SWITCH_STATUS_SUCCESS; @@ -210,6 +210,7 @@ static switch_codec_implementation_t g726_16k_implementation = { /*.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, @@ -231,6 +232,7 @@ static switch_codec_implementation_t g726_24k_implementation = { /*.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, @@ -251,6 +253,7 @@ static switch_codec_implementation_t g726_32k_implementation = { /*.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, @@ -271,6 +274,7 @@ static switch_codec_implementation_t g726_40k_implementation = { /*.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, @@ -293,6 +297,7 @@ static switch_codec_implementation_t aal2_g726_16k_implementation = { /*.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, @@ -314,6 +319,7 @@ static switch_codec_implementation_t aal2_g726_24k_implementation = { /*.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, @@ -334,6 +340,7 @@ static switch_codec_implementation_t aal2_g726_32k_implementation = { /*.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, @@ -354,6 +361,7 @@ static switch_codec_implementation_t aal2_g726_40k_implementation = { /*.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, diff --git a/src/mod/codecs/mod_g729/mod_g729.c b/src/mod/codecs/mod_g729/mod_g729.c index 39bca9b841..612ab6d266 100644 --- a/src/mod/codecs/mod_g729/mod_g729.c +++ b/src/mod/codecs/mod_g729/mod_g729.c @@ -218,6 +218,7 @@ static switch_codec_implementation_t g729_40ms_8k_implementation = { /*.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, @@ -238,6 +239,7 @@ static switch_codec_implementation_t g729_30ms_8k_implementation = { /*.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, @@ -259,6 +261,7 @@ static switch_codec_implementation_t g729_10ms_8k_implementation = { /*.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, @@ -280,6 +283,7 @@ static switch_codec_implementation_t g729_8k_implementation = { /*.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, diff --git a/src/mod/codecs/mod_gsm/mod_gsm.c b/src/mod/codecs/mod_gsm/mod_gsm.c index cbf202cf45..1d55014899 100644 --- a/src/mod/codecs/mod_gsm/mod_gsm.c +++ b/src/mod/codecs/mod_gsm/mod_gsm.c @@ -140,6 +140,7 @@ static switch_codec_implementation_t gsm_8k_implementation = { /*.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, diff --git a/src/mod/codecs/mod_h26x/mod_h26x.c b/src/mod/codecs/mod_h26x/mod_h26x.c index 7213988d32..e697dfa813 100644 --- a/src/mod/codecs/mod_h26x/mod_h26x.c +++ b/src/mod/codecs/mod_h26x/mod_h26x.c @@ -81,6 +81,7 @@ static switch_codec_implementation_t h264_90000_implementation = { /*.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, @@ -102,6 +103,7 @@ static switch_codec_implementation_t h263_90000_implementation = { /*.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, @@ -123,6 +125,7 @@ static switch_codec_implementation_t h261_90000_implementation = { /*.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, diff --git a/src/mod/codecs/mod_ilbc/mod_ilbc.c b/src/mod/codecs/mod_ilbc/mod_ilbc.c index bbc0e02ecf..682c629e27 100644 --- a/src/mod/codecs/mod_ilbc/mod_ilbc.c +++ b/src/mod/codecs/mod_ilbc/mod_ilbc.c @@ -188,6 +188,7 @@ static switch_codec_implementation_t ilbc_8k_30ms_implementation = { /*.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, @@ -208,6 +209,7 @@ static switch_codec_implementation_t ilbc_8k_20ms_implementation = { /*.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, @@ -231,6 +233,7 @@ static switch_codec_implementation_t ilbc_102_8k_30ms_implementation = { /*.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, @@ -251,6 +254,7 @@ static switch_codec_implementation_t ilbc_102_8k_20ms_implementation = { /*.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, @@ -273,6 +277,7 @@ static switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = { /*.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, diff --git a/src/mod/codecs/mod_l16/mod_l16.c b/src/mod/codecs/mod_l16/mod_l16.c index 8f601b6f46..f1c368328c 100644 --- a/src/mod/codecs/mod_l16/mod_l16.c +++ b/src/mod/codecs/mod_l16/mod_l16.c @@ -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. */ - 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); *encoded_data_len = decoded_data_len; 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, 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); *decoded_data_len = encoded_data_len; return SWITCH_STATUS_RESAMPLE; @@ -93,6 +93,7 @@ static switch_codec_implementation_t raw_32k_60ms_implementation = { /*.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, @@ -114,6 +115,7 @@ static switch_codec_implementation_t raw_32k_30ms_implementation = { /*.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, @@ -135,6 +137,7 @@ static switch_codec_implementation_t raw_32k_20ms_implementation = { /*.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, @@ -156,6 +159,7 @@ static switch_codec_implementation_t raw_32k_10ms_implementation = { /*.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, @@ -177,6 +181,7 @@ static switch_codec_implementation_t raw_22k_20ms_implementation = { /*.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, @@ -198,6 +203,7 @@ static switch_codec_implementation_t raw_16k_120ms_implementation = { /*.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, @@ -219,6 +225,7 @@ static switch_codec_implementation_t raw_16k_60ms_implementation = { /*.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, @@ -240,6 +247,7 @@ static switch_codec_implementation_t raw_16k_30ms_implementation = { /*.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, @@ -261,6 +269,7 @@ static switch_codec_implementation_t raw_16k_20ms_implementation = { /*.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, @@ -282,6 +291,7 @@ static switch_codec_implementation_t raw_16k_10ms_implementation = { /*.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, @@ -306,6 +316,7 @@ static switch_codec_implementation_t raw_8k_120ms_implementation = { /*.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, @@ -328,6 +339,7 @@ static switch_codec_implementation_t raw_8k_60ms_implementation = { /*.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, @@ -349,6 +361,7 @@ static switch_codec_implementation_t raw_8k_30ms_implementation = { /*.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, @@ -369,6 +382,7 @@ static switch_codec_implementation_t raw_8k_20ms_implementation = { /*.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, @@ -392,6 +406,7 @@ static switch_codec_implementation_t raw_8k_10ms_implementation = { /*.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, diff --git a/src/mod/codecs/mod_lpc10/mod_lpc10.c b/src/mod/codecs/mod_lpc10/mod_lpc10.c index 21f8451943..c21f3211be 100644 --- a/src/mod/codecs/mod_lpc10/mod_lpc10.c +++ b/src/mod/codecs/mod_lpc10/mod_lpc10.c @@ -162,6 +162,7 @@ static switch_codec_implementation_t lpc10_implementation = { /*.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, diff --git a/src/mod/codecs/mod_speex/mod_speex.c b/src/mod/codecs/mod_speex/mod_speex.c index 4d82f947cc..1f9ecad963 100644 --- a/src/mod/codecs/mod_speex/mod_speex.c +++ b/src/mod/codecs/mod_speex/mod_speex.c @@ -268,6 +268,7 @@ static switch_codec_implementation_t speex_32k_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 32000, + /*.actual_samples_per_second */ 32000, /*.bits_per_second */ 256000, /*.nanoseconds_per_frame */ 20000, /*.samples_per_frame */ 640, @@ -288,6 +289,7 @@ static switch_codec_implementation_t speex_16k_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 16000, + /*.actual_samples_per_second */ 16000, /*.bits_per_second */ 22000, /*.nanoseconds_per_frame */ 20000, /*.samples_per_frame */ 320, @@ -310,6 +312,7 @@ static switch_codec_implementation_t speex_8k_60ms_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 3300, /*.nanoseconds_per_frame */ 60000, /*.samples_per_frame */ 480, @@ -331,6 +334,7 @@ static switch_codec_implementation_t speex_8k_40ms_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 22000, /*.nanoseconds_per_frame */ 40000, /*.samples_per_frame */ 240, @@ -354,6 +358,7 @@ static switch_codec_implementation_t speex_8k_30ms_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 1650, /*.nanoseconds_per_frame */ 30000, /*.samples_per_frame */ 240, @@ -375,6 +380,7 @@ static switch_codec_implementation_t speex_8k_20ms_implementation = { /*.iananame */ "speex", /*.fmtp */ NULL, /*.samples_per_second */ 8000, + /*.actual_samples_per_second */ 8000, /*.bits_per_second */ 11000, /*.nanoseconds_per_frame */ 20000, /*.samples_per_frame */ 160, diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index a8e116e018..5aa63bdd84 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -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) { 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); 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); @@ -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) { 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); if (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; } - 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", rm_encoding, map->rm_pt, (int)map->rm_rate, imp->iananame, imp->ianacode, codec_rate); 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))) { char tmp[50]; 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->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); diff --git a/src/switch_core_io.c b/src/switch_core_io.c index fccf743707..1ab35a5af6 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -178,9 +178,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi case SWITCH_STATUS_RESAMPLE: if (!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, - 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) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n"); 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; if (!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, - 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); if (status != SWITCH_STATUS_SUCCESS) { 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; if (!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, - 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); if (status != SWITCH_STATUS_SUCCESS) { goto done; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 38c6dd5292..4f858211f9 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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)) { 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->recv_msg.header.m) { 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; -#if 1 - if (payload == 9 /* && G722 RFC != LAME */) { - ts /= 2; - } -#endif send_msg.header.seq = htons(mseq); send_msg.header.ts = htonl(ts); send_msg.header.ssrc = htonl(ssrc);