]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
experimental new native code file eg name a ulaw file .PCMU etc
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 22 Sep 2006 19:50:54 +0000 (19:50 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 22 Sep 2006 19:50:54 +0000 (19:50 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2783 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/formats/mod_native_file/mod_native_file.c [new file with mode: 0644]
src/mod/formats/mod_native_file/mod_native_file.vcproj [new file with mode: 0644]
src/switch_ivr.c
src/switch_rtp.c

diff --git a/src/mod/formats/mod_native_file/mod_native_file.c b/src/mod/formats/mod_native_file/mod_native_file.c
new file mode 100644 (file)
index 0000000..7a6a600
--- /dev/null
@@ -0,0 +1,180 @@
+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct@yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II <anthmct@yahoo.com>
+ *
+ *
+ * mod_native_file.c -- Framework Demo Module
+ *
+ */
+#include <switch.h>
+
+static const char modname[] = "mod_native_file";
+
+struct native_file_context {
+       switch_file_t *fd;
+};
+
+typedef struct native_file_context native_file_context;
+
+static switch_status_t native_file_file_open(switch_file_handle_t *handle, char *path)
+{
+       native_file_context *context;
+       char *ext;
+       unsigned int flags = 0;
+
+       if ((ext = strrchr(path, '.')) == 0) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
+               return SWITCH_STATUS_GENERR;
+       }
+       ext++;
+
+       if ((context = switch_core_alloc(handle->memory_pool, sizeof(*context))) == 0) {
+               return SWITCH_STATUS_MEMERR;
+       }
+
+       if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
+               flags |= SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE;
+       }
+
+       if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
+               flags |= SWITCH_FOPEN_READ;
+       }
+
+       if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
+               return SWITCH_STATUS_GENERR;
+       }
+
+
+
+       handle->samples = 0;
+       handle->samplerate = 8000;
+       handle->channels = 1;
+       handle->format = 0;
+       handle->sections = 0;
+       handle->seekable = 0;
+       handle->speed = 0;
+       handle->private_info = context;
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
+
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t native_file_file_close(switch_file_handle_t *handle)
+{
+       native_file_context *context = handle->private_info;
+       
+       if (context->fd) {
+               switch_file_close(context->fd);
+               context->fd = NULL;
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+{
+       //native_file_context *context = handle->private_info;
+
+       return SWITCH_STATUS_FALSE;
+
+}
+
+static switch_status_t native_file_file_read(switch_file_handle_t *handle, void *data, size_t *len)
+{
+       native_file_context *context = handle->private_info;
+
+       return switch_file_read(context->fd, data, len);
+}
+
+static switch_status_t native_file_file_write(switch_file_handle_t *handle, void *data, size_t *len)
+{
+       native_file_context *context = handle->private_info;
+
+       return switch_file_write(context->fd, data, len);
+}
+
+static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
+{
+       //native_file_context *context = handle->private_info;
+
+       return SWITCH_STATUS_FALSE;
+}
+
+static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+{
+       return SWITCH_STATUS_FALSE;
+}
+
+/* Registration */
+
+static char *supported_formats[SWITCH_MAX_CODECS] = {0};
+
+static switch_file_interface_t native_file_file_interface = {
+       /*.interface_name */ modname,
+       /*.file_open */ native_file_file_open,
+       /*.file_close */ native_file_file_close,
+       /*.file_read */ native_file_file_read,
+       /*.file_write */ native_file_file_write,
+       /*.file_seek */ native_file_file_seek,
+       /*.file_set_string */ native_file_file_set_string,
+       /*.file_get_string */ native_file_file_get_string,
+       /*.extens */ NULL,
+       /*.next */ NULL,
+};
+
+static switch_loadable_module_interface_t native_file_module_interface = {
+       /*.module_name */ modname,
+       /*.endpoint_interface */ NULL,
+       /*.timer_interface */ NULL,
+       /*.dialplan_interface */ NULL,
+       /*.codec_interface */ NULL,
+       /*.application_interface */ NULL,
+       /*.api_interface */ NULL,
+       /*.file_interface */ &native_file_file_interface
+};
+
+
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+
+       const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
+       uint32_t num_codecs = switch_loadable_module_get_codecs(NULL, codecs, sizeof(codecs) / sizeof(codecs[0]));
+       uint32_t x;
+
+       for (x = 0 ; x < num_codecs; x++) {
+               supported_formats[x] = codecs[x]->iananame;
+       }
+
+       /* connect my internal structure to the blank pointer passed to me */
+       native_file_file_interface.extens = supported_formats;
+       *module_interface = &native_file_module_interface;
+
+       /* indicate that the module should continue to be loaded */
+       return SWITCH_STATUS_SUCCESS;
+}
diff --git a/src/mod/formats/mod_native_file/mod_native_file.vcproj b/src/mod/formats/mod_native_file/mod_native_file.vcproj
new file mode 100644 (file)
index 0000000..f098ba3
--- /dev/null
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="mod_native_file"\r
+       ProjectGUID="{AFAC0568-7548-42D5-9F6A-8D3400A1E4F6}"\r
+       RootNamespace="mod_native_file"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                               CommandLine=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\win32\libnative_file\&quot;"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"\r
+                               LinkIncremental="1"\r
+                               AdditionalLibraryDirectories="&quot;..\..\..\..\libs\libnative_file\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"\r
+                               SubSystem="2"\r
+                               ImportLibrary="$(OutDir)/mod_native_file.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                               CommandLine=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\win32\libnative_file\&quot;"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"\r
+                               LinkIncremental="1"\r
+                               AdditionalLibraryDirectories="&quot;..\..\..\..\libs\libnative_file\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"\r
+                               SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               LinkTimeCodeGeneration="1"\r
+                               ImportLibrary="$(OutDir)/mod_native_file.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\mod_native_file.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index 38fd6e3267900bc59de51870e5074914db3a8bfd..75cacbd7b889e3aca9a8b7fc5852bd746f5c0085 100644 (file)
@@ -580,7 +580,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define FILE_STARTSAMPLES 512 * 64
+#define FILE_STARTSAMPLES 1024 * 32
 #define FILE_BLOCKSIZE 1024 * 8
 #define FILE_BUFSIZE 1024 * 64
 
@@ -593,9 +593,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                                                                                   unsigned int buflen)
 {
        switch_channel_t *channel;
-       int16_t abuf[FILE_STARTSAMPLES+1];
+       int16_t abuf[FILE_STARTSAMPLES];
        char dtmf[128];
-       uint32_t interval = 0, samples = 0;
+       uint32_t interval = 0, samples = 0, framelen;
        uint32_t ilen = 0;
        switch_size_t olen = 0;
        switch_frame_t write_frame = {0};
@@ -610,7 +610,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
        switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
        const char *p;
        char *title = "", *copyright = "", *software = "", *artist = "", *comment = "", *date = "";
+       uint8_t asis = 0;
+       char *ext;
        
+       if (file) {
+               if ((ext = strrchr(file, '.'))) {
+                       ext++;
+               } else {
+                       char *new_file;
+                       ext = read_codec->implementation->iananame;
+                       uint32_t len = (uint32_t)strlen(file) + (uint32_t)strlen(ext) + 2;
+                       new_file = switch_core_session_alloc(session, len);
+                       snprintf(new_file, len, "%s.%s", file, ext);
+                       file = new_file;
+                       asis = 1;
+               }
+       }
+
        if (!fh) {
                fh = &lfh;
                memset(fh, 0, sizeof(lfh));
@@ -684,27 +700,40 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
        } 
 
-       codec_name = "L16";
-
-       if (switch_core_codec_init(&codec,
-                                                          codec_name,
-                                                          fh->samplerate,
-                                                          interval,
-                                                          fh->channels,
-                                                          SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                                          NULL, pool) == SWITCH_STATUS_SUCCESS) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
-
-               write_frame.codec = &codec;
+       if (asis) {
+               write_frame.codec = read_codec;
+               samples = read_codec->implementation->samples_per_frame;
+               framelen = read_codec->implementation->encoded_bytes_per_frame;
        } else {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n",
+               codec_name = "L16";
+
+               if (switch_core_codec_init(&codec,
+                                                                  codec_name,
+                                                                  fh->samplerate,
+                                                                  interval,
+                                                                  fh->channels,
+                                                                  SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+                                                                  NULL, pool) == SWITCH_STATUS_SUCCESS) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG,
+                                                         SWITCH_LOG_DEBUG,
+                                                         "Codec Activated %s@%uhz %u channels %dms\n",
+                                                         codec_name,
+                                                         fh->samplerate,
+                                                         fh->channels,
+                                                         interval);
+
+                       write_frame.codec = &codec;
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n",
                                                          codec_name, fh->samplerate, fh->channels, interval);
