git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4600 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2007-03-15 01:58:41 +00:00
parent d35dda719e
commit ffde2ff0af
8 changed files with 42 additions and 16 deletions

View File

@ -1109,7 +1109,8 @@ SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *te
/*!
\brief Open a media file using file format modules
\param fh a file handle to use
\param codec_imp the codec implementation being used
\param channels the number of channels
\param rate the sample rate
\param file_path the path to the file
\param flags read/write flags
\param pool the pool to use (NULL for new pool)
@ -1117,8 +1118,9 @@ SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *te
\note the loadable module used is chosen based on the file extension
*/
SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
const switch_codec_implementation_t *codec_imp,
char *file_path,
uint8_t channels,
uint32_t rate,
unsigned int flags,
switch_memory_pool_t *pool);
/*!

View File

@ -312,7 +312,6 @@ struct switch_file_handle {
/*! private data for the format module to store handle specific info */
void *private_info;
char *handler;
const switch_codec_implementation_t *codec_imp;
int64_t pos;
switch_buffer_t *audio_buffer;
uint32_t thresh;

View File

@ -1781,8 +1781,9 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
}
if (switch_core_file_open(&fh,
NULL,
rec->path,
conference->rate,
1,
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
rec->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
@ -1958,8 +1959,9 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char *
/* Open the file */
if (switch_core_file_open(&fnode->fh,
NULL,
file,
conference->rate,
1,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
pool) != SWITCH_STATUS_SUCCESS) {
switch_core_destroy_memory_pool(&pool);
@ -2044,8 +2046,9 @@ static switch_status_t conference_member_play_file(conference_member_t *member,
/* Open the file */
if (switch_core_file_open(&fnode->fh,
switch_core_session_get_read_codec(member->session)->implementation,
file,
conference->rate,
1,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
pool) != SWITCH_STATUS_SUCCESS) {
switch_core_destroy_memory_pool(&pool);

View File

@ -1,5 +1,6 @@
# define these targets in your makefile if you wish
# local_all local_depend local_clean depend_install local_install local_distclean local_extraclean:
BASE=../../../..
OSARCH=$(shell uname -s)
# and define these variables to impact your build
MODNAME=mod_portaudio

View File

@ -225,8 +225,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
switch_set_flag_locked((&globals), GFLAG_RING);
if (ring_file) {
if (switch_core_file_open(&fh,
globals.read_codec.implementation,
ring_file,
globals.read_codec.implementation->number_of_channels,
globals.read_codec.implementation->samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
NULL) == SWITCH_STATUS_SUCCESS) {
@ -589,8 +590,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
}
if (switch_core_file_open(&tech_pvt->fh,
globals.read_codec.implementation,
tech_pvt->hold_file,
globals.read_codec.implementation->number_of_channels,
globals.read_codec.implementation->samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_core_codec_destroy(&tech_pvt->write_codec);

View File

@ -440,8 +440,12 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, char *path)
return SWITCH_STATUS_MEMERR;
}
if (!handle->samplerate) {
handle->samplerate = 8000;
}
context->memory_pool = handle->memory_pool;
context->samplerate = handle->codec_imp ? handle->codec_imp->samples_per_second : 8000;
context->samplerate = handle->samplerate;
if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {

View File

@ -1012,11 +1012,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
}
return SWITCH_STATUS_SUCCESS;
}
}
SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
const switch_codec_implementation_t *codec_imp,
char *file_path,
uint8_t channels,
uint32_t rate,
unsigned int flags,
switch_memory_pool_t *pool)
{
@ -1056,8 +1057,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
fh->handler = switch_core_strdup(fh->memory_pool, rhs);
}
fh->codec_imp = codec_imp;
if (rate) {
fh->samplerate = rate;
} else {
rate = 8000;
}
if (channels) {
fh->channels = channels;
} else {
fh->channels = 1;
}
return fh->file_interface->file_open(fh, file_path);
}

View File

@ -390,8 +390,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
if (switch_core_file_open(fh,
read_codec->implementation,
file,
read_codec->implementation->number_of_channels,
read_codec->implementation->samples_per_second,
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -629,8 +630,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
if (switch_core_file_open(fh,
read_codec->implementation,
file,
read_codec->implementation->number_of_channels,
read_codec->implementation->samples_per_second,
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -1157,8 +1159,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
}
if (switch_core_file_open(fh,
read_codec->implementation,
file,
read_codec->implementation->number_of_channels,
read_codec->implementation->samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_core_session_reset(session);
@ -2857,8 +2860,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
ringback.fhb.channels = read_codec->implementation->number_of_channels;
ringback.fhb.samplerate = read_codec->implementation->samples_per_second;
if (switch_core_file_open(&ringback.fhb,
read_codec->implementation,
ringback_data,
read_codec->implementation->number_of_channels,
read_codec->implementation->samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");