Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8331f4a0
提交
8331f4a0
authored
3月 09, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3980 --resolve
上级
e31a35a7
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
129 行增加
和
2 行删除
+129
-2
mod_speex.c
src/mod/codecs/mod_speex/mod_speex.c
+127
-2
switch_core_io.c
src/switch_core_io.c
+2
-0
没有找到文件。
src/mod/codecs/mod_speex/mod_speex.c
浏览文件 @
8331f4a0
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-201
1
, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-201
2
, Anthony Minessale II <anthm@freeswitch.org>
*
*
* Version: MPL 1.1
* Version: MPL 1.1
*
*
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
* Contributor(s):
* Contributor(s):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
* Anthony Minessale II <anthm@freeswitch.org>
* Chris Rienzo <chris@rienzo.net>
*
*
*
*
* mod_speex.c -- Speex Codec Module
* mod_speex.c -- Speex Codec Module
...
@@ -279,10 +280,11 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
...
@@ -279,10 +280,11 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
if
(
is_speech
)
{
if
(
is_speech
)
{
switch_clear_flag
(
context
,
SWITCH_CODEC_FLAG_SILENCE
);
switch_clear_flag
(
context
,
SWITCH_CODEC_FLAG_SILENCE
);
*
flag
|=
SWITCH_CODEC_FLAG_SILENCE_STOP
;
*
flag
|=
SWITCH_CODEC_FLAG_SILENCE_STOP
;
*
flag
&=
~
SFF_CNG
;
}
else
{
}
else
{
if
(
switch_test_flag
(
context
,
SWITCH_CODEC_FLAG_SILENCE
))
{
if
(
switch_test_flag
(
context
,
SWITCH_CODEC_FLAG_SILENCE
))
{
*
encoded_data_len
=
0
;
*
encoded_data_len
=
0
;
*
flag
|=
SWITCH_CODEC_FLAG_SILENCE
;
*
flag
|=
SWITCH_CODEC_FLAG_SILENCE
|
SFF_CNG
;
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -353,6 +355,126 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec)
...
@@ -353,6 +355,126 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec)
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
/**
* read default settings from speex.conf
*/
static
void
load_configuration
()
{
switch_xml_t
xml
=
NULL
,
cfg
=
NULL
;
if
((
xml
=
switch_xml_open_cfg
(
"speex.conf"
,
&
cfg
,
NULL
)))
{
switch_xml_t
x_lists
;
if
((
x_lists
=
switch_xml_child
(
cfg
,
"settings"
)))
{
const
char
*
settings_name
=
switch_xml_attr
(
x_lists
,
"name"
);
switch_xml_t
x_list
;
if
(
zstr
(
settings_name
))
{
settings_name
=
""
;
}
for
(
x_list
=
switch_xml_child
(
x_lists
,
"param"
);
x_list
;
x_list
=
x_list
->
next
)
{
const
char
*
name
=
switch_xml_attr
(
x_list
,
"name"
);
const
char
*
value
=
switch_xml_attr
(
x_list
,
"value"
);
if
(
zstr
(
name
))
{
continue
;
}
if
(
zstr
(
value
))
{
continue
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s %s = %s
\n
"
,
settings_name
,
name
,
value
);
if
(
!
strcasecmp
(
"quality"
,
name
))
{
/* compression quality, integer 0-10 */
int
tmp
=
atoi
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
&&
tmp
<=
10
)
{
default_codec_settings
.
quality
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid quality value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"complexity"
,
name
))
{
/* compression complexity, integer 1-10 */
int
tmp
=
atoi
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
1
&&
tmp
<=
10
)
{
default_codec_settings
.
complexity
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid complexity value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"enhancement"
,
name
))
{
/* enable perceptual enhancement, boolean */
default_codec_settings
.
enhancement
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"vad"
,
name
))
{
/* enable voice activity detection, boolean */
default_codec_settings
.
vad
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"vbr"
,
name
))
{
/* enable variable bit rate, boolean */
default_codec_settings
.
vbr
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"vbr-quality"
,
name
))
{
/* variable bit rate quality, float 0-10 */
float
tmp
=
atof
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
&&
tmp
<=
10
)
{
default_codec_settings
.
vbr_quality
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid vbr-quality value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"abr"
,
name
))
{
/* average bit rate, integer bits per sec */
int
tmp
=
atoi
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
)
{
default_codec_settings
.
abr
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid abr value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"dtx"
,
name
))
{
/* discontinuous transmit, boolean */
default_codec_settings
.
dtx
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"preproc"
,
name
))
{
/* enable preprocessor, boolean */
default_codec_settings
.
preproc
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"pp-vad"
,
name
))
{
/* enable preprocessor VAD, boolean */
default_codec_settings
.
pp_vad
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"pp-agc"
,
name
))
{
/* enable preprocessor automatic gain control, boolean */
default_codec_settings
.
pp_agc
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"pp-agc-level"
,
name
))
{
/* agc level, float */
float
tmp
=
atof
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
.
0
f
)
{
default_codec_settings
.
pp_agc_level
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid pp-agc-level value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"pp-denoise"
,
name
))
{
/* enable preprocessor denoiser, boolean */
default_codec_settings
.
pp_denoise
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"pp-dereverb"
,
name
))
{
/* enable preprocessor reverberation removal, boolean */
default_codec_settings
.
pp_dereverb
=
switch_true
(
value
);
}
else
if
(
!
strcasecmp
(
"pp-dereverb-decay"
,
name
))
{
/* reverberation removal decay, float */
float
tmp
=
atof
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
.
0
f
)
{
default_codec_settings
.
pp_dereverb_decay
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid pp-dereverb-decay value: %s
\n
"
,
value
);
}
}
else
if
(
!
strcasecmp
(
"pp-dereverb-level"
,
name
))
{
/* reverberation removal level, float */
float
tmp
=
atof
(
value
);
if
(
switch_is_number
(
value
)
&&
tmp
>=
0
.
0
f
)
{
default_codec_settings
.
pp_dereverb_level
=
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid pp-dereverb-level value: %s
\n
"
,
value
);
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"ignoring invalid unknown param: %s = %s
\n
"
,
name
,
value
);
}
}
}
switch_xml_free
(
xml
);
}
}
SWITCH_MODULE_LOAD_FUNCTION
(
mod_speex_load
)
SWITCH_MODULE_LOAD_FUNCTION
(
mod_speex_load
)
{
{
switch_codec_interface_t
*
codec_interface
;
switch_codec_interface_t
*
codec_interface
;
...
@@ -361,6 +483,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
...
@@ -361,6 +483,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
int
bps
[
4
]
=
{
0
,
24600
,
42200
,
44000
};
int
bps
[
4
]
=
{
0
,
24600
,
42200
,
44000
};
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
load_configuration
();
SWITCH_ADD_CODEC
(
codec_interface
,
"Speex"
);
SWITCH_ADD_CODEC
(
codec_interface
,
"Speex"
);
codec_interface
->
parse_fmtp
=
switch_speex_fmtp_parse
;
codec_interface
->
parse_fmtp
=
switch_speex_fmtp_parse
;
for
(
counta
=
1
;
counta
<=
3
;
counta
++
)
{
for
(
counta
=
1
;
counta
<=
3
;
counta
++
)
{
...
...
src/switch_core_io.c
浏览文件 @
8331f4a0
...
@@ -1059,6 +1059,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
...
@@ -1059,6 +1059,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
session
->
enc_write_frame
.
m
=
frame
->
m
;
session
->
enc_write_frame
.
m
=
frame
->
m
;
session
->
enc_write_frame
.
ssrc
=
frame
->
ssrc
;
session
->
enc_write_frame
.
ssrc
=
frame
->
ssrc
;
session
->
enc_write_frame
.
seq
=
frame
->
seq
;
session
->
enc_write_frame
.
seq
=
frame
->
seq
;
session
->
enc_write_frame
.
flags
=
0
;
write_frame
=
&
session
->
enc_write_frame
;
write_frame
=
&
session
->
enc_write_frame
;
break
;
break
;
case
SWITCH_STATUS_NOOP
:
case
SWITCH_STATUS_NOOP
:
...
@@ -1173,6 +1174,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
...
@@ -1173,6 +1174,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
session
->
enc_write_frame
.
m
=
frame
->
m
;
session
->
enc_write_frame
.
m
=
frame
->
m
;
session
->
enc_write_frame
.
ssrc
=
frame
->
ssrc
;
session
->
enc_write_frame
.
ssrc
=
frame
->
ssrc
;
session
->
enc_write_frame
.
payload
=
session
->
write_impl
.
ianacode
;
session
->
enc_write_frame
.
payload
=
session
->
write_impl
.
ianacode
;
session
->
enc_write_frame
.
flags
=
0
;
write_frame
=
&
session
->
enc_write_frame
;
write_frame
=
&
session
->
enc_write_frame
;
break
;
break
;
case
SWITCH_STATUS_NOOP
:
case
SWITCH_STATUS_NOOP
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论