提交 655325ab authored 作者: Nathan Neulinger's avatar Nathan Neulinger

fixup and merge in FS-4027 enhancements for additional device support

上级 802aa379
...@@ -623,6 +623,26 @@ switch_status_t perform_send_set_speaker_mode(listener_t *listener, ...@@ -623,6 +623,26 @@ switch_status_t perform_send_set_speaker_mode(listener_t *listener,
return skinny_send_reply_quiet(listener, message); return skinny_send_reply_quiet(listener, message);
} }
switch_status_t perform_send_srvreq_response(listener_t *listener,
const char *file, const char *func, int line,
char *ip, uint32_t port)
{
skinny_message_t *message;
message = switch_core_alloc(listener->pool, 12+sizeof(message->data.serv_res_mess));
message->type = SERVER_RESPONSE_MESSAGE;
message->length = 4 + sizeof(message->data.serv_res_mess);
message->data.serv_res_mess.serverListenPort[0] = port;
switch_inet_pton(AF_INET,ip, &message->data.serv_res_mess.serverIpAddr[0]);
switch_copy_string(message->data.serv_res_mess.server[0].serverName,ip,sizeof(message->data.serv_res_mess.server[0].serverName));
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
"Sending Server Request Response with IP (%s) and Port (%d)\n", ip, port);
return skinny_send_reply(listener, message);
}
switch_status_t perform_send_start_media_transmission(listener_t *listener, switch_status_t perform_send_start_media_transmission(listener_t *listener,
const char *file, const char *func, int line, const char *file, const char *func, int line,
uint32_t conference_id, uint32_t conference_id,
......
...@@ -2184,6 +2184,79 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski ...@@ -2184,6 +2184,79 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_message_t *request)
{
char *sql;
skinny_profile_t *profile;
uint32_t i = 0;
uint32_t n = 0;
char *codec_order[SWITCH_MAX_CODECS];
char *codec_string;
size_t string_len, string_pos, pos;
switch_assert(listener->profile);
switch_assert(listener->device_name);
profile = listener->profile;
skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount));
n = request->data.upd_cap.lel_audioCapCount;
if (n > SWITCH_MAX_CODECS) {
n = SWITCH_MAX_CODECS;
}
string_len = -1;
skinny_check_data_length(request, sizeof(request->data.upd_cap.lel_audioCapCount) + n * sizeof(request->data.upd_cap.audioCaps[0]));
for (i = 0; i < n; i++) {
char *codec = skinny_codec2string(request->data.upd_cap.audioCaps[i].lel_payloadCapability);
codec_order[i] = codec;
string_len += strlen(codec)+1;
}
i = 0;
pos = 0;
codec_string = switch_core_alloc(listener->pool, string_len+1);
for (string_pos = 0; string_pos < string_len; string_pos++) {
char *codec = codec_order[i];
switch_assert(i < n);
if(pos == strlen(codec)) {
codec_string[string_pos] = ',';
i++;
pos = 0;
} else {
codec_string[string_pos] = codec[pos++];
}
}
codec_string[string_len] = '\0';
if ((sql = switch_mprintf(
"UPDATE skinny_devices SET codec_string='%s' WHERE name='%s'",
codec_string,
listener->device_name
))) {
skinny_execute_sql(profile, sql, profile->sql_mutex);
switch_safe_free(sql);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Codecs %s supported.\n", codec_string);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t skinny_handle_server_req_message(listener_t *listener, skinny_message_t *request)
{
skinny_profile_t *profile;
profile = listener->profile;
skinny_log_l(listener, SWITCH_LOG_INFO, "Received Server Request Message (length=%d).\n", request->length);
send_srvreq_response(listener, profile->ip, profile->port);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t *request) switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t *request)
{ {
switch_event_t *event = NULL; switch_event_t *event = NULL;
...@@ -2209,7 +2282,7 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re ...@@ -2209,7 +2282,7 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received %s (type=%x,length=%d).\n", skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received %s (type=%x,length=%d).\n",
skinny_message_type2str(request->type), request->type, request->length); skinny_message_type2str(request->type), request->type, request->length);
} }
if(zstr(listener->device_name) && request->type != REGISTER_MESSAGE && request->type != ALARM_MESSAGE && request->type != XML_ALARM_MESSAGE) { if(zstr(listener->device_name) && request->type != REGISTER_MESSAGE && request->type != ALARM_MESSAGE && request->type != XML_ALARM_MESSAGE && request->type != KEEP_ALIVE_MESSAGE) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Device should send a register message first. Received %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); "Device should send a register message first. Received %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
...@@ -2281,6 +2354,10 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re ...@@ -2281,6 +2354,10 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
return skinny_handle_accessory_status_message(listener, request); return skinny_handle_accessory_status_message(listener, request);
case XML_ALARM_MESSAGE: case XML_ALARM_MESSAGE:
return skinny_handle_xml_alarm(listener, request); return skinny_handle_xml_alarm(listener, request);
case DEVICE_UPDATECAPABILITIES:
return skinny_handle_updatecapabilities(listener, request);
case SERVER_REQ_MESSAGE:
return skinny_handle_server_req_message(listener, request);
default: default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Unhandled %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); "Unhandled %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论