提交 070b5991 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-8770 #resolve [media_bug_answer_req=true results in a file being created for unanswered calls]

上级 d6e942c8
......@@ -1048,6 +1048,8 @@ struct record_helper {
switch_thread_t *thread;
switch_mutex_t *buffer_mutex;
int thread_ready;
uint32_t writes;
uint32_t vwrites;
const char *completion_cause;
};
......@@ -1253,7 +1255,7 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_file_write(&rh->in_fh, mask ? null_data : nframe->data, &len);
rh->last_read_time = now;
rh->writes++;
}
break;
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
......@@ -1292,7 +1294,7 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_file_write(&rh->out_fh, mask ? null_data : nframe->data, &len);
rh->last_write_time = now;
rh->writes++;
}
break;
case SWITCH_ABC_TYPE_CLOSE:
......@@ -1352,28 +1354,32 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_file_close(rh->fh);
if (rh->fh->samples_out < rh->fh->samplerate * rh->min_sec) {
if (!rh->writes && !rh->vwrites) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding empty file %s\n", rh->file);
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
switch_file_remove(rh->file, switch_core_session_get_pool(session));
set_completion_cause(rh, "empty-file");
} else if (rh->fh->samples_out < rh->fh->samplerate * rh->min_sec) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file);
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
switch_file_remove(rh->file, switch_core_session_get_pool(session));
set_completion_cause(rh, "input-too-short");
}
} else {
if (switch_channel_down_nosig(channel)) {
/* We got hung up */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is hung up\n");
if (rh->speech_detected) {
/* Treat it as equivalent with final-silence */
set_completion_cause(rh, "success-silence");
if (switch_channel_down_nosig(channel)) {
/* We got hung up */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is hung up\n");
if (rh->speech_detected) {
/* Treat it as equivalent with final-silence */
set_completion_cause(rh, "success-silence");
} else {
/* Treat it as equivalent with inital-silence timeout */
set_completion_cause(rh, "no-input-timeout");
}
} else {
/* Treat it as equivalent with inital-silence timeout */
set_completion_cause(rh, "no-input-timeout");
/* Set the completion_cause to maxtime reached, unless it's already set */
set_completion_cause(rh, "success-maxtime");
}
} else {
/* Set the completion_cause to maxtime reached, unless it's already set */
set_completion_cause(rh, "success-maxtime");
}
}
......@@ -1441,7 +1447,9 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
}
return SWITCH_FALSE;
}
rh->writes++;
/* check for silence timeout */
if (rh->silence_threshold) {
switch_codec_implementation_t read_impl = { 0 };
......@@ -1500,6 +1508,7 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return SWITCH_FALSE;
}
rh->vwrites++;
}
break;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论