}
-#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;
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]))) {
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)) {
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),
}
- 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;
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),
#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;