diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 16d69baae0..cb20f64a7a 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -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); /*! diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 13fb40026e..3af505f64c 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -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; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 2b71b560b7..f6b7db60e1 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -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); diff --git a/src/mod/endpoints/mod_portaudio/Makefile b/src/mod/endpoints/mod_portaudio/Makefile index 72da1c9f14..c5fb848034 100644 --- a/src/mod/endpoints/mod_portaudio/Makefile +++ b/src/mod/endpoints/mod_portaudio/Makefile @@ -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 diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 6ec8bc37c2..027d75a7dc 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -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); diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 184debd5d4..c63bcae0fb 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -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) { diff --git a/src/switch_core.c b/src/switch_core.c index c760fd0244..e7624372ab 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 487c3b1da2..83b197691c 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -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");