]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update2
authorBrian West <brian@freeswitch.org>
Thu, 15 Mar 2007 01:58:41 +0000 (01:58 +0000)
committerBrian West <brian@freeswitch.org>
Thu, 15 Mar 2007 01:58:41 +0000 (01:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4600 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/include/switch_module_interfaces.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_portaudio/Makefile
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/formats/mod_shout/mod_shout.c
src/switch_core.c
src/switch_ivr.c

index 16d69baae0aff8818b9b9db5a1d5c8b62652db53..cb20f64a7ad5e0176cbca390959d9713e56f32a4 100644 (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);
 /*! 
index 13fb40026edb95e632761f51c3801618e34480a3..3af505f64cafd7f15ff602be09638f9d393278fa 100644 (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;
index 2b71b560b7c0d9a73eaac3f310cce8063577811d..f6b7db60e12aa2b3e1889d255bf22b9c7e575c42 100644 (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);
index 72da1c9f141b9e53cd96f20979c92d955f03507d..c5fb848034561991985c61cfbfc364f4771399ad 100644 (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
index 6ec8bc37c2efb5e6e51b9ddd81255efaffe5016c..027d75a7dc9be8ed2e596d327577dfe771a5396d 100644 (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);
index 184debd5d453668cd5c62d6d6fcd12f504266808..c63bcae0fb0c5e7a5e01ecfea73955724e06e2d3 100644 (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) {
index c760fd0244e11dedc13f9f0337b8c8756651a1b7..e7624372abcfd0ee53d035b0ccc335eb45ad9d3c 100644 (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);
 }
 
index 487c3b1da2cffe14ea41e50370bb24ec75b3c892..83b197691c4810dfb6de24faa12488244b714c13 100644 (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");