[Freeswitch-svn] [commit] r2011 - in freeswitch/trunk/src: . mod/applications/mod_commands
Freeswitch SVN
anthm at freeswitch.org
Wed Jul 19 23:55:07 EDT 2006
Author: anthm
Date: Wed Jul 19 23:55:07 2006
New Revision: 2011
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core.c
Log:
enhance the show command
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Wed Jul 19 23:55:07 2006
@@ -186,15 +186,46 @@
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;
- holder->stream->write_function(holder->stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL");
+
+ if (holder->count == 0) {
+ if (holder->http) {
+ holder->stream->write_function(holder->stream, "\n<tr>");
+ }
+
+ for(x = 0; x < argc; x++) {
+ if (holder->http) {
+ holder->stream->write_function(holder->stream, "<td>");
+ holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
+ } else {
+ holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ",");
+ }
+ }
+ }
+
+ if (holder->http) {
+ holder->stream->write_function(holder->stream, "<tr bgcolor=%s>", holder->count % 2 == 0 ? "eeeeee" : "ffffff");
+ }
+
+ for(x = 0; x < argc; x++) {
+ if (holder->http) {
+ holder->stream->write_function(holder->stream, "<td>");
+ holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
+ } else {
+ holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "\n" : ",");
+ }
+ }
+
+
+
+
holder->count++;
return 0;
}
@@ -204,8 +235,12 @@
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 @@
holder.stream = stream;
holder.count = 0;
+ if (holder.http) {
+ holder.stream->write_function(holder.stream, "<table cellpadding=1 cellspacing=4 border=1>\n");
+ }
+
switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
+ if (holder.http) {
+ holder.stream->write_function(holder.stream, "</table>");
+ }
+
+
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);
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Wed Jul 19 23:55:07 2006
@@ -593,6 +593,7 @@
{
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_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) {
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Jul 19 23:55:07 2006
@@ -2821,9 +2821,13 @@
);
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 @@
" 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"
More information about the Freeswitch-svn
mailing list