Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
0a893bac
提交
0a893bac
authored
4月 04, 2016
作者:
Piotr Gregor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9016 Avmd segfaults on NULL read codec
Now it will simply exit. Also added more descriptive and clear error reporting.
上级
48dcab82
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
19 行删除
+66
-19
avmd_desa2_tweaked.c
src/mod/applications/mod_avmd/avmd_desa2_tweaked.c
+1
-2
avmd_desa2_tweaked.h
src/mod/applications/mod_avmd/avmd_desa2_tweaked.h
+1
-2
mod_avmd.c
src/mod/applications/mod_avmd/mod_avmd.c
+64
-15
没有找到文件。
src/mod/applications/mod_avmd/avmd_desa2_tweaked.c
浏览文件 @
0a893bac
...
@@ -20,8 +20,7 @@
...
@@ -20,8 +20,7 @@
double
double
avmd_desa2_tweaked
(
circ_buffer_t
*
b
,
size_t
i
,
avmd_desa2_tweaked
(
circ_buffer_t
*
b
,
size_t
i
)
switch_core_session_t
*
session
)
{
{
double
d
;
double
d
;
double
n
;
double
n
;
...
...
src/mod/applications/mod_avmd/avmd_desa2_tweaked.h
浏览文件 @
0a893bac
...
@@ -35,8 +35,7 @@
...
@@ -35,8 +35,7 @@
* from this partial result using
* from this partial result using
* 0.5 * acos(n/d)
* 0.5 * acos(n/d)
*/
*/
double
avmd_desa2_tweaked
(
circ_buffer_t
*
b
,
size_t
i
,
double
avmd_desa2_tweaked
(
circ_buffer_t
*
b
,
size_t
i
);
switch_core_session_t
*
session
);
#endif
/* __AVMD_DESA2_TWEAKED_H__ */
#endif
/* __AVMD_DESA2_TWEAKED_H__ */
src/mod/applications/mod_avmd/mod_avmd.c
浏览文件 @
0a893bac
...
@@ -208,24 +208,62 @@ static void init_avmd_session_data(avmd_session_t *avmd_session,
...
@@ -208,24 +208,62 @@ static void init_avmd_session_data(avmd_session_t *avmd_session,
static
switch_bool_t
avmd_callback
(
switch_media_bug_t
*
bug
,
static
switch_bool_t
avmd_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
)
void
*
user_data
,
switch_abc_type_t
type
)
{
{
avmd_session_t
*
avmd_session
;
avmd_session_t
*
avmd_session
;
switch_codec_t
*
read_codec
;
switch_codec_t
*
read_codec
;
switch_frame_t
*
frame
;
switch_frame_t
*
frame
;
switch_core_session_t
*
fs_session
;
avmd_session
=
(
avmd_session_t
*
)
user_data
;
avmd_session
=
(
avmd_session_t
*
)
user_data
;
if
(
avmd_session
==
NULL
)
{
if
(
avmd_session
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"No avmd session assigned!
\n
"
);
return
SWITCH_FALSE
;
}
fs_session
=
avmd_session
->
session
;
if
(
fs_session
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"No FreeSWITCH session assigned!
\n
"
);
return
SWITCH_FALSE
;
return
SWITCH_FALSE
;
}
}
switch
(
type
)
{
switch
(
type
)
{
case
SWITCH_ABC_TYPE_INIT
:
case
SWITCH_ABC_TYPE_INIT
:
read_codec
=
switch_core_session_get_read_codec
(
avmd_session
->
session
);
read_codec
=
switch_core_session_get_read_codec
(
fs_session
);
avmd_session
->
rate
=
read_codec
->
implementation
->
samples_per_second
;
if
(
read_codec
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_WARNING
,
"No codec assigned, default session rate to 8000 samples/s
\n
"
);
avmd_session
->
rate
=
8000
;
}
else
{
if
(
read_codec
->
implementation
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_WARNING
,
"No codec implementation assigned, default session rate to 8000 samples/s
\n
"
);
avmd_session
->
rate
=
8000
;
}
else
{
avmd_session
->
rate
=
read_codec
->
implementation
->
samples_per_second
;
}
}
avmd_session
->
start_time
=
switch_micro_time_now
();
avmd_session
->
start_time
=
switch_micro_time_now
();
/* avmd_session->vmd_codec.channels =
/* avmd_session->vmd_codec.channels =
* read_codec->implementation->number_of_channels; */
* read_codec->implementation->number_of_channels; */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
fs_session
),
SWITCH_LOG_INFO
,
"Avmd session started, [%u] samples/s
\n
"
,
avmd_session
->
rate
);
break
;
break
;
case
SWITCH_ABC_TYPE_READ_REPLACE
:
case
SWITCH_ABC_TYPE_READ_REPLACE
:
...
@@ -368,8 +406,14 @@ SWITCH_STANDARD_APP(avmd_start_function)
...
@@ -368,8 +406,14 @@ SWITCH_STANDARD_APP(avmd_start_function)
avmd_session_t
*
avmd_session
;
avmd_session_t
*
avmd_session
;
switch_media_bug_flag_t
flags
=
0
;
switch_media_bug_flag_t
flags
=
0
;
if
(
session
==
NULL
)
if
(
session
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"No FreeSWITCH session assigned!
\n
"
);
return
;
return
;
}
channel
=
switch_core_session_get_channel
(
session
);
channel
=
switch_core_session_get_channel
(
session
);
...
@@ -500,7 +544,8 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -500,7 +544,8 @@ SWITCH_STANDARD_API(avmd_api_main)
/* No command? Display usage */
/* No command? Display usage */
if
(
zstr
(
cmd
))
{
if
(
zstr
(
cmd
))
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
AVMD_SYNTAX
);
stream
->
write_function
(
stream
,
"-ERR, bad command!
\n
"
"-USAGE: %s
\n\n
"
,
AVMD_SYNTAX
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -512,7 +557,8 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -512,7 +557,8 @@ SWITCH_STANDARD_API(avmd_api_main)
/* If we don't have the expected number of parameters
/* If we don't have the expected number of parameters
* display usage */
* display usage */
if
(
argc
!=
AVMD_PARAMS
)
{
if
(
argc
!=
AVMD_PARAMS
)
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
AVMD_SYNTAX
);
stream
->
write_function
(
stream
,
"-ERR, avmd takes [%u] parameters!
\n
"
"-USAGE: %s
\n\n
"
,
AVMD_PARAMS
,
AVMD_SYNTAX
);
goto
end
;
goto
end
;
}
}
...
@@ -524,7 +570,8 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -524,7 +570,8 @@ SWITCH_STANDARD_API(avmd_api_main)
/* If the session was not found exit */
/* If the session was not found exit */
if
(
fs_session
==
NULL
)
{
if
(
fs_session
==
NULL
)
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
AVMD_SYNTAX
);
stream
->
write_function
(
stream
,
"-ERR, no FreeSWITCH session for uuid [%s]!"
"
\n
-USAGE: %s
\n\n
"
,
uuid
,
AVMD_SYNTAX
);
goto
end
;
goto
end
;
}
}
...
@@ -541,7 +588,7 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -541,7 +588,7 @@ SWITCH_STANDARD_API(avmd_api_main)
switch_channel_set_private
(
channel
,
"_avmd_"
,
NULL
);
switch_channel_set_private
(
channel
,
"_avmd_"
,
NULL
);
switch_core_media_bug_remove
(
fs_session
,
&
bug
);
switch_core_media_bug_remove
(
fs_session
,
&
bug
);
switch_safe_free
(
ccmd
);
switch_safe_free
(
ccmd
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
stream
->
write_function
(
stream
,
"+OK
\n
[%s] stopped.
\n
"
,
uuid
);
goto
end
;
goto
end
;
}
}
...
@@ -557,7 +604,8 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -557,7 +604,8 @@ SWITCH_STANDARD_API(avmd_api_main)
/* If we don't see the expected start exit */
/* If we don't see the expected start exit */
if
(
strcasecmp
(
command
,
"start"
)
!=
0
)
{
if
(
strcasecmp
(
command
,
"start"
)
!=
0
)
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
AVMD_SYNTAX
);
stream
->
write_function
(
stream
,
"-ERR, did you mean
\n
"
"api avmd %s start ?
\n
-USAGE: %s
\n\n
"
,
uuid
,
AVMD_SYNTAX
);
goto
end
;
goto
end
;
}
}
...
@@ -595,9 +643,10 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -595,9 +643,10 @@ SWITCH_STANDARD_API(avmd_api_main)
switch_log_printf
(
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
SWITCH_LOG_ERROR
,
"Fail
ure hooking to stream
\n
"
"Fail
ed to add media bug!
\n
"
);
);
stream
->
write_function
(
stream
,
"-ERR, [%s] failed to add media bug!
\n\n
"
,
uuid
);
goto
end
;
goto
end
;
}
}
...
@@ -605,7 +654,7 @@ SWITCH_STANDARD_API(avmd_api_main)
...
@@ -605,7 +654,7 @@ SWITCH_STANDARD_API(avmd_api_main)
switch_channel_set_private
(
channel
,
"_avmd_"
,
bug
);
switch_channel_set_private
(
channel
,
"_avmd_"
,
bug
);
/* Everything went according to plan! Notify the user */
/* Everything went according to plan! Notify the user */
stream
->
write_function
(
stream
,
"+OK
\n
"
);
stream
->
write_function
(
stream
,
"+OK
, start
\n
\n
"
);
end
:
end
:
...
@@ -667,7 +716,7 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
...
@@ -667,7 +716,7 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
/*for (pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++) { */
/*for (pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++) { */
if
((
sample_n
%
sine_len_i
)
==
0
)
{
if
((
sample_n
%
sine_len_i
)
==
0
)
{
/* Get a desa2 frequency estimate every sine len */
/* Get a desa2 frequency estimate every sine len */
omega
=
avmd_desa2_tweaked
(
b
,
pos
+
sample_n
,
session
->
session
);
omega
=
avmd_desa2_tweaked
(
b
,
pos
+
sample_n
);
if
(
omega
<
-
0
.
999999
||
omega
>
0
.
999999
)
{
if
(
omega
<
-
0
.
999999
||
omega
>
0
.
999999
)
{
#ifdef AVMD_DEBUG
#ifdef AVMD_DEBUG
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论