Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6f2c455f
提交
6f2c455f
authored
9月 14, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tone2wav
上级
b7751868
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
232 行增加
和
21 行删除
+232
-21
Makefile.am
Makefile.am
+9
-1
libteletone_generate.c
libs/freetdm/src/libteletone_generate.c
+10
-10
libteletone_generate.c
libs/libteletone/src/libteletone_generate.c
+6
-6
switch_loadable_module.h
src/include/switch_loadable_module.h
+1
-1
switch_types.h
src/include/switch_types.h
+2
-1
switch_core.c
src/switch_core.c
+4
-1
switch_loadable_module.c
src/switch_loadable_module.c
+3
-1
switch_rtp.c
src/switch_rtp.c
+4
-0
tone2wav.c
src/tone2wav.c
+193
-0
没有找到文件。
Makefile.am
浏览文件 @
6f2c455f
...
...
@@ -267,7 +267,7 @@ src/include/switch_swigable_cpp.h: $(switch_srcdir)/src/include/switch_cpp.h
##
## Applications
##
bin_PROGRAMS
=
freeswitch fs_cli fs_ivrd
bin_PROGRAMS
=
freeswitch fs_cli fs_ivrd
tone2wav
##
## fs_cli ()
...
...
@@ -281,6 +281,14 @@ fs_cli_CFLAGS += -DHAVE_EDITLINE -I$(switch_srcdir)/libs/libedit/src
fs_cli_LDADD
=
libs/libedit/src/.libs/libedit.a
endif
##
## tone2wav ()
##
tone2wav_SOURCES
=
src/tone2wav.c
tone2wav_CFLAGS
=
$(AM_CFLAGS)
tone2wav_LDFLAGS
=
$(AM_LDFLAGS)
-lm
tone2wav_LDADD
=
libfreeswitch.la
##
## fs_ivrd ()
##
...
...
libs/freetdm/src/libteletone_generate.c
浏览文件 @
6f2c455f
...
...
@@ -244,7 +244,7 @@ TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone
if
(
ts
->
debug
&&
ts
->
debug_stream
)
{
if
(
map
->
freqs
[
0
]
<=
0
)
{
fprintf
(
ts
->
debug_stream
,
"wait %d (%dms)
\n
"
,
wait
,
wait
/
(
ts
->
rate
/
1000
));
fprintf
(
ts
->
debug_stream
,
"wait %d (%dms)
\n
"
,
wait
,
wait
/
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
));
}
else
{
fprintf
(
ts
->
debug_stream
,
"Generate: ("
);
...
...
@@ -256,14 +256,14 @@ TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone
") [volume %0.2fdB; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %0.2fdB; decay_step %d(%dms); wrote %d bytes]
\n
"
,
ts
->
volume
,
duration
,
duration
/
(
ts
->
rate
/
1000
),
duration
/
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
),
ts
->
channels
,
ts
->
channels
==
1
?
""
:
"s"
,
wait
,
wait
/
(
ts
->
rate
/
1000
),
wait
/
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
),
ts
->
decay_factor
,
ts
->
decay_step
,
ts
->
decay_step
/
(
ts
->
rate
/
1000
),
ts
->
decay_step
/
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
),
ts
->
samples
*
2
);
}
}
...
...
@@ -307,7 +307,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
ts
->
rate
=
atoi
(
cur
+
2
);
break
;
case
'd'
:
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
break
;
case
'v'
:
{
...
...
@@ -318,18 +318,18 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
}
break
;
case
'>'
:
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
ts
->
decay_direction
=
-
1
;
break
;
case
'<'
:
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
ts
->
decay_direction
=
1
;
break
;
case
'+'
:
ts
->
decay_factor
=
(
float
)
atof
(
cur
+
2
);
break
;
case
'w'
:
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
break
;
case
'l'
:
ts
->
loops
=
atoi
(
cur
+
2
);
...
...
@@ -369,10 +369,10 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
*
next
++
=
'\0'
;
}
if
(
i
==
0
)
{
ts
->
tmp_duration
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
);
ts
->
tmp_duration
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
i
++
;
}
else
if
(
i
==
1
)
{
ts
->
tmp_wait
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
);
ts
->
tmp_wait
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
i
++
;
}
else
{
mymap
.
freqs
[
i
++
-
2
]
=
atof
(
p
);
...
...
libs/libteletone/src/libteletone_generate.c
浏览文件 @
6f2c455f
...
...
@@ -355,7 +355,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
ts
->
rate
=
atoi
(
cur
+
2
);
break
;
case
'd'
:
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
break
;
case
'v'
:
{
...
...
@@ -366,18 +366,18 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
}
break
;
case
'>'
:
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
ts
->
decay_direction
=
-
1
;
break
;
case
'<'
:
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
ts
->
decay_direction
=
1
;
break
;
case
'+'
:
ts
->
decay_factor
=
(
float
)
atof
(
cur
+
2
);
break
;
case
'w'
:
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
break
;
case
'l'
:
ts
->
loops
=
atoi
(
cur
+
2
);
...
...
@@ -417,10 +417,10 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
*
next
++
=
'\0'
;
}
if
(
i
==
0
)
{
ts
->
tmp_duration
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
);
ts
->
tmp_duration
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
i
++
;
}
else
if
(
i
==
1
)
{
ts
->
tmp_wait
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
);
ts
->
tmp_wait
=
atoi
(
p
)
*
(
ts
->
rate
/
1000
/
ts
->
channels
?
ts
->
channels
:
1
);
i
++
;
}
else
{
mymap
.
freqs
[
i
++
-
2
]
=
atof
(
p
);
...
...
src/include/switch_loadable_module.h
浏览文件 @
6f2c455f
...
...
@@ -92,7 +92,7 @@ SWITCH_BEGIN_EXTERN_C
\brief Initilize the module backend and load all the modules
\return SWITCH_STATUS_SUCCESS when complete
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_init
(
voi
d
);
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_init
(
switch_bool_t
autoloa
d
);
/*!
\brief Shutdown the module backend and call the shutdown routine in all loaded modules
...
...
src/include/switch_types.h
浏览文件 @
6f2c455f
...
...
@@ -255,7 +255,8 @@ typedef enum {
SCF_USE_CLOCK_RT
=
(
1
<<
10
),
SCF_VERBOSE_EVENTS
=
(
1
<<
11
),
SCF_USE_WIN32_MONOTONIC
=
(
1
<<
12
),
SCF_AUTO_SCHEMAS
=
(
1
<<
13
)
SCF_AUTO_SCHEMAS
=
(
1
<<
13
),
SCF_MINIMAL
=
(
1
<<
14
)
}
switch_core_flag_enum_t
;
typedef
uint32_t
switch_core_flag_t
;
...
...
src/switch_core.c
浏览文件 @
6f2c455f
...
...
@@ -1315,6 +1315,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_log_init
(
runtime
.
memory_pool
,
runtime
.
colorize_console
);
if
(
flags
&
SCF_MINIMAL
)
return
SWITCH_STATUS_SUCCESS
;
runtime
.
tipping_point
=
5000
;
runtime
.
timer_affinity
=
-
1
;
...
...
@@ -1594,7 +1596,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CONSOLE
,
"Bringing up environment.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CONSOLE
,
"Loading Modules.
\n
"
);
if
(
switch_loadable_module_init
()
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_loadable_module_init
(
SWITCH_TRUE
)
!=
SWITCH_STATUS_SUCCESS
)
{
*
err
=
"Cannot load modules"
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CONSOLE
,
"Error: %s
\n
"
,
*
err
);
return
SWITCH_STATUS_GENERR
;
...
...
@@ -1902,6 +1904,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_scheduler_task_thread_stop
();
switch_rtp_shutdown
();
if
(
switch_test_flag
((
&
runtime
),
SCF_USE_AUTO_NAT
))
{
switch_nat_shutdown
();
}
...
...
src/switch_loadable_module.c
浏览文件 @
6f2c455f
...
...
@@ -1218,7 +1218,7 @@ static void switch_loadable_module_path_init()
}
#endif
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_init
()
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_init
(
switch_bool_t
autoload
)
{
apr_finfo_t
finfo
=
{
0
};
...
...
@@ -1268,6 +1268,8 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
switch_core_hash_init_nocase
(
&
loadable_modules
.
dialplan_hash
,
loadable_modules
.
pool
);
switch_mutex_init
(
&
loadable_modules
.
mutex
,
SWITCH_MUTEX_NESTED
,
loadable_modules
.
pool
);
if
(
!
autoload
)
return
SWITCH_STATUS_SUCCESS
;
switch_loadable_module_load_module
(
""
,
"CORE_SOFTTIMER_MODULE"
,
SWITCH_FALSE
,
&
err
);
switch_loadable_module_load_module
(
""
,
"CORE_PCM_MODULE"
,
SWITCH_FALSE
,
&
err
);
...
...
src/switch_rtp.c
浏览文件 @
6f2c455f
...
...
@@ -662,6 +662,10 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void)
const
void
*
var
;
void
*
val
;
if
(
!
global_init
)
{
return
;
}
switch_mutex_lock
(
port_lock
);
for
(
hi
=
switch_hash_first
(
NULL
,
alloc_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
...
...
src/tone2wav.c
0 → 100644
浏览文件 @
6f2c455f
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, 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>
* Michael Jerris <mike@jerris.com>
* Pawel Pierscionek <pawel@voiceworks.pl>
* Bret McDanel <trixter AT 0xdecafbad.com>
*
*
* tone2wav.c -- Generate a .wav from teletone spec
*
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#ifndef WIN32
#ifdef HAVE_SETRLIMIT
#include <sys/resource.h>
#endif
#endif
#include <switch.h>
#include <switch_version.h>
/* Picky compiler */
#ifdef __ICC
#pragma warning (disable:167)
#endif
static
int
teletone_handler
(
teletone_generation_session_t
*
ts
,
teletone_tone_map_t
*
map
)
{
switch_file_handle_t
*
fh
=
(
switch_file_handle_t
*
)
ts
->
user_data
;
int
wrote
;
switch_size_t
len
;
wrote
=
teletone_mux_tones
(
ts
,
map
);
len
=
wrote
;
if
(
switch_core_file_write
(
fh
,
ts
->
buffer
,
&
len
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
-
1
;
}
return
0
;
}
#define fail() r = 255; goto end
/* the main application entry point */
int
main
(
int
argc
,
char
*
argv
[])
{
teletone_generation_session_t
ts
;
int
file_flags
=
SWITCH_FILE_FLAG_WRITE
|
SWITCH_FILE_DATA_SHORT
;
int
r
=
0
;
int
rate
=
8000
;
char
*
file
=
NULL
,
*
script
=
NULL
;
switch_file_handle_t
fh
=
{
0
};
const
char
*
err
=
NULL
;
switch_bool_t
verbose
=
SWITCH_FALSE
;
int
i
=
0
,
c
=
1
,
help
=
0
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
!
strstr
(
argv
[
i
],
"-"
))
break
;
if
(
!
strcmp
(
argv
[
i
],
"-v"
))
{
verbose
=
SWITCH_TRUE
;
}
if
(
!
strcmp
(
argv
[
i
],
"-s"
))
{
c
=
2
;
}
if
(
!
strcmp
(
argv
[
i
],
"-h"
))
{
help
=
1
;
}
if
(
!
strncmp
(
argv
[
i
],
"-R"
,
2
))
{
char
*
p
=
argv
[
i
]
+
2
;
if
(
p
)
{
int
tmp
=
atoi
(
p
);
if
(
tmp
>
0
)
{
rate
=
tmp
;
}
}
}
}
if
(
argc
-
i
!=
2
||
help
)
{
char
*
app
=
NULL
;
if
(
!
help
)
printf
(
"Invalid input!
\n
"
);
if
((
app
=
strrchr
(
argv
[
0
],
'/'
)))
{
app
++
;
}
else
{
app
=
argv
[
0
];
}
printf
(
"USAGE: %s [options] <file> <tones>
\n
"
,
app
);
printf
(
"================================================================================
\n
"
);
printf
(
"Options:
\n
"
"-s
\t\t
Stereo
\n
"
"-h
\t\t
Help
\n
"
"-R<rate>
\t
Set Rate (8000,16000,32000,48000) etc.
\n
"
"-v
\t\t
Verbose Logging
\n
"
"<file>
\t\t
Any file supported by libsndfile
\n
"
"<tones>
\t\t
A valid teletone script http://wiki.freeswitch.org/wiki/TGML"
"
\n\n\n
"
);
return
255
;
}
file
=
argv
[
i
];
script
=
argv
[
i
+
1
];
if
(
switch_core_init
(
SCF_MINIMAL
,
verbose
,
&
err
)
!=
SWITCH_STATUS_SUCCESS
)
{
printf
(
"Cannot init core [%s]
\n
"
,
err
);
fail
();
}
switch_loadable_module_init
(
SWITCH_FALSE
);
if
(
switch_loadable_module_load_module
((
char
*
)
SWITCH_GLOBAL_dirs
.
mod_dir
,
(
char
*
)
"mod_sndfile"
,
SWITCH_TRUE
,
&
err
)
!=
SWITCH_STATUS_SUCCESS
)
{
printf
(
"Cannot init mod_sndfile [%s]
\n
"
,
err
);
fail
();
}
if
(
switch_core_file_open
(
&
fh
,
file
,
c
,
rate
,
file_flags
,
NULL
)
!=
SWITCH_STATUS_SUCCESS
)
{
printf
(
"Cannot open file %s
\n
"
,
file
);
fail
();
}
teletone_init_session
(
&
ts
,
0
,
teletone_handler
,
&
fh
);
ts
.
rate
=
rate
;
ts
.
channels
=
c
;
ts
.
duration
=
250
*
(
rate
/
1000
/
c
);
ts
.
wait
=
50
*
(
rate
/
1000
/
c
);
if
(
verbose
)
{
ts
.
debug
=
10
;
ts
.
debug_stream
=
stdout
;
}
teletone_run
(
&
ts
,
script
);
teletone_destroy_session
(
&
ts
);
switch_core_file_close
(
&
fh
);
printf
(
"File: %s generated.....
\n
Please support:
\n\n
FreeSWITCH http://www.freeswitch.org
\n
ClueCon http://www.cluecon.com
\n
"
,
file
);
end:
switch_core_destroy
();
return
r
;
}
/* 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:
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论