提交 7fa3f7f3 authored 作者: Giovanni Maruzzelli's avatar Giovanni Maruzzelli

skypopen: fixing bug from Anton VG, adding some guards against NULL sessions and channels

上级 3ad0d5d6
......@@ -938,16 +938,21 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
char *p = digit_str;
switch_channel_t *channel = switch_core_session_get_channel(session);
while (p && *p) {
switch_dtmf_t dtmf;
dtmf.digit = *p;
dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
switch_channel_queue_dtmf(channel, &dtmf);
p++;
if(channel){
while (p && *p) {
switch_dtmf_t dtmf;
dtmf.digit = *p;
dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
switch_channel_queue_dtmf(channel, &dtmf);
p++;
}
NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
(unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
}else{
WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG);
}
NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
(unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
}
}
}
......@@ -2138,33 +2143,37 @@ int dtmf_received(private_t *tech_pvt, char *value)
switch_channel_t *channel = NULL;
session = switch_core_session_locate(tech_pvt->session_uuid_str);
channel = switch_core_session_get_channel(session);
if (session) {
channel = switch_core_session_get_channel(session);
if (channel) {
if (channel) {
if (switch_channel_test_flag(channel, CF_BRIDGED)
&& !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
if (switch_channel_test_flag(channel, CF_BRIDGED)
&& !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
NOTICA
("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n",
SKYPOPEN_P_LOG, value[0], switch_channel_get_name(channel));
NOTICA
("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n",
SKYPOPEN_P_LOG, value[0], switch_channel_get_name(channel));
} else {
} else {
switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPOPEN_P_LOG, dtmf.digit, switch_channel_get_name(channel));
switch_mutex_lock(tech_pvt->flag_mutex);
switch_channel_queue_dtmf(channel, &dtmf);
switch_set_flag(tech_pvt, TFLAG_DTMF);
switch_mutex_unlock(tech_pvt->flag_mutex);
switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPOPEN_P_LOG, dtmf.digit, switch_channel_get_name(channel));
switch_mutex_lock(tech_pvt->flag_mutex);
switch_channel_queue_dtmf(channel, &dtmf);
switch_set_flag(tech_pvt, TFLAG_DTMF);
switch_mutex_unlock(tech_pvt->flag_mutex);
}
} else {
WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
}
} else {
WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
switch_core_session_rwunlock(session);
}else{
WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]);
}
switch_core_session_rwunlock(session);
return 0;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论