FS-8770 #resolve [media_bug_answer_req=true results in a file being created for unanswered calls]
This commit is contained in:
parent
d6e942c82c
commit
070b59916a
|
@ -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");
|
||||
}
|
||||
|
||||
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 {
|
||||
/* Set the completion_cause to maxtime reached, unless it's already set */
|
||||
set_completion_cause(rh, "success-maxtime");
|
||||
|
||||
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 {
|
||||
/* Set the completion_cause to maxtime reached, unless it's already set */
|
||||
set_completion_cause(rh, "success-maxtime");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1442,6 +1448,8 @@ 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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue