diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index e2599f9c73..a21bcc39da 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -186,15 +186,46 @@ static switch_status_t pause_function(char *cmd, switch_stream_handle_t *stream) struct holder { switch_stream_handle_t *stream; + char *http; uint32_t count; }; - - static int show_callback(void *pArg, int argc, char **argv, char **columnNames){ struct holder *holder = (struct holder *) pArg; + int x; + + + if (holder->count == 0) { + if (holder->http) { + holder->stream->write_function(holder->stream, "\n"); + } + + for(x = 0; x < argc; x++) { + if (holder->http) { + holder->stream->write_function(holder->stream, ""); + holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ""); + } else { + holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ","); + } + } + } + + if (holder->http) { + holder->stream->write_function(holder->stream, "", holder->count % 2 == 0 ? "eeeeee" : "ffffff"); + } + + for(x = 0; x < argc; x++) { + if (holder->http) { + holder->stream->write_function(holder->stream, ""); + holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "\n" : ""); + } else { + holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "\n" : ","); + } + } + + + - holder->stream->write_function(holder->stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL"); holder->count++; return 0; } @@ -204,8 +235,12 @@ static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream) char sql[1024]; char *errmsg; switch_core_db_t *db = switch_core_db_handle(); - struct holder holder; - + struct holder holder = {0}; + + if (stream->event) { + holder.http = switch_event_get_header(stream->event, "http-host"); + } + if (!cmd) { sprintf (sql, "select * from interfaces"); } @@ -231,14 +266,23 @@ static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream) holder.stream = stream; holder.count = 0; + if (holder.http) { + holder.stream->write_function(holder.stream, "\n"); + } + switch_core_db_exec(db, sql, show_callback, &holder, &errmsg); + if (holder.http) { + holder.stream->write_function(holder.stream, "
"); + } + + if (errmsg) { stream->write_function(stream, "SQL ERR [%s]\n",errmsg); switch_core_db_free(errmsg); errmsg = NULL; } else { - stream->write_function(stream, "%u total.\n", holder.count); + stream->write_function(stream, "\n%u total.\n", holder.count); } switch_core_db_close(db); diff --git a/src/switch_channel.c b/src/switch_channel.c index 69926368bc..d6ad600b17 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -593,6 +593,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw { switch_caller_profile_t *caller_profile, *originator_caller_profile, *originatee_caller_profile; switch_hash_index_t *hi; + switch_codec_t *codec; void *val; const void *var; char state_num[25]; @@ -606,7 +607,16 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", (char *) state_num); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session)); - + + if ((codec = switch_core_session_get_read_codec(channel->session))) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", codec->implementation->iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->samples_per_second); + } + + if ((codec = switch_core_session_get_write_codec(channel->session))) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Name", codec->implementation->iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Rate", "%u", codec->implementation->samples_per_second); + } /* Index Caller's Profile */ if (caller_profile) { diff --git a/src/switch_core.c b/src/switch_core.c index 7126abb0e2..886a4af344 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -2821,9 +2821,13 @@ static void core_event_handler(switch_event_t *event) ); break; case SWITCH_EVENT_CHANNEL_EXECUTE: - sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q' where uuid='%q'", + sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q', read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q'", switch_event_get_header(event, "application"), switch_event_get_header(event, "application-data"), + switch_event_get_header(event, "channel-read-codec-name"), + switch_event_get_header(event, "channel-read-codec-rate"), + switch_event_get_header(event, "channel-write-codec-name"), + switch_event_get_header(event, "channel-write-codec-rate"), switch_event_get_header(event, "unique-id") ); break; @@ -3018,7 +3022,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err " ip_addr VARCHAR(255),\n" " dest VARCHAR(255),\n" " application VARCHAR(255),\n" - " application_data VARCHAR(255)\n" + " application_data VARCHAR(255),\n" + " read_codec VARCHAR(255),\n" + " read_rate VARCHAR(255),\n" + " write_codec VARCHAR(255),\n" + " write_rate VARCHAR(255)\n" ");\n"; char create_calls_sql[] = "CREATE TABLE calls (\n"