add uuid_debug_audio <uuid> <read|write|both> <on|off>

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15274 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-10-29 17:52:52 +00:00
parent 8d01cf8e1a
commit b3ec0eac5f
4 changed files with 62 additions and 15 deletions

View File

@ -514,7 +514,8 @@ typedef enum {
SWITCH_ZRTP_FLAG_SECURE_RECV = (1 << 24),
SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 << 25),
SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26),
SWITCH_RTP_FLAG_DEBUG_RTP = (1 << 27)
SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 << 27),
SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 << 28)
} switch_rtp_flag_enum_t;
typedef uint32_t switch_rtp_flag_t;

View File

@ -2106,10 +2106,10 @@ SWITCH_STANDARD_API(uuid_warning_function)
}
#define DEBUG_AUDIO_SYNTAX "<uuid> <on|off>"
#define DEBUG_AUDIO_SYNTAX "<uuid> <read|write|both> <on|off>"
SWITCH_STANDARD_API(uuid_debug_audio_function)
{
char *mycmd = NULL, *argv[2] = { 0 };
char *mycmd = NULL, *argv[3] = { 0 };
int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
@ -2117,14 +2117,15 @@ SWITCH_STANDARD_API(uuid_debug_audio_function)
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) {
if (zstr(cmd) || argc < 3 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2])) {
stream->write_function(stream, "-USAGE: %s\n", DEBUG_AUDIO_SYNTAX);
} else {
switch_core_session_message_t msg = { 0 };
switch_core_session_t *lsession = NULL;
msg.message_id = SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO;
msg.string_arg = argv[1];
msg.string_array_arg[0] = argv[1];
msg.string_array_arg[1] = argv[2];
msg.from = __FILE__;
if ((lsession = switch_core_session_locate(argv[0]))) {

View File

@ -1082,14 +1082,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO:
{
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if (switch_true(msg->string_arg)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
int32_t flags = 0;
if (!strcasecmp(msg->string_array_arg[0], "read")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ;
} else if (!strcasecmp(msg->string_array_arg[0], "write")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_WRITE;
} else if (!strcasecmp(msg->string_array_arg[0], "both")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ | SWITCH_RTP_FLAG_DEBUG_RTP_WRITE;
}
if (flags) {
if (switch_true(msg->string_array_arg[1])) {
switch_rtp_set_flag(tech_pvt->rtp_session, flags);
} else {
switch_rtp_clear_flag(tech_pvt->rtp_session, flags);
}
} else {
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options\n");
}
}
}
status = SWITCH_STATUS_FALSE;
goto end;
case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY:
if (tech_pvt->rtp_session && switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {

View File

@ -1679,10 +1679,10 @@ static void do_flush(switch_rtp_t *rtp_session)
if (switch_rtp_ready(rtp_session)) {
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ)) {
switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
if (!session) {
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
@ -1904,11 +1904,11 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
}
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ)) {
switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
if (!session) {
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
} else {
const char *tx_host;
@ -1923,7 +1923,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
"%s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
"R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
switch_channel_get_name(switch_core_session_get_channel(session)),
(long)bytes,
my_host, switch_sockaddr_get_port(rtp_session->local_addr),
@ -2748,6 +2748,37 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
#endif
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_WRITE)) {
switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
if (!session) {
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_WRITE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
} else {
const char *tx_host;
const char *old_host;
const char *my_host;
char bufa[30], bufb[30], bufc[30];
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
"W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
switch_channel_get_name(switch_core_session_get_channel(session)),
(long)bytes,
my_host, switch_sockaddr_get_port(rtp_session->local_addr),
old_host, rtp_session->remote_port,
tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
send_msg->header.pt, ntohl(send_msg->header.ts), send_msg->header.m);
}
}
if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
rtp_session->seq--;
ret = -1;