forked from Mirrors/freeswitch
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13641 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
d07590f584
commit
7d6a95d5f7
265
patches/tmp.diff
Normal file
265
patches/tmp.diff
Normal file
@ -0,0 +1,265 @@
|
||||
Index: src/switch_core_media_bug.c
|
||||
===================================================================
|
||||
--- src/switch_core_media_bug.c (revision 13639)
|
||||
+++ src/switch_core_media_bug.c (working copy)
|
||||
@@ -102,7 +102,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame)
|
||||
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame, switch_bool_t fill)
|
||||
{
|
||||
switch_size_t bytes = 0, datalen = 0;
|
||||
int16_t *dp, *fp;
|
||||
@@ -131,7 +131,8 @@
|
||||
|
||||
switch_mutex_lock(bug->read_mutex);
|
||||
frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer, frame->data, bytes);
|
||||
- if (frame->datalen < bytes) {
|
||||
+ if (fill && frame->datalen < bytes) {
|
||||
+ printf("FILL READ %d %d\n", (int)frame->datalen, (int)bytes);
|
||||
memset(((unsigned char *)frame->data) + frame->datalen, 0, bytes - frame->datalen);
|
||||
frame->datalen = bytes;
|
||||
}
|
||||
@@ -141,7 +142,8 @@
|
||||
switch_assert(bug->raw_write_buffer);
|
||||
switch_mutex_lock(bug->write_mutex);
|
||||
datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, bytes);
|
||||
- if (datalen < bytes) {
|
||||
+ if (fill && datalen < bytes) {
|
||||
+ printf("FILL WRITE %d %d\n", (int)datalen, (int)bytes);
|
||||
memset(((unsigned char *)bug->data) + datalen, 0, bytes - datalen);
|
||||
datalen = bytes;
|
||||
}
|
||||
@@ -154,6 +156,14 @@
|
||||
rlen = frame->datalen / 2;
|
||||
wlen = datalen / 2;
|
||||
blen = bytes / 2;
|
||||
+
|
||||
+ if (!fill && rlen == 0 && wlen == 0) {
|
||||
+ frame->datalen = 0;
|
||||
+ frame->samples = 0;
|
||||
+ frame->rate = read_impl.actual_samples_per_second;
|
||||
+ frame->codec = NULL;
|
||||
+ return SWITCH_STATUS_FALSE;
|
||||
+ }
|
||||
|
||||
if (switch_test_flag(bug, SMBF_STEREO)) {
|
||||
for (x = 0; x < blen; x++) {
|
||||
Index: src/switch_ivr_async.c
|
||||
===================================================================
|
||||
--- src/switch_ivr_async.c (revision 13639)
|
||||
+++ src/switch_ivr_async.c (working copy)
|
||||
@@ -424,9 +424,11 @@
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
+#define LEAD_IN 25
|
||||
struct record_helper {
|
||||
char *file;
|
||||
switch_file_handle_t *fh;
|
||||
+ int lead_in;
|
||||
};
|
||||
|
||||
static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
||||
@@ -447,6 +449,22 @@
|
||||
switch_channel_set_private(channel, rh->file, NULL);
|
||||
|
||||
if (rh->fh) {
|
||||
+
|
||||
+ if (switch_channel_test_flag(channel, CF_ANSWERED) || !switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
|
||||
+ switch_size_t len;
|
||||
+ uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
+ switch_frame_t frame = { 0 };
|
||||
+
|
||||
+ frame.data = data;
|
||||
+ frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
+
|
||||
+ while (switch_core_media_bug_read(bug, &frame, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS && frame.datalen) {
|
||||
+ len = (switch_size_t) frame.datalen / 2;
|
||||
+ //printf("POST WRITE %d\n", frame.datalen);
|
||||
+ switch_core_file_write(rh->fh, data, &len);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
switch_core_file_close(rh->fh);
|
||||
if (rh->fh->samples_out < read_impl.samples_per_second * 3) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file);
|
||||
@@ -457,6 +475,10 @@
|
||||
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ_PING:
|
||||
+ if (rh->lead_in) {
|
||||
+ rh->lead_in--;
|
||||
+ } else
|
||||
+
|
||||
if (rh->fh) {
|
||||
switch_size_t len;
|
||||
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
@@ -465,17 +487,16 @@
|
||||
frame.data = data;
|
||||
frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
|
||||
- if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
|
||||
- int doit = 1;
|
||||
- if (!switch_channel_test_flag(channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
|
||||
- doit = 0;
|
||||
- }
|
||||
-
|
||||
- if (doit) {
|
||||
+ if (switch_channel_test_flag(channel, CF_ANSWERED) || !switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
|
||||
+ int loops = LEAD_IN;
|
||||
+ while (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS && frame.datalen) {
|
||||
len = (switch_size_t) frame.datalen / 2;
|
||||
+ //printf("WRITE %d\n", frame.datalen);
|
||||
switch_core_file_write(rh->fh, data, &len);
|
||||
+ if (!--loops) break;
|
||||
}
|
||||
}
|
||||
+ rh->lead_in = LEAD_IN;
|
||||
}
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_WRITE:
|
||||
@@ -528,7 +549,7 @@
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ_PING:
|
||||
if (ep->buffer) {
|
||||
- if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
|
||||
+ if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_buffer_lock(ep->buffer);
|
||||
switch_buffer_zwrite(ep->buffer, frame.data, frame.datalen);
|
||||
switch_buffer_unlock(ep->buffer);
|
||||
@@ -949,6 +970,7 @@
|
||||
rh = switch_core_session_alloc(session, sizeof(*rh));
|
||||
rh->fh = fh;
|
||||
rh->file = switch_core_session_strdup(session, file);
|
||||
+ rh->lead_in = LEAD_IN;
|
||||
|
||||
if ((status = switch_core_media_bug_add(session, record_callback, rh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding media bug for file %s\n", file);
|
||||
@@ -991,7 +1013,7 @@
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
p++;
|
||||
}
|
||||
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
|
||||
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%i %s DTMF DETECTED: %s\n", (int) switch_channel_get_micro(channel), switch_core_session_get_uuid(pvt->session), digit_str);
|
||||
}
|
||||
switch_core_media_bug_set_read_replace_frame(bug, frame);
|
||||
}
|
||||
@@ -1942,7 +1964,7 @@
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ:
|
||||
if (sth->ah) {
|
||||
- if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
|
||||
+ if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_asr_feed(sth->ah, frame.data, frame.datalen, &flags) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error Feeding Data\n");
|
||||
return SWITCH_FALSE;
|
||||
Index: src/switch_rtp.c
|
||||
===================================================================
|
||||
--- src/switch_rtp.c (revision 13639)
|
||||
+++ src/switch_rtp.c (working copy)
|
||||
@@ -2126,6 +2126,7 @@
|
||||
*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
|
||||
ret = 2 + rtp_header_len;
|
||||
rtp_session->stats.inbound.skip_packet_count++;
|
||||
+ printf("CNG\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
Index: src/mod/loggers/mod_logfile/mod_logfile.c
|
||||
===================================================================
|
||||
--- src/mod/loggers/mod_logfile/mod_logfile.c (revision 13639)
|
||||
+++ src/mod/loggers/mod_logfile/mod_logfile.c (working copy)
|
||||
@@ -93,7 +93,7 @@
|
||||
flags |= SWITCH_FOPEN_WRITE;
|
||||
flags |= SWITCH_FOPEN_APPEND;
|
||||
|
||||
- stat = switch_file_open(&afd, profile->logfile, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, module_pool);
|
||||
+ stat = switch_file_open(&afd, profile->logfile, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_WREAD, module_pool);
|
||||
if (stat != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
Index: src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
|
||||
===================================================================
|
||||
--- src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (revision 13639)
|
||||
+++ src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (working copy)
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
if (!switch_strlen_zero(logdir)) {
|
||||
if ((path = switch_mprintf("%s%s%s%s.cdr.xml", logdir, SWITCH_PATH_SEPARATOR, a_prefix, switch_core_session_get_uuid(session)))) {
|
||||
- if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
+ if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR| S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
|
||||
int wrote;
|
||||
wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
|
||||
close(fd);
|
||||
@@ -222,7 +222,7 @@
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to post to web server, writing to file\n");
|
||||
|
||||
if ((path = switch_mprintf("%s%s%s%s.cdr.xml", globals.err_log_dir, SWITCH_PATH_SEPARATOR, a_prefix, switch_core_session_get_uuid(session)))) {
|
||||
- if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
+ if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
|
||||
int wrote;
|
||||
wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
|
||||
close(fd);
|
||||
Index: src/mod/formats/mod_shout/mod_shout.c
|
||||
===================================================================
|
||||
--- src/mod/formats/mod_shout/mod_shout.c (revision 13639)
|
||||
+++ src/mod/formats/mod_shout/mod_shout.c (working copy)
|
||||
@@ -1159,7 +1159,7 @@
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ_PING:
|
||||
if (buffer) {
|
||||
- if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
|
||||
+ if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_buffer_lock(buffer);
|
||||
switch_buffer_write(buffer, frame.data, frame.datalen);
|
||||
switch_buffer_unlock(buffer);
|
||||
Index: src/include/switch_channel.h
|
||||
===================================================================
|
||||
--- src/include/switch_channel.h (revision 13639)
|
||||
+++ src/include/switch_channel.h (working copy)
|
||||
@@ -69,6 +69,9 @@
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_state(switch_channel_t *channel);
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_running_state(switch_channel_t *channel);
|
||||
|
||||
+//Dozier -- get micro for DTMF debugging
|
||||
+SWITCH_DECLARE(int32_t) switch_channel_get_micro(switch_channel_t *channel);
|
||||
+
|
||||
/*!
|
||||
\brief Determine if a channel is ready for io
|
||||
\param channel channel to test
|
||||
Index: src/include/switch_core.h
|
||||
===================================================================
|
||||
--- src/include/switch_core.h (revision 13639)
|
||||
+++ src/include/switch_core.h (working copy)
|
||||
@@ -238,7 +238,7 @@
|
||||
\param frame the frame to write the data to
|
||||
\return the amount of data
|
||||
*/
|
||||
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame);
|
||||
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame, switch_bool_t fill);
|
||||
|
||||
/*!
|
||||
\brief Flush the read and write buffers for the bug
|
||||
Index: src/switch_channel.c
|
||||
===================================================================
|
||||
--- src/switch_channel.c (revision 13639)
|
||||
+++ src/switch_channel.c (working copy)
|
||||
@@ -2326,6 +2326,16 @@
|
||||
return status;
|
||||
}
|
||||
|
||||
+//Dozier -- getting micro time from the channel
|
||||
+SWITCH_DECLARE(int32_t) switch_channel_get_micro(switch_channel_t *channel)
|
||||
+{
|
||||
+ switch_time_t now = switch_micro_time_now();
|
||||
+ switch_time_exp_t tm;
|
||||
+ switch_time_exp_lt(&tm, now);
|
||||
+ return tm.tm_usec;
|
||||
+}
|
||||
+
|
||||
+
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *channel)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
Loading…
Reference in New Issue
Block a user