-               switch_core_file_close(fh);
-               switch_core_session_reset(session);
-               return SWITCH_STATUS_GENERR;
+                       switch_core_file_close(fh);
+                       switch_core_session_reset(session);
+                       return SWITCH_STATUS_GENERR;
+               }
+               samples = codec.implementation->samples_per_frame;
+               framelen = codec.implementation->bytes_per_frame;
        }
 
-       samples = codec.implementation->bytes_per_frame / 2;
 
        if (timer_name) {
                uint32_t len;
@@ -729,6 +758,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
        }
 
        ilen = samples;
+
        while(switch_channel_ready(channel)) {
                int done = 0;
                int do_speed = 1;
@@ -770,36 +800,41 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                }
                
                if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
-                       memset(abuf, 0, ilen * 2);
+                       memset(abuf, 0, framelen);
                        olen = ilen;
             do_speed = 0;
-               } else if (fh->audio_buffer && (switch_buffer_inuse(fh->audio_buffer) > (switch_size_t)(ilen * 2))) {
-                       switch_buffer_read(fh->audio_buffer, abuf, ilen * 2);
-                       olen = ilen;
+               } else if (fh->audio_buffer && (switch_buffer_inuse(fh->audio_buffer) > (switch_size_t)(framelen))) {
+                       switch_buffer_read(fh->audio_buffer, abuf, framelen);
+                       olen = asis ? framelen : ilen;
                        do_speed = 0;
                } else {
-                       olen = FILE_STARTSAMPLES;
+                       olen = 32 * framelen;
                        switch_core_file_read(fh, abuf, &olen);
-                       switch_buffer_write(fh->audio_buffer, abuf, olen * 2);
-                       olen = switch_buffer_read(fh->audio_buffer, abuf, ilen * 2) / 2;
+                       switch_buffer_write(fh->audio_buffer, abuf, asis ? olen : olen * 2);
+                       olen = switch_buffer_read(fh->audio_buffer, abuf, framelen);
+                       if (!asis) {
+                               olen /= 2;
+                       } 
                }
 
                if (done || olen <= 0) {
                        break;
                }
 
