Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
43d89f02
提交
43d89f02
authored
2月 04, 2016
作者:
Piotr Gregor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: fix comments
Applying code guidelines. No side effects.
上级
19a86d55
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
41 行删除
+27
-41
desa2.c
src/mod/applications/mod_avmd/desa2.c
+2
-6
fast_acosf.c
src/mod/applications/mod_avmd/fast_acosf.c
+9
-13
mod_avmd.c
src/mod/applications/mod_avmd/mod_avmd.c
+16
-22
没有找到文件。
src/mod/applications/mod_avmd/desa2.c
浏览文件 @
43d89f02
...
...
@@ -35,7 +35,7 @@ extern double desa2(circ_buffer_t *b, size_t i)
x2sq
=
x2
*
x2
;
d
=
2
.
0
*
((
x2sq
)
-
(
x1
*
x3
));
if
(
d
==
0
.
0
)
return
0
.
0
;
if
(
d
==
0
.
0
)
return
0
.
0
;
n
=
((
x2sq
)
-
(
x0
*
x4
))
-
((
x1
*
x1
)
-
(
x0
*
x2
))
-
((
x3
*
x3
)
-
(
x2
*
x4
));
...
...
@@ -46,14 +46,10 @@ extern double desa2(circ_buffer_t *b, size_t i)
result
=
0
.
5
*
acos
(
n
/
d
);
#endif
if
(
ISNAN
(
result
)){
result
=
0
.
0
;
}
if
(
ISNAN
(
result
))
result
=
0
.
0
;
return
result
;
}
#endif
src/mod/applications/mod_avmd/fast_acosf.c
浏览文件 @
43d89f02
...
...
@@ -65,14 +65,12 @@ extern void compute_table(void)
acos_table_file
=
fopen
(
ACOS_TABLE_FILENAME
,
"w"
);
for
(
i
=
0
;
i
<
(
1
<<
25
);
i
++
){
f
=
acosf
(
float_from_index
(
i
));
ret
=
fwrite
(
&
f
,
sizeof
(
f
),
1
,
acos_table_file
);
assert
(
ret
!=
0
);
for
(
i
=
0
;
i
<
(
1
<<
25
);
i
++
)
{
f
=
acosf
(
float_from_index
(
i
));
ret
=
fwrite
(
&
f
,
sizeof
(
f
),
1
,
acos_table_file
);
assert
(
ret
!=
0
);
}
ret
=
fclose
(
acos_table_file
);
assert
(
ret
!=
EOF
);
}
...
...
@@ -82,13 +80,13 @@ extern void init_fast_acosf(void)
{
int
ret
;
if
(
acos_table
==
NULL
)
{
ret
=
access
(
ACOS_TABLE_FILENAME
,
F_OK
);
if
(
ret
==
0
)
compute_table
();
if
(
acos_table
==
NULL
)
{
ret
=
access
(
ACOS_TABLE_FILENAME
,
F_OK
);
if
(
ret
==
0
)
compute_table
();
acos_fd
=
open
(
ACOS_TABLE_FILENAME
,
O_RDONLY
);
if
(
acos_fd
==
-
1
)
perror
(
"Could not open file "
ACOS_TABLE_FILENAME
);
assert
(
acos_fd
!=
-
1
);
if
(
acos_fd
==
-
1
)
perror
(
"Could not open file "
ACOS_TABLE_FILENAME
);
assert
(
acos_fd
!=
-
1
);
acos_table
=
(
float
*
)
mmap
(
NULL
,
ACOS_TABLE_LENGTH
*
sizeof
(
float
),
...
...
@@ -136,5 +134,3 @@ static float float_from_index(uint32_t d)
#endif
src/mod/applications/mod_avmd/mod_avmd.c
浏览文件 @
43d89f02
...
...
@@ -128,10 +128,10 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
static
void
init_avmd_session_data
(
avmd_session_t
*
avmd_session
,
switch_core_session_t
*
fs_session
);
/*! \brief The avmd session data initialization function
/*! \brief The avmd session data initialization function
.
* @author Eric des Courtis
* @param avmd_session A reference to a avmd session
* @param fs_session A reference to a FreeSWITCH session
* @param avmd_session A reference to a avmd session
.
* @param fs_session A reference to a FreeSWITCH session
.
*/
static
void
init_avmd_session_data
(
avmd_session_t
*
avmd_session
,
switch_core_session_t
*
fs_session
)
{
...
...
@@ -159,7 +159,7 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
}
/*! \brief The callback function that is called when new audio data becomes available
/*! \brief The callback function that is called when new audio data becomes available
.
*
* @author Eric des Courtis
* @param bug A reference to the media bug.
...
...
@@ -203,7 +203,7 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
return
SWITCH_TRUE
;
}
/*! \brief FreeSWITCH module loading function
/*! \brief FreeSWITCH module loading function
.
*
* @author Eric des Courtis
* @return Load success or failure.
...
...
@@ -255,7 +255,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
}
/*! \brief FreeSWITCH application handler function.
* This handles calls made from applications such as LUA and the dialplan
* This handles calls made from applications such as LUA and the dialplan
.
*
* @author Eric des Courtis
* @return Success or failure of the function.
...
...
@@ -321,7 +321,7 @@ SWITCH_STANDARD_APP(avmd_start_function)
switch_channel_set_private
(
channel
,
"_avmd_"
,
bug
);
}
/*! \brief Called when the module shuts down
/*! \brief Called when the module shuts down
.
*
* @author Eric des Courtis
* @return The success or failure of the function.
...
...
@@ -476,10 +476,10 @@ end:
return
SWITCH_STATUS_SUCCESS
;
}
/*! \brief Process one frame of data with avmd algorithm
/*! \brief Process one frame of data with avmd algorithm
.
* @author Eric des Courtis
* @param session An avmd session
* @param frame A
audio frame
* @param session An avmd session
.
* @param frame A
n audio frame.
*/
static
void
avmd_process
(
avmd_session_t
*
session
,
switch_frame_t
*
frame
)
{
...
...
@@ -506,9 +506,7 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
b
=
&
session
->
b
;
/*! If beep has already been detected skip the CPU heavy stuff */
if
(
session
->
state
.
beep_state
==
BEEP_DETECTED
){
return
;
}
if
(
session
->
state
.
beep_state
==
BEEP_DETECTED
)
return
;
/*! Precompute values used heavily in the inner loop */
sine_len_i
=
SINE_LEN
(
session
->
rate
);
...
...
@@ -523,12 +521,12 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i);
/*! INNER LOOP -- OPTIMIZATION TARGET */
for
(
pos
=
session
->
pos
;
pos
<
(
GET_CURRENT_POS
(
b
)
-
P
);
pos
++
)
{
for
(
pos
=
session
->
pos
;
pos
<
(
GET_CURRENT_POS
(
b
)
-
P
);
pos
++
)
{
if
((
pos
%
sine_len_i
)
==
0
)
{
/*! Get a desa2 frequency estimate every sine len */
f
=
desa2
(
b
,
pos
);
if
(
f
<
MIN_FREQUENCY_R
(
session
->
rate
)
||
f
>
MAX_FREQUENCY_R
(
session
->
rate
))
{
if
(
f
<
MIN_FREQUENCY_R
(
session
->
rate
)
||
f
>
MAX_FREQUENCY_R
(
session
->
rate
))
{
v
=
99999
.
0
;
RESET_SMA_BUFFER
(
&
session
->
sma_b
);
RESET_SMA_BUFFER
(
&
session
->
sqa_b
);
...
...
@@ -543,24 +541,20 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
}
/*! If variance is less than threshold then we have detection */
if
(
v
<
VARIANCE_THRESHOLD
)
{
if
(
v
<
VARIANCE_THRESHOLD
)
{
switch_channel_set_variable_printf
(
channel
,
"avmd_total_time"
,
"%d"
,
(
int
)(
switch_micro_time_now
()
-
session
->
start_time
)
/
1000
);
switch_channel_execute_on
(
channel
,
"execute_on_avmd_beep"
);
/*! Throw an event to FreeSWITCH */
status
=
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
AVMD_EVENT_BEEP
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
return
;
}
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
return
;
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Beep-Status"
,
"stop"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Unique-ID"
,
switch_core_session_get_uuid
(
session
->
session
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-command"
,
"avmd"
);
if
((
switch_event_dup
(
&
event_copy
,
event
))
!=
SWITCH_STATUS_SUCCESS
)
{
return
;
}
if
((
switch_event_dup
(
&
event_copy
,
event
))
!=
SWITCH_STATUS_SUCCESS
)
return
;
switch_core_session_queue_event
(
session
->
session
,
&
event
);
switch_event_fire
(
&
event_copy
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论