[Freeswitch-svn] [commit] r6550 - in freeswitch/trunk/src: . include mod/endpoints/mod_dingaling mod/endpoints/mod_sofia mod/formats/mod_shout
Freeswitch SVN
anthm at freeswitch.org
Thu Dec 6 17:26:37 EST 2007
Author: anthm
Date: Thu Dec 6 17:26:37 2007
New Revision: 6550
Modified:
freeswitch/trunk/src/include/switch_apr.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
freeswitch/trunk/src/switch_apr.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_rtp.c
freeswitch/trunk/src/switch_utils.c
Log:
misc changes
Modified: freeswitch/trunk/src/include/switch_apr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_apr.h (original)
+++ freeswitch/trunk/src/include/switch_apr.h Thu Dec 6 17:26:37 2007
@@ -964,7 +964,7 @@
SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t * sock, switch_sockaddr_t * sa);
SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t * sa);
-SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in);
+SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in);
SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t * sa);
SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t * sa);
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Thu Dec 6 17:26:37 2007
@@ -239,6 +239,7 @@
SWITCH_ABC_TYPE_WRITE,
SWITCH_ABC_TYPE_WRITE_REPLACE,
SWITCH_ABC_TYPE_READ_REPLACE,
+ SWITCH_ABC_TYPE_READ_PING,
SWITCH_ABC_TYPE_CLOSE
} switch_abc_type_t;
@@ -806,8 +807,9 @@
SMBF_WRITE_STREAM = (1 << 1),
SMBF_WRITE_REPLACE = (1 << 2),
SMBF_READ_REPLACE = (1 << 3),
- SMBF_STEREO = (1 << 4),
- SMBF_RECORD_ANSWER_REQ = (1 << 5)
+ SMBF_READ_PING = (1 << 4),
+ SMBF_STEREO = (1 << 5),
+ SMBF_RECORD_ANSWER_REQ = (1 << 6)
} switch_media_bug_flag_t;
/*!
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Thu Dec 6 17:26:37 2007
@@ -1525,18 +1525,22 @@
channel_answer_channel(session);
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
+ /*
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
}
+ */
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+ /*
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
}
+ */
break;
default:
break;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Dec 6 17:26:37 2007
@@ -805,16 +805,20 @@
return SWITCH_STATUS_FALSE;
}
}
+ /*
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
}
+ */
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+ /*
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
}
+ */
break;
case SWITCH_MESSAGE_INDICATE_REDIRECT:
if (msg->string_arg) {
Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Thu Dec 6 17:26:37 2007
@@ -932,7 +932,7 @@
break;
case SWITCH_ABC_TYPE_CLOSE:
break;
- case SWITCH_ABC_TYPE_WRITE:
+ case SWITCH_ABC_TYPE_READ_PING:
if (buffer) {
if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
switch_buffer_lock(buffer);
@@ -943,7 +943,10 @@
return SWITCH_FALSE;
}
break;
+
case SWITCH_ABC_TYPE_READ:
+ case SWITCH_ABC_TYPE_WRITE:
+
default:
break;
}
@@ -1052,8 +1055,9 @@
switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(tsession));
switch_buffer_create_dynamic(&buffer, 1024, 2048, 0);
switch_buffer_add_mutex(buffer, mutex);
-
- if (switch_core_media_bug_add(tsession, telecast_callback, buffer, 0, SMBF_READ_STREAM | SMBF_WRITE_STREAM, &bug) != SWITCH_STATUS_SUCCESS) {
+
+ if (switch_core_media_bug_add(tsession, telecast_callback, buffer, 0,
+ SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING, &bug) != SWITCH_STATUS_SUCCESS) {
goto end;
}
@@ -1073,8 +1077,13 @@
bytes = switch_buffer_read(buffer, buf, sizeof(buf));
switch_buffer_unlock(buffer);
} else {
+ if (!bytes) {
+ switch_yield(1000);
+ continue;
+ }
memset(buf, 0, bytes);
}
+
if ((rlen = lame_encode_buffer(gfp, (void *)buf, NULL, bytes / 2, mp3buf, sizeof(mp3buf))) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c (original)
+++ freeswitch/trunk/src/switch_apr.c Thu Dec 6 17:26:37 2007
@@ -646,8 +646,11 @@
/* socket functions */
-SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in)
+SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in)
{
+ if (!in) {
+ return "";
+ }
return get_addr(buf, len, &in->sa.sin.sin_addr);
}
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Dec 6 17:26:37 2007
@@ -131,6 +131,7 @@
assert(session != NULL);
assert(*frame != NULL);
+
if (switch_test_flag(*frame, SFF_CNG)) {
status = SWITCH_STATUS_SUCCESS;
goto done;
@@ -367,6 +368,40 @@
if (flag & SFF_CNG) {
switch_set_flag((*frame), SFF_CNG);
}
+ if (session->bugs) {
+ switch_media_bug_t *bp, *dp, *last = NULL;
+ switch_bool_t ok = SWITCH_TRUE;
+ switch_thread_rwlock_rdlock(session->bug_rwlock);
+ for (bp = session->bugs; bp; bp = bp->next) {
+ if (bp->ready && switch_test_flag(bp, SMBF_READ_PING)) {
+ switch_mutex_lock(bp->read_mutex);
+ if (bp->callback) {
+ if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE || (bp->stop_time && bp->stop_time <= time(NULL))) {
+ ok = SWITCH_FALSE;
+ }
+ }
+ switch_mutex_unlock(bp->read_mutex);
+ }
+
+ if (ok == SWITCH_FALSE) {
+ bp->ready = 0;
+ if (last) {
+ last->next = bp->next;
+ } else {
+ session->bugs = bp->next;
+ }
+ dp = bp;
+ bp = last;
+ switch_core_media_bug_close(&dp);
+ if (!bp) {
+ break;
+ }
+ continue;
+ }
+ last = bp;
+ }
+ switch_thread_rwlock_unlock(session->bug_rwlock);
+ }
}
return status;
@@ -512,7 +547,7 @@
write_frame->rate = session->write_resampler->to_rate;
}
- if (do_bugs) {
+ if (!do_bugs) {
do_write = 1;
write_frame = frame;
goto done;
@@ -528,6 +563,7 @@
continue;
}
if (switch_test_flag(bp, SMBF_WRITE_STREAM)) {
+
switch_mutex_lock(bp->write_mutex);
switch_buffer_write(bp->raw_write_buffer, write_frame->data, write_frame->datalen);
switch_mutex_unlock(bp->write_mutex);
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Thu Dec 6 17:26:37 2007
@@ -168,6 +168,10 @@
status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
if (SWITCH_READ_ACCEPTABLE(status)) {
+ if (switch_test_flag(read_frame, SFF_CNG)) {
+ continue;
+ }
+
if (status != SWITCH_STATUS_BREAK && !switch_channel_test_flag(chan_a, CF_HOLD)) {
if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "write: %s Bad Frame....[%u] Bubye!\n",
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Thu Dec 6 17:26:37 2007
@@ -242,7 +242,7 @@
if ((packet->header.type == SWITCH_STUN_BINDING_REQUEST) && !strcmp(rtp_session->user_ice, username)) {
uint8_t buf[512];
switch_stun_packet_t *rpacket;
- char *remote_ip;
+ const char *remote_ip;
switch_size_t bytes;
char ipbuf[25];
@@ -253,8 +253,8 @@
remote_ip = switch_get_addr(ipbuf, sizeof(ipbuf), rtp_session->from_addr);
-
- switch_stun_packet_attribute_add_binded_address(rpacket, remote_ip, switch_sockaddr_get_port(rtp_session->from_addr));
+
+ switch_stun_packet_attribute_add_binded_address(rpacket, (char *)remote_ip, switch_sockaddr_get_port(rtp_session->from_addr));
bytes = switch_stun_packet_length(rpacket);
switch_socket_sendto(rtp_session->sock, rtp_session->from_addr, 0, (void *) rpacket, &bytes);
}
@@ -424,7 +424,8 @@
{
*err = "Success";
- if (switch_sockaddr_info_get(&rtp_session->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_sockaddr_info_get(&rtp_session->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool)
+ != SWITCH_STATUS_SUCCESS || !rtp_session->remote_addr) {
*err = "Remote Address Error!";
return SWITCH_STATUS_FALSE;
}
@@ -1005,8 +1006,8 @@
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
- char *tx_host;
- char *old_host;
+ const char *tx_host;
+ const char *old_host;
char bufa[30], bufb[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);
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Thu Dec 6 17:26:37 2007
@@ -899,7 +899,9 @@
{
assert(buf);
*buf = '\0';
- inet_ntop(AF_INET, in, buf, len);
+ if (in) {
+ inet_ntop(AF_INET, in, buf, len);
+ }
return buf;
}
More information about the Freeswitch-svn
mailing list