-               if (fh->speed > 2) {
-                       fh->speed = 2;
-               } else if (fh->speed < -2) {
-                       fh->speed = -2;
+               if (!asis) {
+                       if (fh->speed > 2) {
+                               fh->speed = 2;
+                       } else if (fh->speed < -2) {
+                               fh->speed = -2;
+                       }
                }
                
-               if (fh->audio_buffer && last_speed > -1 && last_speed != fh->speed) {
+               if (!asis && fh->audio_buffer && last_speed > -1 && last_speed != fh->speed) {
                        switch_buffer_zero(fh->audio_buffer);
                }
 
                
-               if (fh->speed && do_speed) {
+               if (!asis && fh->speed && do_speed) {
                        float factor = 0.25f * abs(fh->speed);
                        switch_size_t newlen, supplement, step;
                        short *bp = write_frame.data;
@@ -833,14 +868,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                        }
                        last_speed = fh->speed;
                        continue;
-               } 
-
-               write_frame.datalen = (uint32_t)(olen * 2);
+               }
+               
+               write_frame.datalen = (uint32_t)(olen * (asis ? 1 : 2));
                write_frame.samples = (uint32_t)olen;
 
+               
+
+
 #ifndef WIN32
 #if __BYTE_ORDER == __BIG_ENDIAN
-               switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);
+               if (!asis) {switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);}
 #endif
 #endif
                for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
@@ -879,8 +917,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done playing file\n");
        switch_core_file_close(fh);
        switch_buffer_destroy(&fh->audio_buffer);
-       switch_core_codec_destroy(&codec);
-
+       if (!asis) {
+               switch_core_codec_destroy(&codec);
+       }
        if (timer_name) {
                /* End the audio absorbing thread */
                switch_core_thread_session_end(&thread_session);
index d62ef8dcb028d7a577d50369fa66be8a65a83ea4..6384cce0b9914ef269e56cd5fbd034cbcba24eee 100644 (file)
@@ -588,7 +588,10 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
        if ((*rtp_session)->packet_buffer) {
                switch_buffer_destroy(&(*rtp_session)->packet_buffer);
        }
-                       
+       if ((*rtp_session)->dtmf_data.dtmf_buffer) {
+               switch_buffer_destroy(&(*rtp_session)->dtmf_data.dtmf_buffer);
+       }
+
        switch_rtp_kill_socket(*rtp_session);
        switch_socket_close((*rtp_session)->sock);
        (*rtp_session)->sock = NULL;