mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 16:58:35 +00:00
Stings of files
method 1 high level (core most funcs that use switch_ivr_playback) Delimiter is set by a var which also enables the parser <action application="set" data="playback_delimiter=!"/> <action application="set" data="playback_sleep_val=500"/> <action application="playback" data="/ram/sr8k.wav!/ram/swimp.wav"/> method 2 low level (mod_file_string lower level code that uses direct file handles) Delimiter is always ! <action application="playback" data="file_string:///ram/sr8k.wav!/ram/swimp.wav"/> git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13182 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b266da15a4
commit
e223c655b8
@ -59,6 +59,7 @@ formats/mod_sndfile
|
|||||||
#formats/mod_shout
|
#formats/mod_shout
|
||||||
formats/mod_local_stream
|
formats/mod_local_stream
|
||||||
formats/mod_tone_stream
|
formats/mod_tone_stream
|
||||||
|
formats/mod_file_string
|
||||||
#languages/mod_python
|
#languages/mod_python
|
||||||
languages/mod_spidermonkey
|
languages/mod_spidermonkey
|
||||||
languages/mod_spidermonkey_teletone
|
languages/mod_spidermonkey_teletone
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
<!--For local streams (play all the files in a directory)-->
|
<!--For local streams (play all the files in a directory)-->
|
||||||
<load module="mod_local_stream"/>
|
<load module="mod_local_stream"/>
|
||||||
<load module="mod_tone_stream"/>
|
<load module="mod_tone_stream"/>
|
||||||
|
<load module="mod_file_string"/>
|
||||||
|
|
||||||
<!-- Timers -->
|
<!-- Timers -->
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, NULL, NULL);
|
|||||||
SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt)
|
SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt)
|
||||||
{
|
{
|
||||||
switch_caller_extension_t *extension = NULL;
|
switch_caller_extension_t *extension = NULL;
|
||||||
char *argv[128] = { 0 };
|
|
||||||
int argc;
|
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
int x = 0;
|
int x = 0;
|
||||||
char *lbuf;
|
char *lbuf;
|
||||||
@ -1834,7 +1832,7 @@ SWITCH_STANDARD_APP(playback_function)
|
|||||||
{
|
{
|
||||||
switch_input_args_t args = { 0 };
|
switch_input_args_t args = { 0 };
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
switch_status_t status;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
args.input_callback = on_dtmf;
|
args.input_callback = on_dtmf;
|
||||||
|
|
||||||
|
2
src/mod/formats/mod_file_string/Makefile
Normal file
2
src/mod/formats/mod_file_string/Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
BASE=../../../..
|
||||||
|
include $(BASE)/build/modmake.rules
|
283
src/mod/formats/mod_file_string/mod_file_string.2008.vcproj
Normal file
283
src/mod/formats/mod_file_string/mod_file_string.2008.vcproj
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="mod_file_string"
|
||||||
|
ProjectGUID="{2CA40887-1622-46A1-A7F9-17FD7E7E545B}"
|
||||||
|
RootNamespace="mod_file_string"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
<Platform
|
||||||
|
Name="x64"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|x64"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
TargetEnvironment="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="17"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|x64"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
TargetEnvironment="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="17"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<File
|
||||||
|
RelativePath=".\mod_file_string.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
188
src/mod/formats/mod_file_string/mod_file_string.c
Normal file
188
src/mod/formats/mod_file_string/mod_file_string.c
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
|
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||||
|
*
|
||||||
|
* 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 <anthm@freeswitch.org>
|
||||||
|
* Portions created by the Initial Developer are Copyright (C)
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Anthony Minessale II <anthm@freeswitch.org>
|
||||||
|
* Cesar Cepeda <cesar@auronix.com>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* mod_file_string.c -- Local Streaming Audio
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <switch.h>
|
||||||
|
/* for apr_pstrcat */
|
||||||
|
#define DEFAULT_PREBUFFER_SIZE 1024 * 64
|
||||||
|
|
||||||
|
SWITCH_MODULE_LOAD_FUNCTION(mod_file_string_load);
|
||||||
|
|
||||||
|
SWITCH_MODULE_DEFINITION(mod_file_string, mod_file_string_load, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
struct file_string_source;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
switch_mutex_t *mutex;
|
||||||
|
switch_hash_t *source_hash;
|
||||||
|
} globals;
|
||||||
|
|
||||||
|
struct file_string_context {
|
||||||
|
char *argv[128];
|
||||||
|
int argc;
|
||||||
|
int index;
|
||||||
|
int samples;
|
||||||
|
switch_file_handle_t fh;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct file_string_context file_string_context_t;
|
||||||
|
|
||||||
|
|
||||||
|
static int next_file(switch_file_handle_t *handle)
|
||||||
|
{
|
||||||
|
file_string_context_t *context = handle->private_info;
|
||||||
|
|
||||||
|
context->index++;
|
||||||
|
|
||||||
|
if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)) {
|
||||||
|
switch_core_file_close(&context->fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context->index == context->argc) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_core_file_open(&context->fh,
|
||||||
|
context->argv[context->index],
|
||||||
|
handle->channels,
|
||||||
|
handle->samplerate,
|
||||||
|
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->samples = context->fh.samples;
|
||||||
|
handle->samplerate = context->fh.samplerate;
|
||||||
|
handle->channels = context->fh.channels;
|
||||||
|
handle->format = context->fh.format;
|
||||||
|
handle->sections = context->fh.sections;
|
||||||
|
handle->seekable = context->fh.seekable;
|
||||||
|
handle->speed = context->fh.speed;
|
||||||
|
handle->interval = context->fh.interval;
|
||||||
|
|
||||||
|
if (context->index == 0) {
|
||||||
|
context->samples = (handle->samplerate / 1000) * 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static switch_status_t file_string_file_open(switch_file_handle_t *handle, const char *path)
|
||||||
|
{
|
||||||
|
file_string_context_t *context;
|
||||||
|
char *file_dup;
|
||||||
|
|
||||||
|
if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
context = switch_core_alloc(handle->memory_pool, sizeof(*context));
|
||||||
|
|
||||||
|
file_dup = switch_core_strdup(handle->memory_pool, path);
|
||||||
|
context->argc = switch_separate_string(file_dup, '!', context->argv, (sizeof(context->argv) / sizeof(context->argv[0])));
|
||||||
|
context->index = -1;
|
||||||
|
|
||||||
|
handle->private_info = context;
|
||||||
|
|
||||||
|
return next_file(handle) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static switch_status_t file_string_file_close(switch_file_handle_t *handle)
|
||||||
|
{
|
||||||
|
file_string_context_t *context = handle->private_info;
|
||||||
|
|
||||||
|
switch_core_file_close(&context->fh);
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static switch_status_t file_string_file_read(switch_file_handle_t *handle, void *data, size_t *len)
|
||||||
|
{
|
||||||
|
file_string_context_t *context = handle->private_info;
|
||||||
|
switch_status_t status;
|
||||||
|
size_t llen = *len;
|
||||||
|
|
||||||
|
if (context->samples > 0) {
|
||||||
|
if (*len > (size_t)context->samples) {
|
||||||
|
*len = context->samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
context->samples -= *len;
|
||||||
|
switch_generate_sln_silence((int16_t *) data, *len, 400);
|
||||||
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
} else {
|
||||||
|
status = switch_core_file_read(&context->fh, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != SWITCH_STATUS_SUCCESS) {
|
||||||
|
if (!next_file(handle)) {
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
*len = llen;
|
||||||
|
status = switch_core_file_read(&context->fh, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Registration */
|
||||||
|
|
||||||
|
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
|
||||||
|
|
||||||
|
SWITCH_MODULE_LOAD_FUNCTION(mod_file_string_load)
|
||||||
|
{
|
||||||
|
switch_file_interface_t *file_interface;
|
||||||
|
supported_formats[0] = "file_string";
|
||||||
|
|
||||||
|
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||||
|
file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
|
||||||
|
file_interface->interface_name = modname;
|
||||||
|
file_interface->extens = supported_formats;
|
||||||
|
file_interface->file_open = file_string_file_open;
|
||||||
|
file_interface->file_close = file_string_file_close;
|
||||||
|
file_interface->file_read = file_string_file_read;
|
||||||
|
|
||||||
|
memset(&globals, 0, sizeof(globals));
|
||||||
|
/* indicate that the module should continue to be loaded */
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For Emacs:
|
||||||
|
* Local Variables:
|
||||||
|
* mode:c
|
||||||
|
* indent-tabs-mode:t
|
||||||
|
* tab-width:4
|
||||||
|
* c-basic-offset:4
|
||||||
|
* End:
|
||||||
|
* For VIM:
|
||||||
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||||
|
*/
|
51
src/mod/formats/mod_file_string/mod_file_string.vcproj
Normal file
51
src/mod/formats/mod_file_string/mod_file_string.vcproj
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8.00"
|
||||||
|
Name="mod_file_string"
|
||||||
|
ProjectGUID="{2CA40887-1622-46A1-A7F9-17FD7E7E545B}"
|
||||||
|
RootNamespace="mod_file_string"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<File
|
||||||
|
RelativePath=".\mod_file_string.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@ -848,12 +848,34 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
const char *timer_name;
|
const char *timer_name;
|
||||||
const char *prebuf;
|
const char *prebuf;
|
||||||
const char *alt = NULL;
|
const char *alt = NULL;
|
||||||
|
const char *sleep_val;
|
||||||
|
const char *play_delimiter_val;
|
||||||
|
char play_delimiter = 0;
|
||||||
|
int sleep_val_i = 250;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
switch_size_t bread = 0;
|
switch_size_t bread = 0;
|
||||||
int l16 = 0;
|
int l16 = 0;
|
||||||
switch_codec_implementation_t read_impl = {0};
|
switch_codec_implementation_t read_impl = {0};
|
||||||
|
char *file_dup;
|
||||||
|
char *argv[128] = { 0 };
|
||||||
|
int argc;
|
||||||
|
int cur;
|
||||||
|
switch_status_t rst;
|
||||||
|
|
||||||
|
|
||||||
switch_core_session_get_read_impl(session, &read_impl);
|
switch_core_session_get_read_impl(session, &read_impl);
|
||||||
|
|
||||||
|
if ((play_delimiter_val = switch_channel_get_variable(channel, "playback_delimiter"))) {
|
||||||
|
play_delimiter = *play_delimiter_val;
|
||||||
|
|
||||||
|
if ((sleep_val = switch_channel_get_variable(channel, "playback_sleep_val"))) {
|
||||||
|
int tmp = atoi(sleep_val);
|
||||||
|
if (tmp >= 0) {
|
||||||
|
sleep_val_i = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
@ -862,14 +884,36 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
timer_name = switch_channel_get_variable(channel, "timer_name");
|
timer_name = switch_channel_get_variable(channel, "timer_name");
|
||||||
|
|
||||||
if (switch_strlen_zero(file) || !switch_channel_media_ready(channel)) {
|
if (switch_strlen_zero(file) || !switch_channel_media_ready(channel)) {
|
||||||
status = SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(read_impl.iananame, "l16")) {
|
if (!strcasecmp(read_impl.iananame, "l16")) {
|
||||||
l16++;
|
l16++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (play_delimiter) {
|
||||||
|
file_dup = switch_core_session_strdup(session, file);
|
||||||
|
argc = switch_separate_string(file_dup, play_delimiter, argv, (sizeof(argv) / sizeof(argv[0])));
|
||||||
|
} else {
|
||||||
|
argc = 1;
|
||||||
|
argv[0] = (char *)file;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(cur = 0; switch_channel_ready(channel) && cur < argc; cur++) {
|
||||||
|
file = argv[cur];
|
||||||
|
asis = 0;
|
||||||
|
eof = 0;
|
||||||
|
|
||||||
|
if (cur) {
|
||||||
|
fh->samples = sample_start = 0;
|
||||||
|
if (sleep_val_i) {
|
||||||
|
switch_ivr_sleep(session, sleep_val_i, SWITCH_FALSE, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
if ((alt = strchr(file, ':'))) {
|
if ((alt = strchr(file, ':'))) {
|
||||||
char *dup;
|
char *dup;
|
||||||
|
|
||||||
@ -883,10 +927,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
if ((arg = strchr(dup, ':'))) {
|
if ((arg = strchr(dup, ':'))) {
|
||||||
*arg++ = '\0';
|
*arg++ = '\0';
|
||||||
}
|
}
|
||||||
return switch_ivr_phrase_macro(session, dup, arg, lang, args);
|
if ((rst = switch_ivr_phrase_macro(session, dup, arg, lang, args) != SWITCH_STATUS_SUCCESS)) {
|
||||||
|
return rst;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (!strncasecmp(file, "say:", 4)) {
|
} else if (!strncasecmp(file, "say:", 4)) {
|
||||||
char *engine = NULL, *voice = NULL, *text = NULL;
|
char *engine = NULL, *voice = NULL, *text = NULL;
|
||||||
@ -904,17 +951,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!switch_strlen_zero(engine) && !switch_strlen_zero(voice) && !switch_strlen_zero(text)) {
|
if (!switch_strlen_zero(engine) && !switch_strlen_zero(voice) && !switch_strlen_zero(text)) {
|
||||||
return switch_ivr_speak_text(session, engine, voice, text, args);
|
if ((rst = switch_ivr_speak_text(session, engine, voice, text, args)) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
return rst;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
} else if (!switch_strlen_zero(engine) && !(voice && text)) {
|
} else if (!switch_strlen_zero(engine) && !(voice && text)) {
|
||||||
text = engine;
|
text = engine;
|
||||||
engine = (char *) switch_channel_get_variable(channel, "tts_engine");
|
engine = (char *) switch_channel_get_variable(channel, "tts_engine");
|
||||||
voice = (char *) switch_channel_get_variable(channel, "tts_voice");
|
voice = (char *) switch_channel_get_variable(channel, "tts_voice");
|
||||||
if (engine && text) {
|
if (engine && text) {
|
||||||
return switch_ivr_speak_text(session, engine, voice, text, args);
|
if ((rst = switch_ivr_speak_text(session, engine, voice, text, args)) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
return rst;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,6 +990,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!fh) {
|
if (!fh) {
|
||||||
fh = &lfh;
|
fh = &lfh;
|
||||||
memset(fh, 0, sizeof(lfh));
|
memset(fh, 0, sizeof(lfh));
|
||||||
@ -961,15 +1015,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
||||||
status = SWITCH_STATUS_NOTFOUND;
|
status = SWITCH_STATUS_NOTFOUND;
|
||||||
goto end;
|
continue;
|
||||||
}
|
}
|
||||||
if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
|
if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
|
||||||
asis = 1;
|
asis = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!abuf) {
|
||||||
switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
|
switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
|
||||||
write_frame.data = abuf;
|
write_frame.data = abuf;
|
||||||
write_frame.buflen = FILE_STARTSAMPLES;
|
write_frame.buflen = FILE_STARTSAMPLES;
|
||||||
|
}
|
||||||
|
|
||||||
if (sample_start > 0) {
|
if (sample_start > 0) {
|
||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
@ -1011,15 +1067,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
|
|
||||||
if (!fh->audio_buffer) {
|
if (!fh->audio_buffer) {
|
||||||
switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
|
switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
|
||||||
if (!fh->audio_buffer) {
|
switch_assert(fh->audio_buffer);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setup buffer failed\n");
|
|
||||||
|
|
||||||
switch_core_file_close(fh);
|
|
||||||
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
|
||||||
|
|
||||||
status = SWITCH_STATUS_GENERR;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asis) {
|
if (asis) {
|
||||||
@ -1029,6 +1077,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
} else {
|
} else {
|
||||||
codec_name = "L16";
|
codec_name = "L16";
|
||||||
|
|
||||||
|
if (!switch_core_codec_ready((&codec))) {
|
||||||
if (switch_core_codec_init(&codec,
|
if (switch_core_codec_init(&codec,
|
||||||
codec_name,
|
codec_name,
|
||||||
NULL,
|
NULL,
|
||||||
@ -1037,20 +1086,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG,
|
switch_log_printf(SWITCH_CHANNEL_LOG,
|
||||||
SWITCH_LOG_DEBUG, "Codec Activated %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
|
SWITCH_LOG_DEBUG, "Codec Activated %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
|
||||||
|
|
||||||
write_frame.codec = &codec;
|
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
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);
|
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
|
||||||
switch_core_file_close(fh);
|
switch_core_file_close(fh);
|
||||||
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
||||||
status = SWITCH_STATUS_GENERR;
|
status = SWITCH_STATUS_GENERR;
|
||||||
goto end;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
write_frame.codec = &codec;
|
||||||
|
|
||||||
samples = codec.implementation->samples_per_packet;
|
samples = codec.implementation->samples_per_packet;
|
||||||
framelen = codec.implementation->decoded_bytes_per_packet;
|
framelen = codec.implementation->decoded_bytes_per_packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timer_name) {
|
if (timer_name && !timer.samplecount) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
len = samples * 2;
|
len = samples * 2;
|
||||||
@ -1060,7 +1113,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
switch_core_file_close(fh);
|
switch_core_file_close(fh);
|
||||||
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
||||||
status = SWITCH_STATUS_GENERR;
|
status = SWITCH_STATUS_GENERR;
|
||||||
goto end;
|
continue;
|
||||||
}
|
}
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup timer success %u bytes per %d ms!\n", len, interval);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup timer success %u bytes per %d ms!\n", len, interval);
|
||||||
}
|
}
|
||||||
@ -1248,6 +1301,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
last_speed = fh->speed;
|
last_speed = fh->speed;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (olen < llen) {
|
if (olen < llen) {
|
||||||
uint8_t *dp = (uint8_t *) write_frame.data;
|
uint8_t *dp = (uint8_t *) write_frame.data;
|
||||||
memset(dp + (int) olen, 0, (int) (llen - olen));
|
memset(dp + (int) olen, 0, (int) (llen - olen));
|
||||||
@ -1325,26 +1379,33 @@ 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done playing file\n");
|
||||||
//switch_core_file_seek(fh, &fh->last_pos, 0, SEEK_CUR);
|
|
||||||
|
|
||||||
|
|
||||||
switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_out / read_impl.samples_per_second);
|
switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_out / read_impl.samples_per_second);
|
||||||
switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_out);
|
switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_out);
|
||||||
|
|
||||||
switch_core_file_close(fh);
|
switch_core_file_close(fh);
|
||||||
|
|
||||||
|
if (fh->audio_buffer) {
|
||||||
switch_buffer_destroy(&fh->audio_buffer);
|
switch_buffer_destroy(&fh->audio_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fh->sp_audio_buffer) {
|
||||||
switch_buffer_destroy(&fh->sp_audio_buffer);
|
switch_buffer_destroy(&fh->sp_audio_buffer);
|
||||||
if (!asis) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_core_codec_ready((&codec))) {
|
||||||
switch_core_codec_destroy(&codec);
|
switch_core_codec_destroy(&codec);
|
||||||
}
|
}
|
||||||
if (timer_name) {
|
|
||||||
|
if (timer.samplecount) {
|
||||||
/* End the audio absorbing thread */
|
/* End the audio absorbing thread */
|
||||||
switch_core_thread_session_end(session);
|
switch_core_thread_session_end(session);
|
||||||
switch_core_timer_destroy(&timer);
|
switch_core_timer_destroy(&timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
end:
|
|
||||||
switch_safe_free(abuf);
|
switch_safe_free(abuf);
|
||||||
|
|
||||||
switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
|
switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user