From d69cde6367f4bd8fa9119edb389e588b2a8de4cd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 15 Mar 2007 00:36:14 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4598 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 8 ++++++-- src/include/switch_module_interfaces.h | 2 ++ .../applications/mod_conference/mod_conference.c | 3 +++ src/mod/endpoints/mod_portaudio/mod_portaudio.c | 2 ++ src/switch_core.c | 13 +++++++++++-- src/switch_ivr.c | 4 ++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index e784f427ce..16d69baae0 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1109,14 +1109,18 @@ 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 file_path the path to the file \param flags read/write flags \param pool the pool to use (NULL for new pool) \return SWITCH_STATUS_SUCCESS if the file is opened \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, char *file_path, unsigned int flags, switch_memory_pool_t *pool); - +SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, + const switch_codec_implementation_t *codec_imp, + char *file_path, + unsigned int flags, + switch_memory_pool_t *pool); /*! \brief Read media from a file handle \param fh the file handle to read from (must be initilized by you memset all 0 for read, fill in channels and rate for write) diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index c7ee72fe5e..13fb40026e 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -311,6 +311,8 @@ struct switch_file_handle { switch_memory_pool_t *memory_pool; /*! 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 57ea39e724..2b71b560b7 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1781,6 +1781,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th } if (switch_core_file_open(&fh, + NULL, rec->path, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, rec->pool) != SWITCH_STATUS_SUCCESS) { @@ -1957,6 +1958,7 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * /* Open the file */ if (switch_core_file_open(&fnode->fh, + NULL, file, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) { @@ -2042,6 +2044,7 @@ 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, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index bc1a811504..6ec8bc37c2 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -225,6 +225,7 @@ 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, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) { @@ -588,6 +589,7 @@ 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, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_core.c b/src/switch_core.c index d8d6f2f035..c760fd0244 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1014,8 +1014,11 @@ 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, char *file_path, unsigned int flags, - switch_memory_pool_t *pool) +SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, + const switch_codec_implementation_t *codec_imp, + char *file_path, + unsigned int flags, + switch_memory_pool_t *pool) { char *ext; switch_status_t status; @@ -1049,6 +1052,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, switch_set_flag(fh, SWITCH_FILE_FLAG_FREE_POOL); } + if (rhs) { + fh->handler = switch_core_strdup(fh->memory_pool, rhs); + } + + fh->codec_imp = codec_imp; + return fh->file_interface->file_open(fh, file_path); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index c1c7b8e763..487c3b1da2 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -390,6 +390,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se if (switch_core_file_open(fh, + read_codec->implementation, file, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { @@ -628,6 +629,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t if (switch_core_file_open(fh, + read_codec->implementation, file, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { @@ -1155,6 +1157,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } if (switch_core_file_open(fh, + read_codec->implementation, file, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { @@ -2854,6 +2857,7 @@ 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, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {