示例#1
0
int fs_switch_ivr_record_file(switch_core_session_t *session, switch_file_handle_t *fh, char *file, switch_input_args_t *args, unsigned int limit)
{
	switch_status_t status;

	status = switch_ivr_record_file(session, fh, file, args, limit);
	return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
示例#2
0
文件: ivr.c 项目: AricGod/FreeSWITCH
switch_status_t ivre_record(switch_core_session_t *session, ivre_data_t *loc, switch_event_t *event, const char *file_path, switch_file_handle_t *fh, int max_record_len, switch_size_t *record_len) {
	switch_status_t status = SWITCH_STATUS_SUCCESS;
	switch_channel_t *channel = switch_core_session_get_channel(session);

	if (switch_channel_ready(channel)) {
		switch_input_args_t args = { 0 };

		args.input_callback = cb_on_dtmf;
		args.buf = loc;

		if (loc->audio_stopped == SWITCH_FALSE && loc->result == RES_WAITFORMORE) {
			loc->recorded_audio = SWITCH_TRUE;
			switch_ivr_gentones(session, loc->record_tone, 0, NULL);
			status = switch_ivr_record_file(session, fh, file_path, &args, max_record_len);

			if (record_len) {
				*record_len = fh->samples_out / (fh->samplerate ? fh->samplerate : 8000);
			}

		}
		if (loc->result == RES_WAITFORMORE) {
			loc->result = RES_TIMEOUT;
		}

	} else {
		status = SWITCH_STATUS_BREAK;
	}

	return status;
}
示例#3
0
SWITCH_DECLARE(int) CoreSession::recordFile(char *file_name, int time_limit, int silence_threshold, int silence_hits) 
{
	switch_status_t status;
	switch_file_handle_t local_fh;

	this_check(-1);
	sanity_check(-1);

	memset(&local_fh, 0, sizeof(local_fh));
	fhp = &local_fh;
	local_fh.thresh = silence_threshold;
	local_fh.silence_hits = silence_hits;

	begin_allow_threads();
	status = switch_ivr_record_file(session, &local_fh, file_name, &args, time_limit);
	end_allow_threads();

	fhp = NULL;

    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;

}