]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move iana codes to the implementations.
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Jun 2006 20:14:29 +0000 (20:14 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Jun 2006 20:14:29 +0000 (20:14 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1666 d0543943-73ff-0310-b7d9-9358b9ac24b2

13 files changed:
src/include/switch_module_interfaces.h
src/mod/applications/mod_rss/mod_rss.c
src/mod/codecs/mod_g711/mod_g711.c
src/mod/codecs/mod_g729/mod_g729.c
src/mod/codecs/mod_gsm/mod_gsm.c
src/mod/codecs/mod_ilbc/mod_ilbc.c
src/mod/codecs/mod_l16/mod_l16.c
src/mod/codecs/mod_speex/mod_speex.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_exosip/mod_exosip.c
src/mod/endpoints/mod_iax/mod_iax.c
src/switch_loadable_module.c
src/switch_rtp.c

index 2dadbf8ca6dd25203d0aaa5122ade2a77dc8b392..ecee1353d2aaa4f4083c49cdf42a1b9a87c8486a 100644 (file)
@@ -444,6 +444,10 @@ struct switch_codec {
 
 /*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
 struct switch_codec_implementation {
+       /*! the IANA code number */
+       switch_payload_t ianacode;
+       /*! the IANA code name */
+       char *iananame;
        /*! samples transferred per second */
        uint32_t samples_per_second;
        /*! bits transferred per second */
@@ -495,10 +499,6 @@ struct switch_codec_interface {
        const char *interface_name;
        /*! enumeration defining the type of the codec */
        const switch_codec_type_t codec_type;
-       /*! the IANA code number */
-       switch_payload_t ianacode;
-       /*! the IANA code name */
-       char *iananame;
        /*! a list of codec implementations related to the codec */
        const switch_codec_implementation_t *implementations;
        const struct switch_codec_interface *next;
index 08df9ae74bb0dbb6e825c58b189e4523a21aa162..8339f6e0b0466c5d1cdbe5af85d501ee35e12afb 100644 (file)
@@ -69,11 +69,10 @@ static uint32_t match_count(char *str, uint32_t max)
        char tstr[80] = "";
        uint32_t matches = 0, x = 0;
        uint32_t len = (uint32_t)strlen(str);
-       printf("%s\n", str);
+
        for (x = 0; x < max ; x++) {
                snprintf(tstr, sizeof(tstr), "%u", x);
                if (!strncasecmp(str, tstr, len)) {
-                       printf("match %s=%s\n", str, tstr);
                        matches++;
                }
        }
@@ -293,6 +292,7 @@ static void rss_function(switch_core_session_t *session, char *data)
 
                if (jumpto > -1) {
                        snprintf(cmd, sizeof(cmd), "%d", jumpto);
+                       jumpto = -1;
                } else {
                        switch_core_speech_flush_tts(&sh);
 #ifdef MATCH_COUNT
index c3fe511693b1d853810b0482d05700ffc97d5d3e..3fc5a6cd491d6b0d483eae33a69ce73e761ef44c 100644 (file)
@@ -190,6 +190,8 @@ static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
 #if 0
 
 static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
+       /*.ianacode */ 0,
+       /*.iananame */ "PCMU",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 19200,
        /*.microseconds_per_frame */ 60000,
@@ -207,6 +209,8 @@ static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
 
 
 static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
+       /*.ianacode */ 0,
+       /*.iananame */ "PCMU",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 96000,
        /*.microseconds_per_frame */ 30000,
@@ -225,6 +229,8 @@ static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
 #endif
 
 static const switch_codec_implementation_t g711u_16k_implementation = {
+       /*.ianacode */ 0,
+       /*.iananame */ "PCMU",
        /*.samples_per_second */ 16000,
        /*.bits_per_second */ 128000,
        /*.microseconds_per_frame */ 20000,
@@ -241,6 +247,8 @@ static const switch_codec_implementation_t g711u_16k_implementation = {
 };
 
 static const switch_codec_implementation_t g711u_8k_implementation = {
+       /*.ianacode */ 0,
+       /*.iananame */ "PCMU",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 64000,
        /*.microseconds_per_frame */ 20000,
@@ -259,6 +267,8 @@ static const switch_codec_implementation_t g711u_8k_implementation = {
 
 
 static const switch_codec_implementation_t g711a_8k_implementation = {
+       /*.ianacode */ 8,
+       /*.iananame */ "PCMA",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 64000,
        /*.microseconds_per_frame */ 20000,
@@ -278,16 +288,12 @@ static const switch_codec_implementation_t g711a_8k_implementation = {
 static const switch_codec_interface_t g711a_codec_interface = {
        /*.interface_name */ "g711 alaw",
        /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-       /*.ianacode */ 8,
-       /*.iananame */ "PCMA",
        /*.implementations */ &g711a_8k_implementation
 };
 
 static const switch_codec_interface_t g711u_codec_interface = {
        /*.interface_name */ "g711 ulaw",
        /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-       /*.ianacode */ 0,
-       /*.iananame */ "PCMU",
        /*.implementations */ &g711u_8k_implementation,
        /*.next */ &g711a_codec_interface
 };
index 9f6f72861ee87ec9802cf459229559ddf914a4ab..99bee56909506faa5ace26fd27c09bf6658af744 100644 (file)
@@ -219,6 +219,8 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
 /* Registration */ 
 
 static const switch_codec_implementation_t g729_10ms_8k_implementation = { 
+       /*.ianacode */ 18, 
+       /*.iananame */ "G729", 
        /*.samples_per_second */ 8000, 
        /*.bits_per_second */ 32000, 
        /*.microseconds_per_frame */ 10000, 
@@ -235,6 +237,8 @@ static const switch_codec_implementation_t g729_10ms_8k_implementation = {
 };
 
 static const switch_codec_implementation_t g729_8k_implementation = { 
+       /*.ianacode */ 18, 
+       /*.iananame */ "G729", 
        /*.samples_per_second */ 8000, 
        /*.bits_per_second */ 64000, 
        /*.microseconds_per_frame */ 20000, 
@@ -255,8 +259,6 @@ static const switch_codec_implementation_t g729_8k_implementation = {
 static const switch_codec_interface_t g729_codec_interface = { 
        /*.interface_name */ "g729", 
        /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-       /*.ianacode */ 18, 
-       /*.iananame */ "G729", 
        /*.implementations */ &g729_8k_implementation, 
 };
 
index b8bfb7e46d2b0216ccc093022ea62aa7f7d21696..7aef780074c49bf3ff0b1d969f86f459e86ec362 100644 (file)
@@ -133,6 +133,8 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
 
 /* Registration */ 
 static const switch_codec_implementation_t gsm_8k_implementation = { 
+               /*.ianacode */ 3, 
+               /*.iananame */ "gsm", 
                /*.samples_per_second */ 8000, 
                /*.bits_per_second */ 13200, 
                /*.microseconds_per_frame */ 20000, 
@@ -150,8 +152,6 @@ static const switch_codec_implementation_t gsm_8k_implementation = {
 static const switch_codec_interface_t gsm_codec_interface = { 
                /*.interface_name */ "gsm", 
                /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-               /*.ianacode */ 3, 
-               /*.iananame */ "gsm", 
                /*.implementations */ &gsm_8k_implementation, 
 };
 static switch_loadable_module_interface_t gsm_module_interface = { 
index 282eaae74c87dd4f2c494b9b84f6e029d4636cad..96c4e36975959be0e56166690712f058988fa478 100644 (file)
@@ -186,6 +186,8 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
 /* Registration */ 
 
 static const switch_codec_implementation_t ilbc_8k_30ms_implementation = { 
+               /*.ianacode */ 97, 
+               /*.iananame */ "iLBC", 
                /*.samples_per_second */ 8000, 
                /*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
                /*.microseconds_per_frame */ 30000,
@@ -202,6 +204,8 @@ static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
 };
 
 static const switch_codec_implementation_t ilbc_8k_20ms_implementation = { 
+               /*.ianacode */ 97, 
+               /*.iananame */ "iLBC", 
                /*.samples_per_second */ 8000, 
                /*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
                /*.microseconds_per_frame */ 20000,
@@ -219,7 +223,48 @@ static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
 };
 
 
+
+static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = { 
+               /*.ianacode */ 97, 
+               /*.iananame */ "iLBC", 
+               /*.samples_per_second */ 8000, 
+               /*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
+               /*.microseconds_per_frame */ 30000,
+               /*.samples_per_frame */ 240,
+               /*.bytes_per_frame */ 480,
+               /*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
+               /*.number_of_channels */ 1,
+               /*.pref_frames_per_packet */ 1,
+               /*.max_frames_per_packet */ 1,
+               /*.init */ switch_ilbc_init,
+               /*.encode */ switch_ilbc_encode,
+               /*.decode */ switch_ilbc_decode,
+               /*.destroy */ switch_ilbc_destroy
+};
+
+static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = { 
+               /*.ianacode */ 102, 
+               /*.iananame */ "iLBC102", 
+               /*.samples_per_second */ 8000, 
+               /*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
+               /*.microseconds_per_frame */ 20000,
+               /*.samples_per_frame */ 160,
+               /*.bytes_per_frame */ 320,
+               /*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
+               /*.number_of_channels */ 1,
+               /*.pref_frames_per_packet */ 1,
+               /*.max_frames_per_packet */ 1,
+               /*.init */ switch_ilbc_init,
+               /*.encode */ switch_ilbc_encode,
+               /*.decode */ switch_ilbc_decode,
+               /*.destroy */ switch_ilbc_destroy,
+               /*.next */ &ilbc_102_8k_30ms_implementation
+};
+
+
 static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = { 
+               /*.ianacode */ 97, 
+               /*.iananame */ "iLBC20ms",
                /*.samples_per_second */ 8000, 
                /*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
                /*.microseconds_per_frame */ 20000,
@@ -239,25 +284,19 @@ static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation =
 static const switch_codec_interface_t ilbc_20ms_codec_interface = { 
                /*.interface_name */ "ilbc", 
                /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-               /*.ianacode */ 97, 
-               /*.iananame */ "iLBC20ms",
                /*.implementations */ &ilbc_8k_20ms_nonext_implementation
 };
 
 static const switch_codec_interface_t ilbc_102_codec_interface = { 
                /*.interface_name */ "ilbc", 
                /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-               /*.ianacode */ 102, 
-               /*.iananame */ "iLBC102", 
-               /*.implementations */ &ilbc_8k_20ms_implementation, 
+               /*.implementations */ &ilbc_102_8k_20ms_implementation, 
                /*.next*/ &ilbc_20ms_codec_interface
 };
 
 static const switch_codec_interface_t ilbc_codec_interface = { 
                /*.interface_name */ "ilbc", 
                /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-               /*.ianacode */ 97, 
-               /*.iananame */ "iLBC", 
                /*.implementations */ &ilbc_8k_20ms_implementation, 
                /*.next*/ &ilbc_102_codec_interface
 };
index ae61ac19f7399760c534109f2486e5e6c32944ae..71a0700f6f1146478a3e668f3736baadfbfcb594 100644 (file)
@@ -91,6 +91,8 @@ static switch_status_t switch_raw_destroy(switch_codec_t *codec)
 }
 
 static const switch_codec_implementation_t raw_32k_implementation = {
+       /*.ianacode */ 10,
+       /*.iananame */ "L16",
        /*.samples_per_second = */ 32000,
        /*.bits_per_second = */ 512000,
        /*.microseconds_per_frame = */ 20000,
@@ -107,6 +109,8 @@ static const switch_codec_implementation_t raw_32k_implementation = {
 };
 
 static const switch_codec_implementation_t raw_22k_implementation = {
+       /*.ianacode */ 10,
+       /*.iananame */ "L16",
        /*.samples_per_second = */ 22050,
        /*.bits_per_second = */ 352800,
        /*.microseconds_per_frame = */ 20000,
@@ -124,6 +128,8 @@ static const switch_codec_implementation_t raw_22k_implementation = {
 };
 
 static const switch_codec_implementation_t raw_16k_implementation = {
+       /*.ianacode */ 10,
+       /*.iananame */ "L16",
        /*.samples_per_second = */ 16000,
        /*.bits_per_second = */ 256000,
        /*.microseconds_per_frame = */ 20000,
@@ -141,6 +147,8 @@ static const switch_codec_implementation_t raw_16k_implementation = {
 };
 
 static const switch_codec_implementation_t raw_8k_implementation = {
+       /*.ianacode */ 10,
+       /*.iananame */ "L16",
        /*.samples_per_second = */ 8000,
        /*.bits_per_second = */ 128000,
        /*.microseconds_per_frame = */ 20000,
@@ -159,6 +167,8 @@ static const switch_codec_implementation_t raw_8k_implementation = {
 
 
 static const switch_codec_implementation_t raw_8k_30ms_implementation = {
+       /*.ianacode */ 10,
+       /*.iananame */ "L16",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 128000,
        /*.microseconds_per_frame */ 30000,
@@ -179,8 +189,6 @@ static const switch_codec_implementation_t raw_8k_30ms_implementation = {
 static const switch_codec_interface_t raw_codec_interface = {
        /*.interface_name */ "raw signed linear (16 bit)",
        /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-       /*.ianacode */ 10,
-       /*.iananame */ "L16",
        /*.implementations */ &raw_8k_30ms_implementation
 };
 
index 92edd889abafaaf9a3bf7e859032d20b181a055f..cf8461df93e5503bb71db66f0221bf415a38db31 100644 (file)
@@ -268,6 +268,8 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec)
 
 /* Registration */
 static const switch_codec_implementation_t speex_32k_implementation = {
+       /*.ianacode */ 98,
+       /*.iananame */ "speex",
        /*.samples_per_second */ 32000,
        /*.bits_per_second */ 512000,
        /*.nanoseconds_per_frame */ 20000,
@@ -284,6 +286,8 @@ static const switch_codec_implementation_t speex_32k_implementation = {
 };
 
 static const switch_codec_implementation_t speex_16k_implementation = {
+       /*.ianacode */ 98,
+       /*.iananame */ "speex",
        /*.samples_per_second */ 16000,
        /*.bits_per_second */ 256000,
        /*.nanoseconds_per_frame */ 20000,
@@ -301,6 +305,8 @@ static const switch_codec_implementation_t speex_16k_implementation = {
 };
 
 static const switch_codec_implementation_t speex_8k_implementation = {
+       /*.ianacode */ 98,
+       /*.iananame */ "speex",
        /*.samples_per_second */ 8000,
        /*.bits_per_second */ 128000,
        /*.nanoseconds_per_frame */ 20000,
@@ -320,8 +326,6 @@ static const switch_codec_implementation_t speex_8k_implementation = {
 static const switch_codec_interface_t speex_codec_interface = {
        /*.interface_name */ "speex",
        /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-       /*.ianacode */ 98,
-       /*.iananame */ "speex",
        /*.implementations */ &speex_8k_implementation
 };
 
index eaee1fa9f2c115ff8f1c4a6f89845edfde388a34..a599fc80ac3b67f92ea4cd537b2b3a8f0817f81f 100644 (file)
@@ -440,16 +440,16 @@ static int do_describe(struct private_object *tech_pvt, int force)
        if (force || !switch_test_flag(tech_pvt, TFLAG_CODEC_READY)) {
                if (tech_pvt->codec_index < 0) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't have my codec yet here's one\n");
-                       tech_pvt->codec_name = lame(tech_pvt->codecs[0]->iananame);
-                       tech_pvt->codec_num = tech_pvt->codecs[0]->ianacode;
+                       tech_pvt->codec_name = lame(tech_pvt->codecs[0]->implementations->iananame);
+                       tech_pvt->codec_num = tech_pvt->codecs[0]->implementations->ianacode;
                        tech_pvt->codec_index = 0;
                                        
-                       payloads[0].name = lame(tech_pvt->codecs[0]->iananame);
-                       payloads[0].id = tech_pvt->codecs[0]->ianacode;
+                       payloads[0].name = lame(tech_pvt->codecs[0]->implementations->iananame);
+                       payloads[0].id = tech_pvt->codecs[0]->implementations->ianacode;
                        
                } else {
-                       payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
-                       payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
+                       payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->implementations->iananame);
+                       payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->implementations->ianacode;
                }
 
                                
@@ -1546,22 +1546,22 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
                                for(x = 0; x < len; x++) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
                                        for(y = 0; y < tech_pvt->num_codecs; y++) {
-                                               char *name = tech_pvt->codecs[y]->iananame;
+                                               char *name = tech_pvt->codecs[y]->implementations->iananame;
 
                                                if (!strncasecmp(name, "ilbc", 4)) {
                                                        name = "ilbc";
                                                }
-                                               if (tech_pvt->codecs[y]->ianacode > 96) {
+                                               if (tech_pvt->codecs[y]->implementations->ianacode > 96) {
                                                        match = strcasecmp(name, payloads[x].name) ? 0 : 1;
                                                } else {
-                                                       match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0;
+                                                       match = (payloads[x].id == tech_pvt->codecs[y]->implementations->ianacode) ? 1 : 0;
                                                }
                                                
                                                if (match) {
                                                        tech_pvt->codec_index = y;
                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name, payloads[x].id);
-                                                       tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
-                                                       tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
+                                                       tech_pvt->codec_name = tech_pvt->codecs[y]->implementations->iananame;
+                                                       tech_pvt->codec_num = tech_pvt->codecs[y]->implementations->ianacode;
                                                        if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
                                                                do_describe(tech_pvt, 0);
                                                        }
index 2eb4c52ea08ebfcef4ac747c3db360c53cd9797f..c71d2e00c8828e467f7ea151cbd0abbbc466d03c 100644 (file)
@@ -351,24 +351,27 @@ static switch_status_t exosip_on_init(switch_core_session_t *session)
                
                
                if (tech_pvt->num_codecs > 0) {
-                       int i;
+                       int i, lastcode = -1;
 
                        static const switch_codec_implementation_t *imp;
 
                        for (i = 0; i < tech_pvt->num_codecs; i++) {
-
-
-                               snprintf(tmp, sizeof(tmp), "%u", tech_pvt->codecs[i]->ianacode);
-                               sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
                                imp = tech_pvt->codecs[i]->implementations;
 
                                while(NULL != imp) {
                                        uint32_t sps = imp->samples_per_second;
+
+                                       if (lastcode != imp->ianacode) {
+                                               snprintf(tmp, sizeof(tmp), "%u", imp->ianacode);
+                                               sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
+                                               lastcode = imp->ianacode;
+                                       }
+
                                        /* Add to SDP config */
-                                       sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, tech_pvt->codecs[i]->ianacode, tech_pvt->codecs[i]->iananame, sps, 0);
+                                       sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, imp->ianacode, imp->iananame, sps, 0);
 
                                        /* Add to SDP message */
-                                       snprintf(tmp, sizeof(tmp), "%u %s/%d", tech_pvt->codecs[i]->ianacode, tech_pvt->codecs[i]->iananame, sps);
+                                       snprintf(tmp, sizeof(tmp), "%u %s/%d", imp->ianacode, imp->iananame, sps);
                                        sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(tmp));
                                        memset(tmp, 0, sizeof(tmp));
                                        if (imp) {
@@ -521,10 +524,10 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
        }
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activating RTP %s:%d->%s:%d codec: %u ms: %d\n",
-                                                 tech_pvt->local_sdp_audio_ip,
-                                                 tech_pvt->local_sdp_audio_port,
-                                                 tech_pvt->remote_sdp_audio_ip,
-                                                 tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.codec_interface->ianacode, ms);
+                                         tech_pvt->local_sdp_audio_ip,
+                                         tech_pvt->local_sdp_audio_port,
+                                         tech_pvt->remote_sdp_audio_ip,
+                                         tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.implementation->ianacode, ms);
 
 
        if (tech_pvt->realm) {
@@ -548,15 +551,15 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
        }
 
        tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
-                                              tech_pvt->local_sdp_audio_port,
-                                              tech_pvt->remote_sdp_audio_ip,
-                                              tech_pvt->remote_sdp_audio_port,
-                                              tech_pvt->read_codec.codec_interface->ianacode,
-                                              tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
-                                              ms,
-                                              flags,
-                                              key,
-                                              &err, switch_core_session_get_pool(tech_pvt->session));
+                                                                                  tech_pvt->local_sdp_audio_port,
+                                                                                  tech_pvt->remote_sdp_audio_ip,
+                                                                                  tech_pvt->remote_sdp_audio_port,
+                                                                                  tech_pvt->read_codec.implementation->ianacode,
+                                                                                  tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+                                                                                  ms,
+                                                                                  flags,
+                                                                                  key,
+                                                                                  &err, switch_core_session_get_pool(tech_pvt->session));
 
        if (tech_pvt->rtp_session) {
                uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
@@ -1311,7 +1314,7 @@ static switch_status_t exosip_create_call(eXosip_event_t * event)
 
                        for (i = 0; i < tech_pvt->num_codecs; i++) {
                                for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
-                                       sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, tech_pvt->codecs[i]->ianacode, tech_pvt->codecs[i]->iananame,
+                                       sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, imp->ianacode, imp->iananame,
                                                                  imp->samples_per_second, 0);
 
                                }
@@ -1520,22 +1523,20 @@ static switch_status_t parse_sdp_media(struct private_object *tech_pvt, sdp_medi
                        for(i = 0; !match && i < tech_pvt->num_codecs; i++) {
                                const switch_codec_implementation_t *imp;
                                
-                               if (pt < 97) {
-                                       match = (pt == tech_pvt->codecs[i]->ianacode) ? 1 : 0;
-                               } else {
-                                       match = strcasecmp(name, tech_pvt->codecs[i]->iananame) ? 0 : 1;
-                               }
                                
-                               if (match) {
-                                       match = 0;
+                               for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
+
+                                       if (pt < 97) {
+                                               match = (pt == imp->ianacode) ? 1 : 0;
+                                       } else {
+                                               match = strcasecmp(name, imp->iananame) ? 0 : 1;
+                                       }
                                        
-                                       for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
-                                               if ((r == imp->samples_per_second)) {
-                                                       match = 1;
-                                                       break;
-                                               }
+                                       if (match && (r == imp->samples_per_second)) {
+                                               break;
                                        }
                                }
+                               
                        }
 
                        if (match) {
index 2b5ad14fc64434179ae3d27b266b41c46d1279b6..213cb12a274b11ccc31b25730458c33ffbcbf130 100644 (file)
@@ -234,11 +234,15 @@ static switch_status_t iax_set_codec(struct private_object *tech_pvt, struct iax
        }
 
        for (x = 0; x < num_codecs; x++) {
-               unsigned int codec = iana2ast(codecs[x]->ianacode);
-               if (io == IAX_QUERY) {
-                       iax_pref_codec_add(iax_session, codec);
+               static const switch_codec_implementation_t *imp;
+               for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+                       unsigned int codec = iana2ast(imp->ianacode);
+               
+                       if (io == IAX_QUERY) {
+                               iax_pref_codec_add(iax_session, codec);
+                       }
+                       local_cap |= codec;
                }
-               local_cap |= codec;
        }
 
        if (io == IAX_SET) {
@@ -247,7 +251,7 @@ static switch_status_t iax_set_codec(struct private_object *tech_pvt, struct iax
                mixed_cap = local_cap;
        }
 
-       leading = iana2ast(codecs[0]->ianacode);
+       leading = iana2ast(codecs[0]->implementations->ianacode);
        if (io == IAX_QUERY) {
                chosen = leading;
                *format = chosen;
@@ -259,7 +263,7 @@ static switch_status_t iax_set_codec(struct private_object *tech_pvt, struct iax
                return SWITCH_STATUS_SUCCESS;
        } else if (switch_test_flag(&globals, GFLAG_MY_CODEC_PREFS) && (leading & mixed_cap)) {
                chosen = leading;
-               dname = codecs[0]->iananame;
+               dname = codecs[0]->implementations->iananame;
        } else {
                unsigned int prefs[32];
                int len = 0;
@@ -283,8 +287,12 @@ static switch_status_t iax_set_codec(struct private_object *tech_pvt, struct iax
                                        int z;
                                        chosen = prefs[x];
                                        for (z = 0; z < num_codecs; z++) {
-                                               if (prefs[x] == iana2ast(codecs[z]->ianacode)) {
-                                                       dname = codecs[z]->iananame;
+                                               static const switch_codec_implementation_t *imp;
+                                               for (imp = codecs[z]->implementations; imp; imp = imp->next) {
+                                                       if (prefs[x] == iana2ast(imp->ianacode)) {
+                                                               dname = imp->iananame;
+                                                               break;
+                                                       }
                                                }
                                        }
                                        break;
@@ -294,17 +302,25 @@ static switch_status_t iax_set_codec(struct private_object *tech_pvt, struct iax
                        if (*format & mixed_cap) {      /* is the one we asked for here? */
                                chosen = *format;
                                for (x = 0; x < num_codecs; x++) {
-                                       unsigned int cap = iana2ast(codecs[x]->ianacode);
-                                       if (cap == chosen) {
-                                               dname = codecs[x]->iananame;
+                                       static const switch_codec_implementation_t *imp;
+                                       for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+                                               unsigned int cap = iana2ast(imp->ianacode);
+                                               if (cap == chosen) {
+                                                       dname = imp->iananame;
+                                                       break;
+                                               }
                                        }
                                }
                        } else {                        /* c'mon there has to be SOMETHING... */
                                for (x = 0; x < num_codecs; x++) {
-                                       unsigned int cap = iana2ast(codecs[x]->ianacode);
-                                       if (cap & mixed_cap) {
-                                               chosen = cap;
-                                               dname = codecs[x]->iananame;
+                                       static const switch_codec_implementation_t *imp;
+                                       for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+                                               unsigned int cap = iana2ast(imp->ianacode);
+                                               if (cap & mixed_cap) {
+                                                       chosen = cap;
+                                                       dname = imp->iananame;
+                                                       break;
+                                               }
                                        }
                                }
                        }
index d1d27897011e576cd6db34ad09bc6eed11694931..475c6c79c4ec82e96b28c935c99537fd0443d4ac 100644 (file)
@@ -109,16 +109,19 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
                        for (impl = ptr->implementations; impl; impl = impl->next) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
                                                                  "Adding Codec '%s' (%s) %dkhz %dms\n",
-                                                                 ptr->iananame,
+                                                                 impl->iananame,
                                                                  ptr->interface_name,
                                                                  impl->samples_per_second, impl->microseconds_per_frame / 1000);
+                               if (!switch_core_hash_find(loadable_modules.codec_hash, (char *) impl->iananame)) {
+                                       switch_core_hash_insert(loadable_modules.codec_hash, (char *) impl->iananame, (void *) ptr);
+                               }
                        }
                        if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "codec");
                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
                                switch_event_fire(&event);
                        }
-                       switch_core_hash_insert(loadable_modules.codec_hash, (char *) ptr->iananame, (void *) ptr);
+                       
                }
        }
 
index db378db20f37fb4ab0763d4f97b3855a5b7b78be..f1d190b85029922f782558be8ab1951851ec74e5 100644 (file)
@@ -1082,7 +1082,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, void *data, uint32_t data
        }
        
        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) && 
-               rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->codec_interface->ianacode &&
+               rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
                datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) {
                int16_t decoded[SWITCH_RECCOMMENDED_BUFFER_SIZE/sizeof(int16_t)];
                uint32_t rate;
@@ -1241,7 +1241,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session,
        memset(&rtp_session->vad_data, 0, sizeof(rtp_session->vad_data));
        
        if (switch_core_codec_init(&rtp_session->vad_data.vad_codec,
-                                                          codec->codec_interface->iananame,
+                                                          codec->implementation->iananame,
                                                           codec->implementation->samples_per_second,
                                                           codec->implementation->microseconds_per_frame / 1000,
                                                           codec->implementation->number_of_channels,