Merge branch 'master' into smgmaster

This commit is contained in:
Konrad Hammel committed 2011-03-15 10:53:35 -04:00
commit c58a3db915
156 files changed
+6210 -4304

No files matched your search

+25 -10
View File
@@ -77,6 +77,7 @@ typedef enum {
TFLAG_TERM = (1 << 20),
TFLAG_TRANSPORT_ACCEPT = (1 << 21),
TFLAG_READY = (1 << 22),
TFLAG_NAT_MAP = (1 << 22)
} TFLAGS;
typedef enum {
@@ -158,6 +159,7 @@ struct private_object {
ldl_session_t *dlsession;
char *remote_ip;
switch_port_t local_port;
switch_port_t adv_local_port;
switch_port_t remote_port;
char local_user[17];
char local_pass[17];
@@ -596,9 +598,9 @@ static void ipchanged_event_handler(switch_event_t *event)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n");
if (cond && !strcmp(cond, "network-address-change")) {
const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4");
const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4");
if (cond && !strcmp(cond, "network-external-address-change")) {
const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4");
const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4");
switch_hash_index_t *hi;
void *val;
char *tmp;
@@ -886,11 +888,22 @@ static int activate_rtp(struct private_object *tech_pvt)
if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
switch_port_t external_port = 0;
switch_nat_add_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE);
tech_pvt->local_port = external_port;
if (external_port) {
tech_pvt->adv_local_port = external_port;
switch_set_flag(tech_pvt, TFLAG_NAT_MAP);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "NAT mapping returned 0. Run freeswitch with -nonat since it's not working right.\n");
}
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
if (tech_pvt->adv_local_port != tech_pvt->local_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d(%d) -> %s:%d\n", tech_pvt->profile->ip,
tech_pvt->local_port, tech_pvt->adv_local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
}
flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
@@ -964,7 +977,7 @@ static int do_candidates(struct private_object *tech_pvt, int force)
}
cand[0].port = tech_pvt->local_port;
cand[0].port = tech_pvt->adv_local_port;
cand[0].address = advip;
if (!strncasecmp(advip, "stun:", 5)) {
@@ -1253,9 +1266,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
tech_pvt->rtp_session = NULL;
}
if (globals.auto_nat && tech_pvt->profile->local_network && tech_pvt->remote_ip && tech_pvt->profile->local_network &&
!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
switch_nat_del_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP);
if (switch_test_flag(tech_pvt, TFLAG_NAT_MAP)) {
switch_nat_del_mapping((switch_port_t) tech_pvt->adv_local_port, SWITCH_NAT_UDP);
switch_clear_flag(tech_pvt, TFLAG_NAT_MAP);
}
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
@@ -1751,6 +1764,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
tech_pvt->adv_local_port = tech_pvt->local_port;
tech_pvt->recip = switch_core_session_strdup(*new_session, full_id);
if (dnis) {
tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis);
@@ -2992,6 +3006,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
status = LDL_STATUS_FALSE;
goto done;
}
tech_pvt->adv_local_port = tech_pvt->local_port;
switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
tech_pvt->recip = switch_core_session_strdup(session, from);
if (!(exten = ldl_session_get_value(dlsession, "dnis"))) {
+48 -6
View File
@@ -651,7 +651,7 @@ int channel_on_routing_callback(void *pArg, int argc, char **argv, char **column
} else {
send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON);
skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY);
send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, 10, 0xffff);
send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, SKINNY_KEY_SET_IN_USE_HINT, 0xffff);
send_display_prompt_status(listener, 0, SKINNY_DISP_IN_USE_REMOTE,
line_instance, helper->tech_pvt->call_id);
skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance);
@@ -1243,6 +1243,21 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt)
switch_mutex_unlock(globals.mutex);
}
static int flush_listener_callback(void *pArg, int argc, char **argv, char **columnNames)
{
char *profile_name = argv[0];
char *value = argv[1];
char *domain_name = argv[2];
char *device_name = argv[3];
char *device_instance = argv[4];
char *token = switch_mprintf("skinny/%q/%q/%q:%q", profile_name, value, device_name, device_instance);
switch_core_del_registration(value, domain_name, token);
switch_safe_free(token);
return 0;
}
static void flush_listener(listener_t *listener)
{
@@ -1250,6 +1265,18 @@ static void flush_listener(listener_t *listener)
skinny_profile_t *profile = listener->profile;
char *sql;
if ((sql = switch_mprintf(
"SELECT '%q', value, '%q', '%q', '%d' "
"FROM skinny_lines "
"WHERE device_name='%s' AND device_instance=%d "
"ORDER BY position",
profile->name, profile->domain, listener->device_name, listener->device_instance,
listener->device_name, listener->device_instance
))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL);
switch_safe_free(sql);
}
if ((sql = switch_mprintf(
"DELETE FROM skinny_devices "
"WHERE name='%s' and instance=%d",
@@ -1488,6 +1515,8 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void
listener_t *listener;
switch_memory_pool_t *tmp_pool = NULL, *listener_pool = NULL;
uint32_t errs = 0;
switch_sockaddr_t *local_sa = NULL;
switch_sockaddr_t *remote_sa =NULL;
if (switch_core_new_memory_pool(&tmp_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
@@ -1496,8 +1525,9 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void
new_socket:
while(globals.running) {
char *listening_ip = NULL;
switch_clear_flag_locked(profile, PFLAG_RESPAWN);
rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_INET, profile->port, 0, tmp_pool);
rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool);
if (rv)
goto fail;
rv = switch_socket_create(&profile->sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, tmp_pool);
@@ -1512,6 +1542,10 @@ new_socket:
rv = switch_socket_listen(profile->sock, 5);
if (rv)
goto sock_fail;
switch_sockaddr_ip_get(&listening_ip, sa);
if (!profile->ip || strcmp(listening_ip, profile->ip)) {
profile->ip = switch_core_strdup(profile->pool, listening_ip);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Socket up listening on %s:%u\n", profile->ip, profile->port);
break;
@@ -1566,9 +1600,14 @@ new_socket:
switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock);
switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa);
listener->remote_port = switch_sockaddr_get_port(listener->sa);
switch_socket_addr_get(&remote_sa, SWITCH_TRUE, listener->sock);
switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), remote_sa);
listener->remote_port = switch_sockaddr_get_port(remote_sa);
switch_socket_addr_get(&local_sa, SWITCH_FALSE, listener->sock);
switch_get_addr(listener->local_ip, sizeof(listener->local_ip), local_sa);
listener->local_port = switch_sockaddr_get_port(local_sa);
launch_listener_thread(listener);
}
@@ -1636,7 +1675,7 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c
profile->domain = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "ip")) {
if (!profile->ip || strcmp(val, profile->ip)) {
profile->ip = switch_core_strdup(profile->pool, val);
profile->ip = switch_core_strdup(profile->pool, zstr(val) ? NULL : val);
switch_set_flag_locked(profile, PFLAG_SHOULD_RESPAWN);
}
} else if (!strcasecmp(var, "port")) {
@@ -1784,6 +1823,9 @@ static switch_status_t load_skinny_config(void)
size_t string_len = strlen(val);
size_t string_pos, start = 0;
int field_no = 0;
if (zstr(val)) {
continue;
}
if (soft_key_set_id > 15) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"soft-key-set name '%s' is greater than 15 in soft-key-set-set '%s' in profile %s.\n",
+16 -16
View File
@@ -132,25 +132,25 @@ typedef enum {
#define SKINNY_MAX_LINES 42
struct listener {
skinny_profile_t *profile;
char device_name[16];
uint32_t device_instance;
uint32_t device_type;
skinny_profile_t *profile;
char device_name[16];
uint32_t device_instance;
uint32_t device_type;
char firmware_version[16];
char *soft_key_set_set;
switch_socket_t *sock;
switch_memory_pool_t *pool;
switch_thread_rwlock_t *rwlock;
switch_sockaddr_t *sa;
char remote_ip[50];
switch_mutex_t *flag_mutex;
uint32_t flags;
switch_port_t remote_port;
uint32_t id;
time_t expire_time;
struct listener *next;
switch_socket_t *sock;
switch_memory_pool_t *pool;
switch_thread_rwlock_t *rwlock;
char remote_ip[50];
switch_port_t remote_port;
char local_ip[50];
switch_port_t local_port;
switch_mutex_t *flag_mutex;
uint32_t flags;
time_t expire_time;
struct listener *next;
};
typedef struct listener listener_t;
@@ -43,10 +43,10 @@ char* skinny_codec2string(enum skinny_codecs skinnycodec)
switch (skinnycodec) {
case SKINNY_CODEC_ALAW_64K:
case SKINNY_CODEC_ALAW_56K:
return "ALAW";
return "PCMA";
case SKINNY_CODEC_ULAW_64K:
case SKINNY_CODEC_ULAW_56K:
return "ULAW";
return "PCMU";
case SKINNY_CODEC_G722_64K:
case SKINNY_CODEC_G722_56K:
case SKINNY_CODEC_G722_48K:
+88 -67
View File
@@ -97,6 +97,12 @@ struct PACKED on_hook_message {
uint32_t call_id;
};
/* ForwardStatReqMessage */
#define FORWARD_STAT_REQ_MESSAGE 0x0009
struct PACKED forward_stat_req_message {
uint32_t line_instance;
};
/* SpeedDialStatReqMessage */
#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
struct PACKED speed_dial_stat_req_message {
@@ -125,7 +131,7 @@ struct PACKED line_stat_req_message {
#define CAPABILITIES_RES_MESSAGE 0x0010
struct PACKED station_capabilities {
uint32_t codec;
uint16_t frames;
uint16_t max_frames_per_packet;
char reserved[10];
};
@@ -328,6 +334,19 @@ struct PACKED call_info_message {
uint32_t party_pi_restriction_bits;
};
/* ForwardStatMessage */
#define FORWARD_STAT_MESSAGE 0x0090
struct PACKED forward_stat_message {
uint32_t active_forward;
uint32_t line_instance;
uint32_t forward_all_active;
char forward_all_number[24];
uint32_t forward_busy_active;
char forward_busy_number[24];
uint32_t forward_noanswer_active;
char forward_noanswer_number[24];
};
/* SpeedDialStatMessage */
#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
struct PACKED speed_dial_stat_res_message {
@@ -566,76 +585,78 @@ struct PACKED service_url_stat_res_message {
union skinny_data {
/* no data for KEEP_ALIVE_MESSAGE */
struct register_message reg;
struct port_message port;
struct keypad_button_message keypad_button;
struct enbloc_call_message enbloc_call;
struct stimulus_message stimulus;
struct off_hook_message off_hook;
struct on_hook_message on_hook;
struct speed_dial_stat_req_message speed_dial_req;
struct line_stat_req_message line_req;
/* no data for CONFIG_STAT_REQ_MESSAGE */
/* no data for TIME_DATE_REQ_MESSAGE */
/* no data for BUTTON_TEMPLATE_REQ_MESSAGE */
/* no data for VERSION_REQ_MESSAGE */
struct capabilities_res_message cap_res;
struct alarm_message alarm;
struct open_receive_channel_ack_message open_receive_channel_ack;
/* no data for SOFT_KEY_SET_REQ_MESSAGE */
struct soft_key_event_message soft_key_event;
/* no data for UNREGISTER_MESSAGE */
/* no data for SOFT_KEY_TEMPLATE_REQ_MESSAGE */
struct headset_status_message headset_status;
struct register_available_lines_message reg_lines;
/* see field "data" for DEVICE_TO_USER_DATA_MESSAGE */
/* see field "data" for DEVICE_TO_USER_DATA_RESPONSE_MESSAGE */
struct service_url_stat_req_message service_url_req;
struct feature_stat_req_message feature_req;
/* see field "extended_data" for DEVICE_TO_USER_DATA_VERSION1_MESSAGE */
/* see field "extended_data" for DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE */
struct register_ack_message reg_ack;
struct start_tone_message start_tone;
struct stop_tone_message stop_tone;
struct set_ringer_message ringer;
struct set_lamp_message lamp;
struct set_speaker_mode_message speaker_mode;
struct start_media_transmission_message start_media;
struct stop_media_transmission_message stop_media;
struct call_info_message call_info;
struct speed_dial_stat_res_message speed_dial_res;
struct line_stat_res_message line_res;
struct config_stat_res_message config_res;
struct define_time_date_message define_time_date;
struct button_template_message button_template;
struct version_message version;
/* no data for CAPABILITIES_REQ_MESSAGE */
struct register_reject_message reg_rej;
struct reset_message reset;
/* no data for KEEP_ALIVE_ACK_MESSAGE */
struct open_receive_channel_message open_receive_channel;
struct close_receive_channel_message close_receive_channel;
struct soft_key_template_res_message soft_key_template;
struct soft_key_set_res_message soft_key_set;
struct select_soft_keys_message select_soft_keys;
struct call_state_message call_state;
struct display_prompt_status_message display_prompt_status;
struct clear_prompt_status_message clear_prompt_status;
struct activate_call_plane_message activate_call_plane;
struct unregister_ack_message unregister_ack;
struct back_space_req_message back_space_req;
struct dialed_number_message dialed_number;
/* see field "data" for USER_TO_DEVICE_DATA_MESSAGE */
struct feature_stat_res_message feature_res;
struct display_pri_notify_message display_pri_notify;
struct service_url_stat_res_message service_url_res;
/* see field "extended_data" for USER_TO_DEVICE_DATA_VERSION1_MESSAGE */
struct register_message reg;
struct port_message port;
struct keypad_button_message keypad_button;
struct enbloc_call_message enbloc_call;
struct stimulus_message stimulus;
struct off_hook_message off_hook;
struct on_hook_message on_hook;
struct forward_stat_req_message forward_stat_req;
struct speed_dial_stat_req_message speed_dial_req;
struct line_stat_req_message line_req;
/* no data for CONFIG_STAT_REQ_MESSAGE */
/* no data for TIME_DATE_REQ_MESSAGE */
/* no data for BUTTON_TEMPLATE_REQ_MESSAGE */
/* no data for VERSION_REQ_MESSAGE */
struct capabilities_res_message cap_res;
struct alarm_message alarm;
struct open_receive_channel_ack_message open_receive_channel_ack;
/* no data for SOFT_KEY_SET_REQ_MESSAGE */
struct soft_key_event_message soft_key_event;
/* no data for UNREGISTER_MESSAGE */
/* no data for SOFT_KEY_TEMPLATE_REQ_MESSAGE */
struct headset_status_message headset_status;
struct register_available_lines_message reg_lines;
/* see field "data" for DEVICE_TO_USER_DATA_MESSAGE */
/* see field "data" for DEVICE_TO_USER_DATA_RESPONSE_MESSAGE */
struct service_url_stat_req_message service_url_req;
struct feature_stat_req_message feature_req;
/* see field "extended_data" for DEVICE_TO_USER_DATA_VERSION1_MESSAGE */
/* see field "extended_data" for DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE */
struct register_ack_message reg_ack;
struct start_tone_message start_tone;
struct stop_tone_message stop_tone;
struct set_ringer_message ringer;
struct set_lamp_message lamp;
struct set_speaker_mode_message speaker_mode;
struct start_media_transmission_message start_media;
struct stop_media_transmission_message stop_media;
struct call_info_message call_info;
struct forward_stat_message forward_stat;
struct speed_dial_stat_res_message speed_dial_res;
struct line_stat_res_message line_res;
struct config_stat_res_message config_res;
struct define_time_date_message define_time_date;
struct button_template_message button_template;
struct version_message version;
/* no data for CAPABILITIES_REQ_MESSAGE */
struct register_reject_message reg_rej;
struct reset_message reset;
/* no data for KEEP_ALIVE_ACK_MESSAGE */
struct open_receive_channel_message open_receive_channel;
struct close_receive_channel_message close_receive_channel;
struct soft_key_template_res_message soft_key_template;
struct soft_key_set_res_message soft_key_set;
struct select_soft_keys_message select_soft_keys;
struct call_state_message call_state;
struct display_prompt_status_message display_prompt_status;
struct clear_prompt_status_message clear_prompt_status;
struct activate_call_plane_message activate_call_plane;
struct unregister_ack_message unregister_ack;
struct back_space_req_message back_space_req;
struct dialed_number_message dialed_number;
/* see field "data" for USER_TO_DEVICE_DATA_MESSAGE */
struct feature_stat_res_message feature_res;
struct display_pri_notify_message display_pri_notify;
struct service_url_stat_res_message service_url_res;
/* see field "extended_data" for USER_TO_DEVICE_DATA_VERSION1_MESSAGE */
struct data_message data;
struct extended_data_message extended_data;
uint16_t as_uint16;
char as_char[1];
uint16_t as_uint16;
char as_char[1];
};
/*
+31 -2
View File
@@ -555,6 +555,7 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN
skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance);
send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_BLINK);
send_set_ringer(listener, SKINNY_RING_INSIDE, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id);
switch_channel_mark_ring_ready(channel);
}
return 0;
}
@@ -1006,6 +1007,10 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
}
if ((xbuttons = switch_xml_child(xskinny, "buttons"))) {
uint32_t line_instance = 1;
char *network_ip = inet_ntoa(request->data.reg.ip);
int network_port = 0;
char network_port_c[6];
snprintf(network_port_c, sizeof(network_port_c), "%d", network_port);
for (xbutton = switch_xml_child(xbuttons, "button"); xbutton; xbutton = xbutton->next) {
uint32_t position = atoi(switch_xml_attr_soft(xbutton, "position"));
uint32_t type = skinny_str2button(switch_xml_attr_soft(xbutton, "type"));
@@ -1031,8 +1036,14 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
label, value, caller_name,
ring_on_idle, ring_on_active, busy_trigger,
forward_all, forward_busy, forward_noanswer, noanswer_duration))) {
char *token, *url;
skinny_execute_sql(profile, sql, profile->sql_mutex);
switch_safe_free(sql);
token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance);
url = switch_mprintf("skinny/%q/%q", profile->name, value);
switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp");
switch_safe_free(token);
switch_safe_free(url);
}
if (line_instance == 1) {
switch_event_t *message_query_event = NULL;
@@ -1318,6 +1329,22 @@ switch_status_t skinny_handle_on_hook_message(listener_t *listener, skinny_messa
return status;
}
switch_status_t skinny_handle_forward_stat_req_message(listener_t *listener, skinny_message_t *request)
{
skinny_message_t *message;
skinny_check_data_length(request, sizeof(request->data.forward_stat_req));
message = switch_core_alloc(listener->pool, 12+sizeof(message->data.forward_stat));
message->type = FORWARD_STAT_MESSAGE;
message->length = 4 + sizeof(message->data.forward_stat);
message->data.forward_stat.line_instance = request->data.forward_stat_req.line_instance;
skinny_send_reply(listener, message);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t skinny_handle_speed_dial_stat_request(listener_t *listener, skinny_message_t *request)
{
@@ -1649,12 +1676,12 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste
goto end;
}
tech_pvt->local_sdp_audio_ip = listener->local_ip;
/* Request a local port from the core's allocator */
if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(listener->profile->ip))) {
if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(tech_pvt->local_sdp_audio_ip))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "No RTP ports available!\n");
return SWITCH_STATUS_FALSE;
}
tech_pvt->local_sdp_audio_ip = switch_core_strdup(switch_core_session_get_pool(session), listener->profile->ip);
tech_pvt->remote_sdp_audio_ip = inet_ntoa(request->data.open_receive_channel_ack.ip);
tech_pvt->remote_sdp_audio_port = request->data.open_receive_channel_ack.port;
@@ -2035,6 +2062,8 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
return skinny_handle_off_hook_message(listener, request);
case ON_HOOK_MESSAGE:
return skinny_handle_on_hook_message(listener, request);
case FORWARD_STAT_REQ_MESSAGE:
return skinny_handle_forward_stat_req_message(listener, request);
case SPEED_DIAL_STAT_REQ_MESSAGE:
return skinny_handle_speed_dial_stat_request(listener, request);
case LINE_STAT_REQ_MESSAGE:
+70 -67
View File
@@ -35,73 +35,75 @@
/* Translation tables */
struct skinny_table SKINNY_MESSAGE_TYPES[] = {
{"KeepAliveMessage", KEEP_ALIVE_MESSAGE},
{"RegisterMessage", REGISTER_MESSAGE},
{"PortMessage", PORT_MESSAGE},
{"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE},
{"EnblocCallMessage", ENBLOC_CALL_MESSAGE},
{"StimulusMessage", STIMULUS_MESSAGE},
{"OffHookMessage", OFF_HOOK_MESSAGE},
{"OnHookMessage", ON_HOOK_MESSAGE},
{"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE},
{"LineStatReqMessage", LINE_STAT_REQ_MESSAGE},
{"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE},
{"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE},
{"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE},
{"VersionReqMessage", VERSION_REQ_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE},
{"AlarmMessage", ALARM_MESSAGE},
{"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE},
{"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE},
{"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE},
{"UnregisterMessage", UNREGISTER_MESSAGE},
{"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE},
{"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE},
{"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE},
{"DeviceToUserDataMessage", DEVICE_TO_USER_DATA_MESSAGE},
{"DeviceToUserDataResponseMessage", DEVICE_TO_USER_DATA_RESPONSE_MESSAGE},
{"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE},
{"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE},
{"DeviceToUserDataVersion1Message", DEVICE_TO_USER_DATA_VERSION1_MESSAGE},
{"DeviceToUserDataResponseVersion1Message", DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE},
{"RegisterAckMessage", REGISTER_ACK_MESSAGE},
{"StartToneMessage", START_TONE_MESSAGE},
{"StopToneMessage", STOP_TONE_MESSAGE},
{"SetRingerMessage", SET_RINGER_MESSAGE},
{"SetLampMessage", SET_LAMP_MESSAGE},
{"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE},
{"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE},
{"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE},
{"CallInfoMessage", CALL_INFO_MESSAGE},
{"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE},
{"LineStatResMessage", LINE_STAT_RES_MESSAGE},
{"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE},
{"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE},
{"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE},
{"VersionMessage", VERSION_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE},
{"RegisterRejectMessage", REGISTER_REJECT_MESSAGE},
{"ResetMessage", RESET_MESSAGE},
{"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE},
{"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE},
{"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE},
{"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE},
{"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE},
{"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE},
{"CallStateMessage", CALL_STATE_MESSAGE},
{"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE},
{"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE},
{"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE},
{"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE},
{"BackSpaceReqMessage", BACK_SPACE_REQ_MESSAGE},
{"DialedNumberMessage", DIALED_NUMBER_MESSAGE},
{"UserToDeviceDataMessage", USER_TO_DEVICE_DATA_MESSAGE},
{"FeatureResMessage", FEATURE_STAT_RES_MESSAGE},
{"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE},
{"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE},
{"UserToDeviceDataVersion1Message", USER_TO_DEVICE_DATA_VERSION1_MESSAGE},
{"XMLAlarmMessage", XML_ALARM_MESSAGE},
{NULL, 0}
{"KeepAliveMessage", KEEP_ALIVE_MESSAGE},
{"RegisterMessage", REGISTER_MESSAGE},
{"PortMessage", PORT_MESSAGE},
{"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE},
{"EnblocCallMessage", ENBLOC_CALL_MESSAGE},
{"StimulusMessage", STIMULUS_MESSAGE},
{"OffHookMessage", OFF_HOOK_MESSAGE},
{"OnHookMessage", ON_HOOK_MESSAGE},
{"ForwardStatReqMessage", FORWARD_STAT_REQ_MESSAGE},
{"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE},
{"LineStatReqMessage", LINE_STAT_REQ_MESSAGE},
{"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE},
{"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE},
{"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE},
{"VersionReqMessage", VERSION_REQ_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE},
{"AlarmMessage", ALARM_MESSAGE},
{"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE},
{"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE},
{"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE},
{"UnregisterMessage", UNREGISTER_MESSAGE},
{"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE},
{"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE},
{"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE},
{"DeviceToUserDataMessage", DEVICE_TO_USER_DATA_MESSAGE},
{"DeviceToUserDataResponseMessage", DEVICE_TO_USER_DATA_RESPONSE_MESSAGE},
{"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE},
{"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE},
{"DeviceToUserDataVersion1Message", DEVICE_TO_USER_DATA_VERSION1_MESSAGE},
{"DeviceToUserDataResponseVersion1Message", DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE},
{"RegisterAckMessage", REGISTER_ACK_MESSAGE},
{"StartToneMessage", START_TONE_MESSAGE},
{"StopToneMessage", STOP_TONE_MESSAGE},
{"SetRingerMessage", SET_RINGER_MESSAGE},
{"SetLampMessage", SET_LAMP_MESSAGE},
{"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE},
{"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE},
{"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE},
{"CallInfoMessage", CALL_INFO_MESSAGE},
{"ForwardStatMessage", FORWARD_STAT_MESSAGE},
{"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE},
{"LineStatResMessage", LINE_STAT_RES_MESSAGE},
{"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE},
{"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE},
{"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE},
{"VersionMessage", VERSION_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE},
{"RegisterRejectMessage", REGISTER_REJECT_MESSAGE},
{"ResetMessage", RESET_MESSAGE},
{"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE},
{"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE},
{"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE},
{"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE},
{"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE},
{"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE},
{"CallStateMessage", CALL_STATE_MESSAGE},
{"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE},
{"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE},
{"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE},
{"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE},
{"BackSpaceReqMessage", BACK_SPACE_REQ_MESSAGE},
{"DialedNumberMessage", DIALED_NUMBER_MESSAGE},
{"UserToDeviceDataMessage", USER_TO_DEVICE_DATA_MESSAGE},
{"FeatureResMessage", FEATURE_STAT_RES_MESSAGE},
{"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE},
{"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE},
{"UserToDeviceDataVersion1Message", USER_TO_DEVICE_DATA_VERSION1_MESSAGE},
{"XMLAlarmMessage", XML_ALARM_MESSAGE},
{NULL, 0}
};
SKINNY_DECLARE_ID2STR(skinny_message_type2str, SKINNY_MESSAGE_TYPES, "UnknownMessage")
SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1)
@@ -216,6 +218,7 @@ struct skinny_table SKINNY_KEY_SETS[] = {
{"KeySetConnectedWithConference", SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE},
{"KeySetRingOut", SKINNY_KEY_SET_RING_OUT},
{"KeySetOffHookWithFeatures", SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES},
{"KeySetInUseHint", SKINNY_KEY_SET_IN_USE_HINT},
{NULL, 0}
};
SKINNY_DECLARE_ID2STR(skinny_soft_key_set2str, SKINNY_KEY_SETS, "UNKNOWN_SOFT_KEY_SET")
+3 -2
View File
@@ -87,7 +87,7 @@ uint32_t func(const char *str)\
}
extern struct skinny_table SKINNY_MESSAGE_TYPES[67];
extern struct skinny_table SKINNY_MESSAGE_TYPES[69];
const char *skinny_message_type2str(uint32_t id);
uint32_t skinny_str2message_type(const char *str);
#define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES)
@@ -210,8 +210,9 @@ enum skinny_key_set {
SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7,
SKINNY_KEY_SET_RING_OUT = 8,
SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9,
SKINNY_KEY_SET_IN_USE_HINT = 10,
};
extern struct skinny_table SKINNY_KEY_SETS[11];
extern struct skinny_table SKINNY_KEY_SETS[12];
const char *skinny_soft_key_set2str(uint32_t id);
uint32_t skinny_str2soft_key_set(const char *str);
#define SKINNY_PUSH_SOFT_KEY_SETS SKINNY_DECLARE_PUSH_MATCH(SKINNY_KEY_SETS)
+46 -11
View File
@@ -1349,10 +1349,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER:
{
if (switch_rtp_ready(tech_pvt->rtp_session)) {
int len, maxlen = 0, qlen = 0, maxqlen = 50;
int len, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0;
if (msg->string_arg) {
char *p;
char *p, *q;
const char *s;
if (!strcasecmp(msg->string_arg, "pause")) {
@@ -1379,6 +1379,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if ((p = strchr(msg->string_arg, ':'))) {
p++;
maxlen = atol(p);
if ((q = strchr(p, ':'))) {
q++;
max_drift = abs(atol(q));
}
}
}
@@ -1391,9 +1395,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (qlen) {
if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen,
tech_pvt->read_impl.samples_per_packet,
tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) {
tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n", len, qlen, maxqlen);
SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)\n",
len, qlen, maxqlen, max_drift);
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
@@ -1439,10 +1444,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_BRIDGE:
{
const char *var = switch_channel_get_variable(tech_pvt->channel, "sip_jitter_buffer_during_bridge");
sofia_glue_tech_track(tech_pvt->profile, session);
sofia_glue_tech_simplify(tech_pvt);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if (switch_false(var) && switch_rtp_ready(tech_pvt->rtp_session)) {
const char *val;
int ok = 0;
@@ -1477,6 +1485,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
const char *val;
int ok = 0;
sofia_glue_tech_track(tech_pvt->profile, session);
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s RESUME Jitterbuffer\n", switch_channel_get_name(channel));
@@ -3515,7 +3525,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
profile = sofia_glue_find_profile(profile_name);
}
if (!profile) {
if (!profile && !zstr(domain)) {
profile = sofia_glue_find_profile(domain);
}
}
@@ -4682,17 +4692,42 @@ static void general_event_handler(switch_event_t *event)
case SWITCH_EVENT_TRAP:
{
const char *cond = switch_event_get_header(event, "condition");
switch_hash_index_t *hi;
const void *var;
void *val;
sofia_profile_t *profile;
if (zstr(cond)) {
cond = "";
}
if (cond && !strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) {
if (!strcmp(cond, "network-external-address-change") && mod_sofia_globals.auto_restart) {
const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4");
const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4");
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (mod_sofia_globals.profile_hash && !zstr(old_ip4) && !zstr(new_ip4)) {
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &var, NULL, &val);
if ((profile = (sofia_profile_t *) val)) {
if (!zstr(profile->extsipip) && !strcmp(profile->extsipip, old_ip4)) {
profile->extsipip = switch_core_strdup(profile->pool, new_ip4);
}
if (!zstr(profile->extrtpip) && !strcmp(profile->extrtpip, old_ip4)) {
profile->extrtpip = switch_core_strdup(profile->pool, new_ip4);
}
}
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
sofia_glue_restart_all_profiles();
} else if (!strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) {
const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4");
const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4");
const char *old_ip6 = switch_event_get_header_nil(event, "network-address-previous-v6");
const char *new_ip6 = switch_event_get_header_nil(event, "network-address-change-v6");
switch_hash_index_t *hi;
const void *var;
void *val;
sofia_profile_t *profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IP change detected [%s]->[%s] [%s]->[%s]\n", old_ip4, new_ip4, old_ip6, new_ip6);
+8 -2
View File
@@ -864,7 +864,6 @@ void sofia_event_callback(nua_event_t event,
case nua_r_unsubscribe:
case nua_r_publish:
case nua_i_cancel:
case nua_r_cancel:
case nua_i_error:
case nua_i_active:
case nua_i_terminated:
@@ -872,6 +871,13 @@ void sofia_event_callback(nua_event_t event,
case nua_i_prack:
case nua_r_prack:
break;
case nua_r_cancel:
{
if (status > 299 && nh) {
nua_handle_destroy(nh);
}
}
break;
case nua_i_ack:
{
if (channel && sip) {
@@ -2135,7 +2141,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
register_transport = (char *) sofia_glue_transport2str(gateway->register_transport);
if (contact_params) {
if (! zstr(contact_params)) {
if (*contact_params == ';') {
params = switch_core_sprintf(gateway->pool, "%s;transport=%s;gw=%s", contact_params, register_transport, gateway->name);
} else {
+126 -61
View File
@@ -3166,12 +3166,16 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec")) || (val = tech_pvt->profile->jb_msec)) {
int jb_msec = atoi(val);
int maxlen = 0;
char *p;
int maxlen = 0, max_drift = 0;
char *p, *q;
if ((p = strchr(val, ':'))) {
p++;
maxlen = atoi(p);
if ((q = strchr(p, ':'))) {
q++;
max_drift = abs(atoi(q));
}
}
if (jb_msec < 20 || jb_msec > 10000) {
@@ -3188,7 +3192,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen,
tech_pvt->read_impl.samples_per_packet,
tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) {
tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen);
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);
@@ -3238,7 +3242,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
}
if (tech_pvt->audio_recv_pt != tech_pvt->agreed_pt) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "Set audio receive payload to %u\n", tech_pvt->audio_recv_pt);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
"%s Set audio receive payload to %u\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->audio_recv_pt);
switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->audio_recv_pt);
}
@@ -3423,8 +3429,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (tech_pvt->video_recv_pt != tech_pvt->video_agreed_pt) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
"Set video receive payload to %u\n", tech_pvt->video_recv_pt);
switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->video_recv_pt);
"%s Set video receive payload to %u\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->video_recv_pt);
switch_rtp_set_recv_pt(tech_pvt->video_rtp_session, tech_pvt->video_recv_pt);
}
switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_video_pt", "%d", tech_pvt->video_agreed_pt);
@@ -3484,6 +3490,59 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
}
static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size_t buflen)
{
int codec_ms = ptime;
uint32_t map_bit_rate = 0;
char ptstr[20] = "";
char ratestr[20] = "";
char bitstr[20] = "";
switch_codec_fmtp_t codec_fmtp = { 0 };
if (!codec_ms) {
codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt);
}
map_bit_rate = switch_known_bitrate(map->rm_pt);
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
ptime = codec_ms = 30;
}
if (zstr(map->rm_fmtp)) {
if (!strcasecmp(map->rm_encoding, "ilbc")) {
ptime = codec_ms = 30;
map_bit_rate = 13330;
}
} else {
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
if (codec_fmtp.bits_per_second) {
map_bit_rate = codec_fmtp.bits_per_second;
}
if (codec_fmtp.microseconds_per_packet) {
codec_ms = (codec_fmtp.microseconds_per_packet / 1000);
}
}
}
if (map->rm_rate) {
switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate);
}
if (codec_ms) {
switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms);
}
if (map_bit_rate) {
switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate);
}
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
}
void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp)
{
char buf[1024] = { 0 };
@@ -3500,7 +3559,13 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 };
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = switch_core_session_get_private(session);
int prefer_sdp = 0;
const char *var;
if ((var = switch_channel_get_variable(channel, "ep_codec_prefer_sdp")) && switch_true(var)) {
prefer_sdp = 1;
}
if (!zstr(codec_string)) {
char *tmp_codec_string;
if ((tmp_codec_string = strdup(codec_string))) {
@@ -3551,78 +3616,62 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
break;
}
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) {
continue;
}
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
for (map = m->m_rtpmaps; map; map = map->rm_next) {
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
if (map->rm_encoding) {
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
match = 0;
if (map->rm_encoding) {
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
} else {
match = 0;
}
}
if (match) {
add_audio_codec(map, ptime, buf, sizeof(buf));
break;
}
}
}
if (match) {
int codec_ms = ptime;
uint32_t map_bit_rate = 0;
char ptstr[20] = "";
char ratestr[20] = "";
char bitstr[20] = "";
switch_codec_fmtp_t codec_fmtp = { 0 };
if (!codec_ms) {
codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt);
} else {
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) {
continue;
}
for (map = m->m_rtpmaps; map; map = map->rm_next) {
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
map_bit_rate = switch_known_bitrate(map->rm_pt);
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
ptime = codec_ms = 30;
}
if (zstr(map->rm_fmtp)) {
if (!strcasecmp(map->rm_encoding, "ilbc")) {
ptime = codec_ms = 30;
map_bit_rate = 13330;
}
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
if (codec_fmtp.bits_per_second) {
map_bit_rate = codec_fmtp.bits_per_second;
}
if (codec_fmtp.microseconds_per_packet) {
codec_ms = (codec_fmtp.microseconds_per_packet / 1000);
}
if (map->rm_encoding) {
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
} else {
match = 0;
}
}
if (map->rm_rate) {
switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate);
if (match) {
add_audio_codec(map, ptime, buf, sizeof(buf));
break;
}
if (codec_ms) {
switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms);
}
if (map_bit_rate) {
switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate);
}
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
break;
}
}
}
} else if (m->m_type == sdp_media_video && m->m_port) {
connection = sdp->sdp_connection;
if (m->m_connections) {
@@ -3814,6 +3863,7 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
{
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
sdp_attribute_t *attr;
const char *var;
if (!t38_options) {
t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
@@ -3893,6 +3943,21 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38);
if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_execute_on_image"))) {
char *app, *arg = NULL;
app = switch_core_session_strdup(tech_pvt->session, var);
if (strstr(app, "::")) {
switch_core_session_execute_application_async(tech_pvt->session, app, arg);
} else {
if ((arg = strchr(app, ' '))) {
*arg++ = '\0';
}
switch_core_session_execute_application(tech_pvt->session, app, arg);
}
}
return t38_options;
}
@@ -5166,7 +5231,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
tech_pvt->local_sdp_str = switch_core_session_strdup(session, tmp);
}
if ((tmp = switch_channel_get_variable(channel, "switch_r_sdp"))) {
if ((tmp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE))) {
tech_pvt->remote_sdp_str = switch_core_session_strdup(session, tmp);
}
+12 -9
View File
@@ -91,6 +91,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
char *user_via = NULL;
char *contact_str = NULL;
char *dup_dest = NULL;
char *p = NULL;
char *remote_host = NULL;
if (!to) {
@@ -187,7 +188,12 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
/* sofia_glue is running sofia_overcome_sip_uri_weakness we do not, not sure if it matters */
dup_dest = strdup(dst->contact);
if (dst->route_uri) {
dup_dest = strdup(dst->route_uri);
} else {
dup_dest = strdup(dst->to);
}
if (dst->route_uri) {
remote_host = strdup(dst->route_uri);
@@ -226,17 +232,12 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
contact_str = profile->url;
}
switch_safe_free(dup_dest);
switch_safe_free(remote_host);
status = SWITCH_STATUS_SUCCESS;
/*
if ((p = strstr(contact, ";fs_"))) {
if (dup_dest && (p = strstr(dup_dest, ";fs_"))) {
*p = '\0';
}
*/
/* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */
msg_nh = nua_handle(profile->nua, NULL,
@@ -244,7 +245,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
SIPTAG_FROM_STR(from),
TAG_IF(contact, NUTAG_URL(contact)),
SIPTAG_TO_STR(dst->to),
SIPTAG_TO_STR(dup_dest),
SIPTAG_CONTACT_STR(contact_str),
TAG_END());
@@ -257,6 +258,8 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
TAG_END());
sofia_glue_free_destination(dst);
switch_safe_free(dup_dest);
switch_safe_free(remote_host);
}
switch_console_free_matches(&list);
+1 -1
View File
@@ -653,7 +653,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
"and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile);
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld",
switch_snprintf(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%s' and expires <= %ld",
mod_sofia_globals.hostname, (long) now);