]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
more g722 fun
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 19 Oct 2007 03:21:37 +0000 (03:21 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 19 Oct 2007 03:21:37 +0000 (03:21 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5987 d0543943-73ff-0310-b7d9-9358b9ac24b2

17 files changed:
src/include/switch_module_interfaces.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/codecs/mod_amr/mod_amr.c
src/mod/codecs/mod_g711/mod_g711.c
src/mod/codecs/mod_g722/mod_g722.c
src/mod/codecs/mod_g723_1/mod_g723_1.c
src/mod/codecs/mod_g726/mod_g726.c
src/mod/codecs/mod_g729/mod_g729.c
src/mod/codecs/mod_gsm/mod_gsm.c
src/mod/codecs/mod_h26x/mod_h26x.c
src/mod/codecs/mod_ilbc/mod_ilbc.c
src/mod/codecs/mod_l16/mod_l16.c
src/mod/codecs/mod_lpc10/mod_lpc10.c
src/mod/codecs/mod_speex/mod_speex.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_io.c
src/switch_rtp.c

index a24125624d6aa7ffdefac3c4dbe1a5edf26b5588..e60631539a0e12d10b8212e57c0615be21a5476a 100644 (file)
@@ -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 */
index 57d257b498abaa06f8f144cac34dac583e7f07bd..1ee84dc3bcdccf8ef85fb4a0b9050ec9b83ae813 100644 (file)
@@ -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) {
index 7f2552f7f19806a459e8aba70630d3b121f6be1e..640a0625cca81a90aa274e168c824ed7807fcf7c 100644 (file)
@@ -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,
index becc713f758ba52494b6ccf21afdc53639b11e4a..0656a05211c8135474815bc8ca056716b0e08e3e 100644 (file)
@@ -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,
index 86ccd1856b92f7c7fbb165c2f72884c85b5f7951..f7040c66b8be491f738f02bcd9c06f138c9c05e3 100644 (file)
@@ -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;
index 111508b4dba63179c3c038bf6024b1190fbeda1d..2dcb16913dd1a9efb0e729c0f1a18f033ec1d7ca 100644 (file)
@@ -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,
index b98b1f58c96d4fc9ada09081afbb867ee4b60942..11d4781d49af5087c2a4d15ae5bdbf481a97328f 100644 (file)
@@ -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,
index 39bca9b84134c2fd1a1c78bea81e85e0b6577498..612ab6d2662dd42a2df8431fe6b676d333817e8b 100644 (file)
@@ -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,
index cbf202cf4532c2aa7da13b588f0224709026cdae..1d550148993358d019e042b3e8318dabcd99b7e0 100644 (file)
@@ -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,
index 7213988d3223d18019807f963021c91d1f16180f..e697dfa813fd43d790c1ab903f5bc1f6013aebab 100644 (file)
@@ -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,
index bbc0e02ecf3f1d97bf683394018fd9676285775a..682c629e27ab8dbd3579b32c6cd0eff6ee0d162f 100644 (file)
@@ -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,
index 8f601b6f46b1aaa3395bfcf62fc1932d8373dab4..f1c368328c60cc11faa14a14f9560ee6c99cf45d 100644 (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. */
-       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,
index 21f845194320fb0a038d51716399f2814683504c..c21f3211be2cd77849e9a547dca4264492bb8204 100644 (file)
@@ -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,
index 4d82f947cc036ab14ca5888a921235d8edb9e473..1f9ecad963517d9d3566d0553981985db845d5e3 100644 (file)
@@ -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,
index a8e116e0185306522389e8556ee49269281e47a0..5aa63bdd840290c9ee8d5c9ef9a4f25cba9f321b 100644 (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) {
                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);
index fccf743707b3c08702a18bbfc97803243135bef9..1ab35a5af618ca99fb895dbfbcc9758e14c665f1 100644 (file)
@@ -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;
index 38c6dd52929e496068db049925d68231ceb1d22a..4f858211f93b0bd6efac6399c5b7c2623da3569c 100644 (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)) {
                        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);