Exemplo n.º 1
0
SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_count) {

    switch_status_t status;
    //switch_file_handle_t fh = { 0 };
	const char *prebuf;
	switch_file_handle_t local_fh;

	this_check(-1);
    sanity_check(-1);
	
	memset(&local_fh, 0, sizeof(local_fh));
	fhp = &local_fh;
    local_fh.samples = starting_sample_count;


	if ((prebuf = switch_channel_get_variable(this->channel, "stream_prebuffer"))) {
        int maybe = atoi(prebuf);
        if (maybe > 0) {
            local_fh.prebuf = maybe;
        }
	}

    begin_allow_threads();
    status = switch_ivr_play_file(session, fhp, file, ap);
    end_allow_threads();

	fhp = NULL;
	
    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;

}
Exemplo n.º 2
0
SWITCH_DECLARE(char *) CoreSession::read(int min_digits,
										 int max_digits,
										 const char *prompt_audio_file,
										 int timeout,
										 const char *valid_terminators)
{
	this_check((char *)"");
	sanity_check((char *)"");
	if (min_digits < 1) {
		min_digits = 1;
	}

	if (max_digits < 1) {
		max_digits = 1;
	}

	if (timeout < 1) {
		timeout = 1;
	}

    begin_allow_threads();
	switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf, sizeof(dtmf_buf), timeout, valid_terminators);
    end_allow_threads();

	return dtmf_buf;
}
Exemplo n.º 3
0
SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits, 
													 int max_digits, 
													 int max_tries, 
													 int timeout, 
													 char *terminators, 
													 char *audio_files, 
													 char *bad_input_audio_files,
													 char *digits_regex,
													 const char *var_name)
{
    switch_status_t status;
	sanity_check((char *)"");
	this_check((char *)"");
	begin_allow_threads();
	memset(dtmf_buf, 0, sizeof(dtmf_buf));
    status = switch_play_and_get_digits( session, 
										 (uint32_t) min_digits,
										 (uint32_t) max_digits,
										 (uint32_t) max_tries, 
										 (uint32_t) timeout, 
										 terminators, 
										 audio_files, 
										 bad_input_audio_files,
										 var_name,
										 dtmf_buf, 
										 sizeof(dtmf_buf), 
										 digits_regex);

	end_allow_threads();
	return dtmf_buf;
}
Exemplo n.º 4
0
SWITCH_DECLARE(int) CoreSession::collectDigits(int digit_timeout, int abs_timeout) {
	this_check(-1);
	sanity_check(-1);
    begin_allow_threads();
	switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout);
    end_allow_threads();
    return SWITCH_STATUS_SUCCESS;
} 
Exemplo n.º 5
0
SWITCH_DECLARE(void) CoreSession::execute(const char *app, const char *data)
{
	this_check_void();
	sanity_check_noreturn;

	begin_allow_threads();
	switch_core_session_execute_application(session, app, data);
	end_allow_threads();
}
Exemplo n.º 6
0
SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char *context)
{
    switch_status_t status;
	this_check(-1);
	sanity_check(-1);
    begin_allow_threads();
    status = switch_ivr_session_transfer(session, extension, dialplan, context);
	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "transfer result: %d\n", status);
    end_allow_threads();
    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
Exemplo n.º 7
0
SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender) 
{
	this_check_void();
	sanity_check_noreturn;
	if (!(tosay && module_name && say_type && say_method)) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n");
		return;
	}
	begin_allow_threads();
	switch_ivr_say(session, tosay, module_name, say_type, say_method, say_gender, ap);
    end_allow_threads();
}
Exemplo n.º 8
0
SWITCH_DECLARE(int) CoreSession::sleep(int ms, int sync) {

    switch_status_t status;

	this_check(-1);
    sanity_check(-1);
	
    begin_allow_threads();
    status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap);
    end_allow_threads();

    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;

}
Exemplo n.º 9
0
SWITCH_DECLARE(void) CoreSession::sayPhrase(const char *phrase_name, const char *phrase_data, const char *phrase_lang) 
{
	this_check_void();
	sanity_check_noreturn;
	
	if (!(phrase_name)) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n");
		return;
	}

	begin_allow_threads();
	switch_ivr_phrase_macro(session, phrase_name, phrase_data, phrase_lang, ap);
    end_allow_threads();
}
Exemplo n.º 10
0
SWITCH_DECLARE(void) CoreSession::execute(const char *app, const char *data)
{
	this_check_void();
	sanity_check_noreturn;

	if (zstr(app)) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
		return;
	} 

	begin_allow_threads();
	switch_core_session_execute_application(session, app, data);
	end_allow_threads();
}
Exemplo n.º 11
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;

}
Exemplo n.º 12
0
SWITCH_DECLARE(int) CoreSession::speak(char *text)
{
    switch_status_t status;

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

	if (!tts_name) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS engine specified\n");
		return SWITCH_STATUS_FALSE;
	}

	if (!voice_name) {
		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS voice specified\n");
		return SWITCH_STATUS_FALSE;
	}


	begin_allow_threads();
	status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap);
	end_allow_threads();
    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
Exemplo n.º 13
0
SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits, 
											  char *terminators, 
											  int timeout,
											  int interdigit)
{
	this_check((char *)"");
	sanity_check((char *)"");
	begin_allow_threads();
	char terminator;

	memset(dtmf_buf, 0, sizeof(dtmf_buf));
	switch_ivr_collect_digits_count(session, 
									dtmf_buf,
									sizeof(dtmf_buf),
									maxdigits, 
									terminators, 
									&terminator, 
									(uint32_t) timeout, (uint32_t)interdigit, 0);

	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
	end_allow_threads();
	return dtmf_buf;
}