[Freeswitch-svn] [commit] r2364 - in freeswitch/trunk/src: . mod/codecs/mod_g711 mod/endpoints/mod_exosip
Freeswitch SVN
anthm at freeswitch.org
Tue Aug 22 17:08:35 EDT 2006
Author: anthm
Date: Tue Aug 22 17:08:34 2006
New Revision: 2364
Modified:
freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
freeswitch/trunk/src/switch_core.c
Log:
fix 183 on exosip
Modified: freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c Tue Aug 22 17:08:34 2006
@@ -207,8 +207,8 @@
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy
};
-#endif
+
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
@@ -248,6 +248,7 @@
/*.destroy */ switch_g711u_destroy,
/*.next */ &g711u_8k_30ms_implementation
};
+#endif
static const switch_codec_implementation_t g711u_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
@@ -266,7 +267,7 @@
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_16k_implementation
+ ///*.next */ &g711u_16k_implementation
};
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Tue Aug 22 17:08:34 2006
@@ -77,7 +77,8 @@
TFLAG_VAD_OUT = ( 1 << 13),
TFLAG_VAD = ( 1 << 14),
TFLAG_TIMER = ( 1 << 15),
- TFLAG_AA = (1 << 16)
+ TFLAG_AA = (1 << 16),
+ TFLAG_PRE_ANSWER = (1 << 17)
} TFLAGS;
@@ -349,13 +350,7 @@
tech_set_codecs(tech_pvt);
- sprintf(dbuf, "%u", tech_pvt->te);
- sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
- sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
- sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
- sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
- sprintf(dbuf, "%u 0-15", tech_pvt->te);
- sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "fmtp", osip_strdup(dbuf));
+
if (tech_pvt->num_codecs > 0) {
int i, lastcode = -1;
@@ -365,7 +360,7 @@
for (i = 0; i < tech_pvt->num_codecs; i++) {
imp = tech_pvt->codecs[i];
- while(NULL != imp) {
+ if (imp) {
uint32_t sps = imp->samples_per_second;
if (lastcode != imp->ianacode) {
@@ -381,14 +376,18 @@
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) {
- imp = imp->next;
- }
}
}
}
+ sprintf(dbuf, "%u", tech_pvt->te);
+ sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
+ sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
+ sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
+ sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
+ sprintf(dbuf, "%u 0-15", tech_pvt->te);
+ sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "fmtp", osip_strdup(dbuf));
/* Setup our INVITE */
eXosip_lock();
@@ -1328,7 +1327,7 @@
static const switch_codec_implementation_t *imp = NULL;
for (i = 0; i < tech_pvt->num_codecs; i++) {
- for (imp = tech_pvt->codecs[i]; imp; imp = imp->next) {
+ if ((imp = tech_pvt->codecs[i])) {
sdp_add_codec(tech_pvt->sdp_config,
tech_pvt->codecs[i]->codec_type,
imp->ianacode,
@@ -1705,7 +1704,7 @@
}
-static void handle_answer(eXosip_event_t * event)
+static void handle_answer(eXosip_event_t *event)
{
osip_message_t *ack = NULL;
sdp_message_t *remote_sdp = NULL;
@@ -1715,12 +1714,24 @@
char *dpayload = NULL, *dname = NULL, *drate = NULL;
switch_channel_t *channel;
const switch_codec_implementation_t *imp = NULL;
+ uint8_t pre_answer = 0;
+
+
if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot answer nonexistant call [%d]!\n", event->cid);
return;
}
+ if (event->type == EXOSIP_CALL_RINGING) {
+ pre_answer = 1;
+ if (switch_test_flag(tech_pvt, TFLAG_PRE_ANSWER)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "one pre-answer is enough for call [%d]!\n", event->cid);
+ return;
+ }
+ switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
+ }
+
channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL);
@@ -1755,6 +1766,13 @@
/* Assign them thar IDs */
tech_pvt->did = event->did;
tech_pvt->tid = event->tid;
+
+ if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ switch_clear_flag_locked(tech_pvt, TFLAG_USING_CODEC);
+ }
+
{
int rate = atoi(drate);
int ms = globals.codec_ms;
@@ -1823,11 +1841,17 @@
if (switch_test_flag(tech_pvt, TFLAG_RTP)) {
channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL);
- switch_channel_answer(channel);
+ if (pre_answer) {
+ switch_channel_pre_answer(channel);
+ } else {
+ switch_channel_answer(channel);
+ }
}
}
+
+
static const char *event_names[] = {
"EXOSIP_REGISTRATION_NEW",
"EXOSIP_REGISTRATION_SUCCESS",
@@ -2205,7 +2229,7 @@
/* This is like a 100 Trying... yeah */
break;
case EXOSIP_CALL_RINGING:
- //handle_ringing(event);
+ handle_answer(event);
break;
case EXOSIP_CALL_REDIRECTED:
break;
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Aug 22 17:08:34 2006
@@ -3203,7 +3203,7 @@
mlockall(MCL_CURRENT|MCL_FUTURE);
#endif
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "freeswitch Version %s Started. Crash Protection [%s] Max Sessions[%u]\n\n", SWITCH_VERSION_FULL, __CP, switch_core_session_limit(0));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\n\n", SWITCH_VERSION_FULL, __CP, switch_core_session_limit(0));
return SWITCH_STATUS_SUCCESS;
}
More information about the Freeswitch-svn
mailing list