Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c442be0f
提交
c442be0f
authored
4月 07, 2016
作者:
Piotr Gregor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9036: [avmd] Cast to unsigned
Should fix warnings on Windoze.
上级
8baf10d2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
39 行删除
+33
-39
avmd_options.h
src/mod/applications/mod_avmd/avmd_options.h
+6
-2
mod_avmd.c
src/mod/applications/mod_avmd/mod_avmd.c
+27
-37
没有找到文件。
src/mod/applications/mod_avmd/avmd_options.h
浏览文件 @
c442be0f
...
...
@@ -2,7 +2,11 @@
* @brief Options controlling avmd module.
*
* @author Eric des Courtis
* @par Modifications: Piotr Gregor < piotrek.gregor gmail.com >
*
* Contributor(s):
*
* Piotr Gregor <piotrek.gregor gmail.com>:
* Eric des Courtis <eric.des.courtis@benbria.com>
*/
...
...
@@ -30,7 +34,7 @@
#define AVMD_REQUIRE_CONTINUOUS_STREAK
/* define number of samples to skip starting from the beginning
*
of
frame and after reset */
*
of the
frame and after reset */
#define AVMD_SAMLPE_TO_SKIP_N 6
/* define/undefine this to enable/disable simplified estimation
...
...
src/mod/applications/mod_avmd/mod_avmd.c
浏览文件 @
c442be0f
...
...
@@ -83,7 +83,8 @@
* for 8kHz audio. All the frequencies above 0.25 sampling rate
* will be aliased to some frequency below that threshold.
* This is not a problem here as we are interested in detection
* of any sine wave instead of detection of particular frequency.
* of any constant amplitude anf frequency sine wave instead
* of detection of particular frequency.
*/
#define MAX_FREQUENCY (2500.0)
/*! Maximum frequency as digital normalized frequency */
...
...
@@ -105,7 +106,7 @@
/*! FreeSWITCH CUSTOM event type. */
#define AVMD_EVENT_BEEP "avmd::beep"
#define AVMD_CHAR_BUF_LEN
1
0
#define AVMD_CHAR_BUF_LEN
2
0
#define AVMD_BUF_LINEAR_LEN 160
...
...
@@ -184,7 +185,7 @@ static int init_avmd_session_data(avmd_session_t *avmd_session,
#endif
avmd_session
->
sample_count
=
0
;
buf_sz
=
BEEP_LEN
(
avmd_session
->
rate
)
/
SINE_LEN
(
avmd_session
->
rate
);
buf_sz
=
BEEP_LEN
(
(
uint32_t
)
avmd_session
->
rate
)
/
(
uint32_t
)
SINE_LEN
(
avmd_session
->
rate
);
if
(
buf_sz
<
1
)
{
return
-
2
;
}
...
...
@@ -338,25 +339,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
"Can't access file [%s], error [%s]
\n
"
,
ACOS_TABLE_FILENAME
,
err
);
break
;
case
-
2
:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error creating file [%s], error [%s]
\n
"
,
ACOS_TABLE_FILENAME
,
err
);
break
;
case
-
3
:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Access rights are OK but can't open file [%s], error [%s]
\n
"
,
ACOS_TABLE_FILENAME
,
err
);
break
;
case
-
4
:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Access rights are OK but can't mmap file [%s], error [%s]
\n
"
,
ACOS_TABLE_FILENAME
,
err
);
break
;
default
:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unknown error [%d] while initializing fast cos table [%s], "
...
...
@@ -604,19 +601,22 @@ SWITCH_STANDARD_API(avmd_api_main)
switch_channel_set_private
(
channel
,
"_avmd_"
,
NULL
);
switch_core_media_bug_remove
(
fs_session
,
&
bug
);
switch_safe_free
(
ccmd
);
#ifdef AVMD_REPORT_STATUS
stream
->
write_function
(
stream
,
"+OK
\n
[%s] [%s] stopped.
\n\n
"
,
uuid_dup
,
switch_channel_get_name
(
channel
));
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_INFO
,
"Avmd on channel [%s] stopped!
\n
"
,
switch_channel_get_name
(
channel
));
#endif
goto
end
;
}
#ifdef AVMD_REPORT_STATUS
/* We have already started */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
"Avmd already started!
\n
"
);
stream
->
write_function
(
stream
,
"-ERR, avmd for FreeSWITCH session [%s]"
"
\n
already started
\n\n
"
,
uuid
);
#endif
goto
end
;
}
...
...
@@ -656,13 +656,8 @@ SWITCH_STANDARD_API(avmd_api_main)
"
\n
has no read codec assigned yet. Please try again.
\n\n
"
,
switch_channel_get_name
(
channel
),
uuid
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
<<<<<<<
HEAD
"Failed to start session. Channel [%s] has no codec assigned yet."
" Please try again
\n
"
,
switch_channel_get_name
(
channel
));
=======
"Failed to start session. Channel [%s] has no codec assigned yet.
\n
"
,
switch_channel_get_name
(
channel
));
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
goto
end
;
}
#endif
...
...
@@ -685,35 +680,24 @@ SWITCH_STANDARD_API(avmd_api_main)
" for FreeSWITCH session [%s]
\n
"
,
uuid
);
switch
(
res
)
{
case
-
1
:
<<<<<<<
HEAD
stream
->
write_function
(
stream
,
"-ERR, buffer error
\n\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
"Failed to init avmd session."
" Buffer error!
\n
"
);
break
;
case
-
2
:
=======
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
stream
->
write_function
(
stream
,
"-ERR, SMA buffer size is 0
\n\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
"Failed to init avmd session."
" SMA buffer size is 0!
\n
"
);
break
;
<<<<<<<
HEAD
case
-
3
:
=======
case
-
2
:
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
stream
->
write_function
(
stream
,
"-ERR, SMA buffer error
\n\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
"Failed to init avmd session."
" SMA buffer error
\n
"
);
break
;
<<<<<<<
HEAD
case
-
4
:
=======
case
-
3
:
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
stream
->
write_function
(
stream
,
"-ERR, SMA sqa buffer error
\n\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_ERROR
,
"Failed to init avmd session."
...
...
@@ -754,20 +738,13 @@ SWITCH_STANDARD_API(avmd_api_main)
/* Set the vmd tag to detect an existing vmd media bug */
switch_channel_set_private
(
channel
,
"_avmd_"
,
bug
);
<<<<<<<
HEAD
/* OK */
=======
/* Everything went according to plan! Notify the user */
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
#ifdef AVMD_REPORT_STATUS
stream
->
write_function
(
stream
,
"+OK
\n
[%s] [%s] started!
\n\n
"
,
uuid
,
switch_channel_get_name
(
channel
));
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_INFO
,
"Avmd on channel [%s] started!
\n
"
,
switch_channel_get_name
(
channel
));
<<<<<<<
HEAD
=======
>>>>>>>
FS
-
9031
:
[
avmd
]
Check
session
initialization
#endif
end
:
if
(
fs_session
)
{
...
...
@@ -787,6 +764,7 @@ end:
*/
static
void
avmd_process
(
avmd_session_t
*
session
,
switch_frame_t
*
frame
)
{
int
res
;
switch_event_t
*
event
;
switch_status_t
status
;
switch_event_t
*
event_copy
;
...
...
@@ -811,7 +789,7 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
if
(
session
->
state
.
beep_state
==
BEEP_DETECTED
)
return
;
/* Precompute values used heavily in the inner loop */
sine_len_i
=
SINE_LEN
(
session
->
rate
);
sine_len_i
=
(
uint32_t
)
SINE_LEN
(
session
->
rate
);
//sine_len = (double)sine_len_i;
//beep_len_i = BEEP_LEN(session->rate);
...
...
@@ -921,7 +899,6 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
#else
sma_digital_freq
=
0
.
5
*
acos
(
session
->
sma_b
.
sma
);
#endif
/* AVMD_FAST_MATH */
snprintf
(
buf
,
AVMD_CHAR_BUF_LEN
,
"%f"
,
TO_HZ
(
session
->
rate
,
sma_digital_freq
));
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"
);
...
...
@@ -934,8 +911,21 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
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"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"frequency"
,
buf
);
snprintf
(
buf
,
AVMD_CHAR_BUF_LEN
,
"%f"
,
v
);
res
=
snprintf
(
buf
,
AVMD_CHAR_BUF_LEN
,
"%f"
,
TO_HZ
(
session
->
rate
,
sma_digital_freq
));
if
(
res
<
0
||
res
>
AVMD_CHAR_BUF_LEN
-
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
->
session
),
SWITCH_LOG_ERROR
,
"Frequency truncated [%s], [%d] attempted!
\n
"
,
buf
,
res
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"frequency"
,
"ERROR (TRUNCATED)"
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"frequency"
,
buf
);
res
=
snprintf
(
buf
,
AVMD_CHAR_BUF_LEN
,
"%f"
,
v
);
if
(
res
<
0
||
res
>
AVMD_CHAR_BUF_LEN
-
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
->
session
),
SWITCH_LOG_ERROR
,
"Error, truncated [%s], [%d] attempeted!
\n
"
,
buf
,
res
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"variance"
,
"ERROR (TRUNCATED)"
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"variance"
,
buf
);
if
((
switch_event_dup
(
&
event_copy
,
event
))
!=
SWITCH_STATUS_SUCCESS
)
return
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论