Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
f6fd9546
提交
f6fd9546
authored
11月 29, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
api tweaks
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@3485
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
6b5a464f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
53 行增加
和
11 行删除
+53
-11
switch_module_interfaces.h
src/include/switch_module_interfaces.h
+2
-0
mod_spidermonkey.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
+16
-6
switch_event.c
src/switch_event.c
+5
-5
switch_ivr.c
src/switch_ivr.c
+30
-0
没有找到文件。
src/include/switch_module_interfaces.h
浏览文件 @
f6fd9546
...
@@ -313,6 +313,8 @@ struct switch_file_handle {
...
@@ -313,6 +313,8 @@ struct switch_file_handle {
void
*
private_info
;
void
*
private_info
;
int64_t
pos
;
int64_t
pos
;
switch_buffer_t
*
audio_buffer
;
switch_buffer_t
*
audio_buffer
;
uint32_t
thresh
;
uint32_t
silence_hits
;
};
};
/*! \brief Abstract interface to an asr module */
/*! \brief Abstract interface to an asr module */
...
...
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
浏览文件 @
f6fd9546
...
@@ -828,7 +828,7 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -828,7 +828,7 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
int
len
=
0
;
int
len
=
0
;
switch_input_callback_function_t
dtmf_func
=
NULL
;
switch_input_callback_function_t
dtmf_func
=
NULL
;
struct
input_callback_state
cb_state
=
{
0
};
struct
input_callback_state
cb_state
=
{
0
};
switch_file_handle_t
fh
;
switch_file_handle_t
fh
=
{
0
}
;
JSFunction
*
function
;
JSFunction
*
function
;
int32
limit
=
0
;
int32
limit
=
0
;
...
@@ -860,9 +860,21 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -860,9 +860,21 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
if
(
argc
>
3
)
{
if
(
argc
>
3
)
{
JS_ValueToInt32
(
cx
,
argv
[
3
],
&
limit
);
JS_ValueToInt32
(
cx
,
argv
[
3
],
&
limit
);
}
}
if
(
argc
>
4
)
{
int32_t
thresh
;
JS_ValueToInt32
(
cx
,
argv
[
4
],
&
thresh
);
fh
.
thresh
=
thresh
;
}
if
(
argc
>
5
)
{
int32_t
silence_hits
;
JS_ValueToInt32
(
cx
,
argv
[
5
],
&
silence_hits
);
fh
.
silence_hits
=
silence_hits
;
}
}
}
memset
(
&
fh
,
0
,
sizeof
(
fh
));
cb_state
.
extra
=
&
fh
;
cb_state
.
extra
=
&
fh
;
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
switch_ivr_record_file
(
jss
->
session
,
&
fh
,
file_name
,
dtmf_func
,
bp
,
len
,
limit
);
switch_ivr_record_file
(
jss
->
session
,
&
fh
,
file_name
,
dtmf_func
,
bp
,
len
,
limit
);
...
@@ -925,7 +937,7 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -925,7 +937,7 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
int
len
=
0
;
int
len
=
0
;
switch_input_callback_function_t
dtmf_func
=
NULL
;
switch_input_callback_function_t
dtmf_func
=
NULL
;
struct
input_callback_state
cb_state
=
{
0
};
struct
input_callback_state
cb_state
=
{
0
};
switch_file_handle_t
fh
;
switch_file_handle_t
fh
=
{
0
}
;
JSFunction
*
function
;
JSFunction
*
function
;
channel
=
switch_core_session_get_channel
(
jss
->
session
);
channel
=
switch_core_session_get_channel
(
jss
->
session
);
...
@@ -963,12 +975,10 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -963,12 +975,10 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
if
(
argc
>
4
)
{
if
(
argc
>
4
)
{
int32
samps
;
int32
samps
;
uint32_t
pos
=
0
;
JS_ValueToInt32
(
cx
,
argv
[
4
],
&
samps
);
JS_ValueToInt32
(
cx
,
argv
[
4
],
&
samps
);
switch_core_file_seek
(
&
fh
,
&
pos
,
samps
,
SEEK_CUR
)
;
fh
.
samples
=
samps
;
}
}
memset
(
&
fh
,
0
,
sizeof
(
fh
));
cb_state
.
extra
=
&
fh
;
cb_state
.
extra
=
&
fh
;
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
switch_ivr_play_file
(
jss
->
session
,
&
fh
,
file_name
,
timer_name
,
dtmf_func
,
bp
,
len
);
switch_ivr_play_file
(
jss
->
session
,
&
fh
,
file_name
,
timer_name
,
dtmf_func
,
bp
,
len
);
...
...
src/switch_event.c
浏览文件 @
f6fd9546
...
@@ -606,7 +606,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
...
@@ -606,7 +606,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
*
str
=
NULL
;
*
str
=
NULL
;
if
(
!
(
buf
=
malloc
(
blocksize
)))
{
dlen
=
blocksize
*
2
;
if
(
!
(
buf
=
malloc
(
dlen
)))
{
return
SWITCH_STATUS_MEMERR
;
return
SWITCH_STATUS_MEMERR
;
}
}
...
@@ -615,9 +617,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
...
@@ -615,9 +617,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
return
SWITCH_STATUS_MEMERR
;
return
SWITCH_STATUS_MEMERR
;
}
}
dlen
=
blocksize
;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "hit serialze!.\n");
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"hit serialze!.
\n
"
);
for
(
hp
=
event
->
headers
;
hp
;
hp
=
hp
->
next
)
{
for
(
hp
=
event
->
headers
;
hp
;
hp
=
hp
->
next
)
{
/*
/*
* grab enough memory to store 3x the string (url encode takes one char and turns it into %XX)
* grab enough memory to store 3x the string (url encode takes one char and turns it into %XX)
...
@@ -628,7 +628,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
...
@@ -628,7 +628,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
*/
*/
if
(
encode_len
<
((
strlen
(
hp
->
value
)
*
3
)
+
1
))
{
if
(
encode_len
<
((
strlen
(
hp
->
value
)
*
3
)
+
1
))
{
char
*
tmp
;
char
*
tmp
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Allocing %d was %d.
\n
"
,
((
strlen
(
hp
->
value
)
*
3
)
+
1
),
encode_len
);
//
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Allocing %d was %d.\n", ((strlen(hp->value) * 3) + 1), encode_len);
/* we can use realloc for initial alloc as well, if encode_buf is zero it treats it as a malloc */
/* we can use realloc for initial alloc as well, if encode_buf is zero it treats it as a malloc */
if
(
!
(
tmp
=
realloc
(
encode_buf
,
((
strlen
(
hp
->
value
)
*
3
)
+
1
))))
{
if
(
!
(
tmp
=
realloc
(
encode_buf
,
((
strlen
(
hp
->
value
)
*
3
)
+
1
))))
{
/* oh boy, ram's gone, give back what little we grabbed and bail */
/* oh boy, ram's gone, give back what little we grabbed and bail */
...
...
src/switch_ivr.c
浏览文件 @
f6fd9546
...
@@ -428,6 +428,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
...
@@ -428,6 +428,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
start
=
time
(
NULL
);
start
=
time
(
NULL
);
}
}
if
(
fh
->
thresh
)
{
if
(
!
fh
->
silence_hits
)
{
fh
->
silence_hits
=
20
;
}
}
while
(
switch_channel_ready
(
channel
))
{
while
(
switch_channel_ready
(
channel
))
{
switch_size_t
len
;
switch_size_t
len
;
switch_event_t
*
event
;
switch_event_t
*
event
;
...
@@ -477,6 +483,26 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
...
@@ -477,6 +483,26 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
if
(
!
SWITCH_READ_ACCEPTABLE
(
status
))
{
if
(
!
SWITCH_READ_ACCEPTABLE
(
status
))
{
break
;
break
;
}
}
if
(
fh
->
thresh
)
{
int16_t
*
fdata
=
(
int16_t
*
)
read_frame
->
data
;
uint32_t
samples
=
read_frame
->
datalen
/
sizeof
(
*
fdata
);
uint32_t
score
,
count
=
0
,
j
=
0
;
double
energy
=
0
;
for
(
count
=
0
;
count
<
samples
;
count
++
)
{
energy
+=
abs
(
fdata
[
j
]);
j
+=
read_codec
->
implementation
->
number_of_channels
;
}
score
=
energy
/
samples
;
if
(
score
<
fh
->
thresh
)
{
if
(
!--
fh
->
silence_hits
)
{
break
;
}
}
}
if
(
!
switch_test_flag
(
fh
,
SWITCH_FILE_PAUSE
))
{
if
(
!
switch_test_flag
(
fh
,
SWITCH_FILE_PAUSE
))
{
len
=
(
switch_size_t
)
read_frame
->
datalen
/
2
;
len
=
(
switch_size_t
)
read_frame
->
datalen
/
2
;
switch_core_file_write
(
fh
,
read_frame
->
data
,
&
len
);
switch_core_file_write
(
fh
,
read_frame
->
data
,
&
len
);
...
@@ -983,6 +1009,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
...
@@ -983,6 +1009,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
write_frame
.
data
=
abuf
;
write_frame
.
data
=
abuf
;
write_frame
.
buflen
=
sizeof
(
abuf
);
write_frame
.
buflen
=
sizeof
(
abuf
);
if
(
fh
->
samples
)
{
uint32_t
pos
=
0
;
switch_core_file_seek
(
fh
,
&
pos
,
fh
->
samples
,
SEEK_CUR
);
}
if
(
switch_core_file_get_string
(
fh
,
SWITCH_AUDIO_COL_STR_TITLE
,
&
p
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_file_get_string
(
fh
,
SWITCH_AUDIO_COL_STR_TITLE
,
&
p
)
==
SWITCH_STATUS_SUCCESS
)
{
title
=
(
char
*
)
switch_core_session_strdup
(
session
,
(
char
*
)
p
);
title
=
(
char
*
)
switch_core_session_strdup
(
session
,
(
char
*
)
p
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论