提交 75198fe4 authored 作者: Anthony Minessale's avatar Anthony Minessale

audio adjustments

上级 03f5d55f
...@@ -408,7 +408,7 @@ static switch_status_t conference_local_play_file(conference_obj_t *conference, ...@@ -408,7 +408,7 @@ static switch_status_t conference_local_play_file(conference_obj_t *conference,
static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin); static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin);
static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin); static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop); static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool); static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_core_session_t *session, switch_memory_pool_t *pool);
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
const char *body, const char *type, const char *hint); const char *body, const char *type, const char *hint);
...@@ -2500,6 +2500,10 @@ static void conference_loop_output(conference_member_t *member) ...@@ -2500,6 +2500,10 @@ static void conference_loop_output(conference_member_t *member)
use_buffer = NULL; use_buffer = NULL;
mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer); mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
if (mux_used < bytes * 2) {
use_timer = 1;
}
if (mux_used) { if (mux_used) {
if (mux_used < bytes) { if (mux_used < bytes) {
if (++low_count >= 5) { if (++low_count >= 5) {
...@@ -2512,10 +2516,7 @@ static void conference_loop_output(conference_member_t *member) ...@@ -2512,10 +2516,7 @@ static void conference_loop_output(conference_member_t *member)
} }
} }
if (mux_used >= bytes) {
use_timer = 1;
if (mux_used) {
/* Flush the output buffer and write all the data (presumably muxed) back to the channel */ /* Flush the output buffer and write all the data (presumably muxed) back to the channel */
switch_mutex_lock(member->audio_out_mutex); switch_mutex_lock(member->audio_out_mutex);
write_frame.data = data; write_frame.data = data;
...@@ -4347,7 +4348,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc ...@@ -4347,7 +4348,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
} }
/* Create the conference object. */ /* Create the conference object. */
new_conference = conference_new(conf_name, xml_cfg, pool); new_conference = conference_new(conf_name, xml_cfg, member->session, pool);
/* Release the config registry handle */ /* Release the config registry handle */
if (cxml) { if (cxml) {
...@@ -5472,7 +5473,7 @@ SWITCH_STANDARD_APP(conference_function) ...@@ -5472,7 +5473,7 @@ SWITCH_STANDARD_APP(conference_function)
} }
/* Create the conference object. */ /* Create the conference object. */
conference = conference_new(conf_name, xml_cfg, NULL); conference = conference_new(conf_name, xml_cfg, session, NULL);
if (!conference) { if (!conference) {
goto done; goto done;
...@@ -5517,7 +5518,7 @@ SWITCH_STANDARD_APP(conference_function) ...@@ -5517,7 +5518,7 @@ SWITCH_STANDARD_APP(conference_function)
const char *max_members_str; const char *max_members_str;
/* couldn't find the conference, create one */ /* couldn't find the conference, create one */
conference = conference_new(conf_name, xml_cfg, NULL); conference = conference_new(conf_name, xml_cfg, session, NULL);
if (!conference) { if (!conference) {
goto done; goto done;
...@@ -5942,7 +5943,7 @@ static conference_obj_t *conference_find(char *name) ...@@ -5942,7 +5943,7 @@ static conference_obj_t *conference_find(char *name)
} }
/* create a new conferene with a specific profile */ /* create a new conferene with a specific profile */
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool) static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_core_session_t *session, switch_memory_pool_t *pool)
{ {
conference_obj_t *conference; conference_obj_t *conference;
switch_xml_t xml_kvp; switch_xml_t xml_kvp;
...@@ -5985,6 +5986,10 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m ...@@ -5985,6 +5986,10 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
char *verbose_events = NULL; char *verbose_events = NULL;
char *auto_record = NULL; char *auto_record = NULL;
char *terminate_on_silence = NULL; char *terminate_on_silence = NULL;
switch_codec_implementation_t read_impl = { 0 };
switch_channel_t *channel = NULL;
const char *force_rate = NULL, *force_interval = NULL;
uint32_t force_rate_i = 0, force_interval_i = 0;
/* Validate the conference name */ /* Validate the conference name */
if (zstr(name)) { if (zstr(name)) {
...@@ -5992,6 +5997,37 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m ...@@ -5992,6 +5997,37 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
return NULL; return NULL;
} }
if (session) {
uint32_t tmp;
switch_core_session_get_read_impl(session, &read_impl);
channel = switch_core_session_get_channel(session);
if ((force_rate = switch_channel_get_variable(channel, "conference_force_rate"))) {
if (!strcasecmp(force_rate, "auto")) {
force_rate_i = read_impl.actual_samples_per_second;
} else {
tmp = atoi(force_rate);
if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {
force_rate_i = rate = tmp;
}
}
}
if ((force_interval = switch_channel_get_variable(channel, "conference_force_interval"))) {
if (!strcasecmp(force_interval, "auto")) {
force_interval_i = read_impl.microseconds_per_packet / 1000;
} else {
tmp = atoi(force_interval);
if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
force_interval_i = interval = tmp;
}
}
}
}
switch_mutex_lock(globals.hash_mutex); switch_mutex_lock(globals.hash_mutex);
/* parse the profile tree for param values */ /* parse the profile tree for param values */
...@@ -6012,21 +6048,34 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m ...@@ -6012,21 +6048,34 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
var = buf; var = buf;
} }
if (!strcasecmp(var, "rate") && !zstr(val)) { if (!force_rate_i && !strcasecmp(var, "rate") && !zstr(val)) {
uint32_t tmp = atoi(val); uint32_t tmp = atoi(val);
if (session && tmp == 0) {
if (!strcasecmp(val, "auto")) {
rate = read_impl.actual_samples_per_second;
}
} else {
if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) { if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {
rate = tmp; rate = tmp;
} }
}
} else if (!strcasecmp(var, "domain") && !zstr(val)) { } else if (!strcasecmp(var, "domain") && !zstr(val)) {
domain = val; domain = val;
} else if (!strcasecmp(var, "interval") && !zstr(val)) { } else if (!force_interval_i && !strcasecmp(var, "interval") && !zstr(val)) {
uint32_t tmp = atoi(val); uint32_t tmp = atoi(val);
if (session && tmp == 0) {
if (!strcasecmp(val, "auto")) {
interval = read_impl.microseconds_per_packet / 1000;
}
} else {
if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) { if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
interval = tmp; interval = tmp;
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
} }
}
} else if (!strcasecmp(var, "timer-name") && !zstr(val)) { } else if (!strcasecmp(var, "timer-name") && !zstr(val)) {
timer_name = val; timer_name = val;
} else if (!strcasecmp(var, "tts-engine") && !zstr(val)) { } else if (!strcasecmp(var, "tts-engine") && !zstr(val)) {
...@@ -6296,6 +6345,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m ...@@ -6296,6 +6345,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
} else { } else {
conference->domain = "cluecon.com"; conference->domain = "cluecon.com";
} }
conference->rate = rate; conference->rate = rate;
conference->interval = interval; conference->interval = interval;
......
...@@ -2173,7 +2173,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t ...@@ -2173,7 +2173,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes);
ts = ntohl(rtp_session->recv_msg.header.ts); ts = ntohl(rtp_session->recv_msg.header.ts);
if (ts && !rtp_session->jb && ts <= rtp_session->last_cng_ts) { if (*bytes && (!rtp_session->recv_te || rtp_session->recv_msg.header.pt != rtp_session->recv_te) &&
ts && !rtp_session->jb && ts == rtp_session->last_cng_ts) {
/* we already sent this frame..... */ /* we already sent this frame..... */
*bytes = 0; *bytes = 0;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -2929,7 +2930,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -2929,7 +2930,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (do_cng) { if (do_cng) {
uint8_t *data = (uint8_t *) rtp_session->recv_msg.body; uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
if (rtp_session->last_cng_ts == rtp_session->last_read_ts + rtp_session->samples_per_interval) {
rtp_session->last_cng_ts = 0;
} else {
rtp_session->last_cng_ts = rtp_session->last_read_ts + rtp_session->samples_per_interval; rtp_session->last_cng_ts = rtp_session->last_read_ts + rtp_session->samples_per_interval;
}
memset(data, 0, 2); memset(data, 0, 2);
data[0] = 65; data[0] = 65;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论