git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3384 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-11-16 15:50:17 +00:00
parent 394a188b7e
commit 594ccf8bb8
3 changed files with 173 additions and 152 deletions

View File

@ -264,9 +264,9 @@ ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, c
session->id = apr_pstrdup(session->pool, id);
session->them = apr_pstrdup(session->pool, them);
//if (me) {
//session->initiator = apr_pstrdup(session->pool, them);
//}
if (me) {
session->initiator = apr_pstrdup(session->pool, me);
}
if (ldl_test_flag(handle, LDL_FLAG_COMPONENT)) {
session->login = apr_pstrdup(session->pool, me);
@ -1468,14 +1468,29 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
}
static void add_elements(ldl_session_t *session, iks *tag)
{
apr_hash_index_t *hi;
for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) {
void *val = NULL;
const void *key = NULL;
apr_hash_this(hi, &key, NULL, &val);
if (val) {
iks *var = iks_insert(tag, "info_element");
iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie");
iks_insert_attrib(var, "name", (char *) key);
iks_insert_attrib(var, "value", (char *) val);
}
}
}
static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp, unsigned int *id, char *type)
{
iks *iq, *sess;
unsigned int myid;
char idbuf[80];
apr_hash_index_t *hi;
myid = next_id();
snprintf(idbuf, sizeof(idbuf), "%u", myid);
@ -1491,18 +1506,6 @@ static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp,
iks_insert_attrib(sess, "type", type);
iks_insert_attrib(sess, "id", session->id);
iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them);
for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) {
void *val = NULL;
const void *key = NULL;
apr_hash_this(hi, &key, NULL, &val);
if (val) {
iks *var = iks_insert(sess, "info_element");
iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie");
iks_insert_attrib(var, "name", (char *) key);
iks_insert_attrib(var, "value", (char *) val);
}
}
*sessp = sess;
*iqp = iq;
@ -1717,6 +1720,8 @@ unsigned int ldl_session_candidates(ldl_session_t *session,
new_session_iq(session, &iq, &sess, &id, "transport-info");
tag = iks_insert(sess, "transport");
iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");
add_elements(session, tag);
tag = iks_insert(tag, "candidate");
if (candidates[x].name) {

View File

@ -248,7 +248,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
}
rpid = translate_rpid(rpid, status);
ldl_handle_send_presence(profile->handle, sub_to, sub_from, "probe", rpid, status);
//ldl_handle_send_presence(profile->handle, sub_to, sub_from, "probe", rpid, status);
ldl_handle_send_presence(profile->handle, sub_to, sub_from, type, rpid, status);
@ -333,7 +333,6 @@ static void pres_event_handler(switch_event_t *event)
type, rpid, status, proto, from);
for (hi = switch_hash_first(apr_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
char *errmsg;
switch_hash_this(hi, NULL, NULL, &val);
@ -819,6 +818,7 @@ static int do_candidates(struct private_object *tech_pvt, int force)
cand[0].protocol = "udp";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
}
switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
@ -913,6 +913,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
started = switch_time_now();
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
tech_pvt->next_desc = switch_time_now();
} else {
tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
@ -1567,9 +1568,9 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session,
ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, user);
tech_pvt->profile = mdl_profile;
ldl_session_set_private(dlsession, *new_session);
ldl_session_set_value(dlsession, "dnis", dnis);
ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name);
ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
//ldl_session_set_value(dlsession, "dnis", dnis);
//ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name);
//ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
tech_pvt->dlsession = dlsession;
if (!get_codecs(tech_pvt)) {
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -2101,6 +2102,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
execute_sql(profile->dbname, sql, profile->mutex);
switch_core_db_free(sql);
}
if (is_special(to)) {
ldl_handle_send_presence(profile->handle, to, from, NULL, "unknown", "Click To Call");
}
#if 0
if (is_special(to)) {
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@ -2111,6 +2118,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_event_fire(&event);
}
}
#endif
break;
case LDL_SIGNAL_ROSTER:
if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
@ -2135,6 +2143,11 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_event_fire(&event);
}
if (is_special(to)) {
ldl_handle_send_presence(profile->handle, to, from, NULL, "unknown", "Click To Call");
}
#if 0
if (is_special(to)) {
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@ -2146,7 +2159,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
}
}
break;
#endif
case LDL_SIGNAL_PRESENCE_OUT:
if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
@ -2285,6 +2298,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
ldl_session_set_private(dlsession, session);
tech_pvt->dlsession = dlsession;
switch_channel_set_name(channel, "DingaLing/new");
switch_channel_set_state(channel, CS_INIT);
switch_core_session_thread_launch(session);
} else {
@ -2415,16 +2429,21 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
}
}
break;
case LDL_SIGNAL_CANDIDATES:
if (signal) {
ldl_candidate_t *candidates;
unsigned int len = 0;
if (ldl_session_get_candidates(dlsession, &candidates, &len) == LDL_STATUS_SUCCESS) {
unsigned int x;
if (ldl_session_get_candidates(dlsession, &candidates, &len) != LDL_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Candidate Error!\n");
switch_set_flag(tech_pvt, TFLAG_BYE);
switch_clear_flag(tech_pvt, TFLAG_IO);
status = LDL_STATUS_FALSE;
goto done;
}
if (tech_pvt->remote_ip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
@ -2468,6 +2487,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
ldl_session_accept_candidate(dlsession, &candidates[x]);
}
@ -2578,15 +2598,11 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
}
}
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
status = LDL_STATUS_SUCCESS;
goto done;
}
}
}
}
break;
case LDL_SIGNAL_ERROR:
case LDL_SIGNAL_TERMINATE:

View File

@ -765,7 +765,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
rtp_session->last_time = switch_time_now();
}
for(;;) {
while(rtp_session->ready) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);