[Freeswitch-svn] [commit] r2416 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Mon Aug 28 12:40:06 EDT 2006
Author: anthm
Date: Mon Aug 28 12:40:05 2006
New Revision: 2416
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
WIP
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon Aug 28 12:40:05 2006
@@ -52,6 +52,7 @@
#include <sofia-sip/nua.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/sdp.h>
+#include <sofia-sip/sip_protos.h>
#define DBFILE "sofia"
static const char modname[] = "mod_sofia";
@@ -167,6 +168,8 @@
switch_mutex_t *flag_mutex;
switch_payload_t te;
nua_handle_t *nh;
+ su_home_t *home;
+ sip_contact_t *contact;
};
/* Function Prototypes */
@@ -351,6 +354,10 @@
tech_pvt->profile = profile;
tech_pvt->te = profile->te;
tech_pvt->session = session;
+
+ tech_pvt->home = su_home_new(sizeof(*tech_pvt->home));
+ su_home_init(tech_pvt->home);
+
switch_core_session_set_private(session, tech_pvt);
tech_set_codecs(tech_pvt);
@@ -535,6 +542,10 @@
deactivate_rtp(tech_pvt);
+ su_home_deinit(tech_pvt->home);
+
+
+
if (tech_pvt->nh) {
if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
nua_bye(tech_pvt->nh, TAG_END());
@@ -712,7 +723,8 @@
set_local_sdp(tech_pvt);
activate_rtp(tech_pvt);
if (tech_pvt->nh) {
- nua_respond(tech_pvt->nh, SIP_200_OK, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
+ tech_pvt->contact = sip_contact_create(tech_pvt->home, URL_STRING_MAKE("sip:1000 at 208.64.200.40"), NULL);
+ nua_respond(tech_pvt->nh, SIP_200_OK, SIPTAG_CONTACT(tech_pvt->contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP:\n%s\n", tech_pvt->local_sdp_str);
}
}
@@ -987,7 +999,7 @@
tech_choose_port(tech_pvt);
set_local_sdp(tech_pvt);
activate_rtp(tech_pvt);
- nua_respond(tech_pvt->nh, SIP_183_SESSION_PROGRESS, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
+ nua_respond(tech_pvt->nh, SIP_183_SESSION_PROGRESS, SIPTAG_CONTACT(tech_pvt->contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
//nua_respond(tech_pvt->nh, SIP_200_OK, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
}
}
@@ -1203,8 +1215,7 @@
break;
case nua_callstate_proceeding:
if (session && r_sdp) {
- su_home_t home[1] = { SU_HOME_INIT(home) };
- sdp_parser_t *parser = sdp_parse(home, r_sdp, (int)strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
@@ -1218,9 +1229,6 @@
sdp_parser_free(parser);
}
- if (home) {
- su_home_deinit(home);
- }
if (match) {
tech_choose_port(tech_pvt);
@@ -1231,17 +1239,17 @@
}
}
switch_channel_set_variable(channel, "endpoint_disposition", "NO CODECS");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ nua_respond(nh, SIP_488_NOT_ACCEPTABLE, SIPTAG_CONTACT(tech_pvt->contact), TAG_END());
break;
case nua_callstate_completing:
nua_ack(nh, TAG_END());
break;
case nua_callstate_received:
if (session && r_sdp) {
- su_home_t home[1] = { SU_HOME_INIT(home) };
- sdp_parser_t *parser = sdp_parse(home, r_sdp, (int)strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
+
if (tech_pvt->num_codecs) {
if ((sdp = sdp_session(parser))) {
@@ -1253,12 +1261,9 @@
sdp_parser_free(parser);
}
- if (home) {
- su_home_deinit(home);
- }
if (match) {
- switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
+ switch_channel_set_variable(channel, "endpoint_disposition", "RECEIVED");
switch_channel_set_state(channel, CS_INIT);
switch_set_flag_locked(tech_pvt, TFLAG_READY);
switch_core_session_thread_launch(session);
@@ -1267,7 +1272,7 @@
}
}
switch_channel_set_variable(channel, "endpoint_disposition", "NO CODECS");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ nua_respond(nh, SIP_488_NOT_ACCEPTABLE, SIPTAG_CONTACT(tech_pvt->contact), TAG_END());
break;
case nua_callstate_early:
break;
@@ -1276,8 +1281,7 @@
case nua_callstate_ready:
if (session) {
if (r_sdp) {
- su_home_t home[1] = { SU_HOME_INIT(home) };
- sdp_parser_t *parser = sdp_parse(home, r_sdp, (int)strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int)strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
@@ -1291,11 +1295,9 @@
sdp_parser_free(parser);
}
- if (home) {
- su_home_deinit(home);
- }
if (match) {
+ switch_set_flag_locked(tech_pvt, TFLAG_ANS);
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
tech_choose_port(tech_pvt);
activate_rtp(tech_pvt);
@@ -1309,7 +1311,7 @@
}
}
switch_channel_set_variable(channel, "endpoint_disposition", "NO CODECS");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ nua_respond(nh, SIP_488_NOT_ACCEPTABLE, SIPTAG_CONTACT(tech_pvt->contact), TAG_END());
break;
case nua_callstate_terminating:
break;
More information about the Freeswitch-svn
mailing list