Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
807efbd0
提交
807efbd0
authored
10月 01, 2018
作者:
Seven Du
提交者:
Andrey Volk
7月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11183 FS-11425 refactor out parse_profile
上级
cd2a53b5
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
224 行增加
和
219 行删除
+224
-219
avcodec.c
src/mod/applications/mod_av/avcodec.c
+224
-219
没有找到文件。
src/mod/applications/mod_av/avcodec.c
浏览文件 @
807efbd0
...
@@ -1871,105 +1871,8 @@ void show_codecs(switch_stream_handle_t *stream)
...
@@ -1871,105 +1871,8 @@ void show_codecs(switch_stream_handle_t *stream)
#define UINTVAL(v) (v > 0 ? v : 0);
#define UINTVAL(v) (v > 0 ? v : 0);
static
void
load_config
(
)
static
void
parse_profile
(
switch_xml_t
profile
)
{
{
switch_xml_t
cfg
=
NULL
,
xml
=
NULL
;
int
i
;
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263"
)].
name
,
"H263"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263+"
)].
name
,
"H263+"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H264"
)].
name
,
"H264"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H265"
)].
name
,
"H265"
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_profile_t
*
profile
=
&
avcodec_globals
.
profiles
[
i
];
profile
->
ctx
.
colorspace
=
AVCOL_SPC_RGB
;
profile
->
ctx
.
color_range
=
AVCOL_RANGE_JPEG
;
profile
->
ctx
.
flags
=
0
;
profile
->
ctx
.
me_cmp
=
-
1
;
profile
->
ctx
.
me_range
=
-
1
;
profile
->
ctx
.
max_b_frames
=
-
1
;
profile
->
ctx
.
refs
=
-
1
;
profile
->
ctx
.
gop_size
=
-
1
;
profile
->
ctx
.
keyint_min
=
-
1
;
profile
->
ctx
.
i_quant_factor
=
-
1
;
profile
->
ctx
.
b_quant_factor
=
-
1
;
profile
->
ctx
.
qcompress
=
-
1
;
profile
->
ctx
.
qmin
=
-
1
;
profile
->
ctx
.
qmax
=
-
1
;
profile
->
ctx
.
max_qdiff
=
-
1
;
profile
->
ctx
.
thread_count
=
switch_parse_cpu_string
(
"cpu/2/4"
);
profile
->
decoder_thread_count
=
switch_parse_cpu_string
(
"cpu/2/4"
);
if
(
!
strcasecmp
(
CODEC_MAPS
[
i
],
"H264"
))
{
profile
->
ctx
.
profile
=
FF_PROFILE_H264_BASELINE
;
profile
->
ctx
.
level
=
41
;
#ifdef AV_CODEC_FLAG_PSNR
profile
->
ctx
.
flags
|=
AV_CODEC_FLAG_PSNR
;
#endif
#ifdef CODEC_FLAG_LOOP_FILTER
profile
->
ctx
.
flags
|=
CODEC_FLAG_LOOP_FILTER
;
#endif
}
}
avcodec_globals
.
max_bitrate
=
0
;
xml
=
switch_xml_open_cfg
(
"avcodec.conf"
,
&
cfg
,
NULL
);
if
(
xml
)
{
switch_xml_t
settings
=
switch_xml_child
(
cfg
,
"settings"
);
switch_xml_t
profiles
=
switch_xml_child
(
cfg
,
"profiles"
);
if
(
settings
)
{
switch_xml_t
param
;
for
(
param
=
switch_xml_child
(
settings
,
"param"
);
param
;
param
=
param
->
next
)
{
const
char
*
name
=
switch_xml_attr
(
param
,
"name"
);
const
char
*
value
=
switch_xml_attr
(
param
,
"value"
);
if
(
zstr
(
name
)
||
zstr
(
value
))
continue
;
if
(
!
strcmp
(
name
,
"max-bitrate"
))
{
avcodec_globals
.
max_bitrate
=
switch_parse_bandwidth_string
(
value
);
}
else
if
(
!
strcmp
(
name
,
"rtp-slice-size"
))
{
int
val
=
atoi
(
value
);
avcodec_globals
.
rtp_slice_size
=
UINTVAL
(
val
);
}
else
if
(
!
strcmp
(
name
,
"key-frame-min-freq"
))
{
int
val
=
atoi
(
value
);
avcodec_globals
.
key_frame_min_freq
=
UINTVAL
(
val
);
avcodec_globals
.
key_frame_min_freq
*=
1000
;
}
else
if
(
!
strcmp
(
name
,
"dec-threads"
))
{
int
i
;
unsigned
int
threads
=
switch_parse_cpu_string
(
value
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_globals
.
profiles
[
i
].
decoder_thread_count
=
threads
;
}
}
else
if
(
!
strcmp
(
name
,
"enc-threads"
))
{
int
i
;
unsigned
int
threads
=
switch_parse_cpu_string
(
value
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_globals
.
profiles
[
i
].
ctx
.
thread_count
=
threads
;
}
}
else
if
(
!
strcasecmp
(
name
,
"h263-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h263+-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263+"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h264-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H264"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h265-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H265"
)].
name
,
value
);
}
}
}
if
(
profiles
)
{
switch_xml_t
profile
=
switch_xml_child
(
profiles
,
"profile"
);
for
(;
profile
;
profile
=
profile
->
next
)
{
switch_xml_t
options
=
switch_xml_child
(
profile
,
"options"
);
switch_xml_t
options
=
switch_xml_child
(
profile
,
"options"
);
switch_xml_t
param
=
NULL
;
switch_xml_t
param
=
NULL
;
const
char
*
profile_name
=
switch_xml_attr
(
profile
,
"name"
);
const
char
*
profile_name
=
switch_xml_attr
(
profile
,
"name"
);
...
@@ -1977,7 +1880,7 @@ static void load_config()
...
@@ -1977,7 +1880,7 @@ static void load_config()
AVCodecContext
*
ctx
=
NULL
;
AVCodecContext
*
ctx
=
NULL
;
int
i
;
int
i
;
if
(
zstr
(
profile_name
))
continue
;
if
(
zstr
(
profile_name
))
return
;
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
if
(
!
strcmp
(
profile_name
,
avcodec_globals
.
profiles
[
i
].
name
))
{
if
(
!
strcmp
(
profile_name
,
avcodec_globals
.
profiles
[
i
].
name
))
{
...
@@ -1987,7 +1890,7 @@ static void load_config()
...
@@ -1987,7 +1890,7 @@ static void load_config()
}
}
}
}
if
(
!
ctx
)
continue
;
if
(
!
ctx
)
return
;
for
(
param
=
switch_xml_child
(
profile
,
"param"
);
param
;
param
=
param
->
next
)
{
for
(
param
=
switch_xml_child
(
profile
,
"param"
);
param
;
param
=
param
->
next
)
{
const
char
*
name
=
switch_xml_attr
(
param
,
"name"
);
const
char
*
name
=
switch_xml_attr
(
param
,
"name"
);
...
@@ -2189,6 +2092,108 @@ static void load_config()
...
@@ -2189,6 +2092,108 @@ static void load_config()
switch_event_add_header_string
(
aprofile
->
options
,
SWITCH_STACK_BOTTOM
,
name
,
value
);
switch_event_add_header_string
(
aprofile
->
options
,
SWITCH_STACK_BOTTOM
,
name
,
value
);
}
}
}
// for options
}
// for options
}
static
void
load_config
()
{
switch_xml_t
cfg
=
NULL
,
xml
=
NULL
;
int
i
;
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263"
)].
name
,
"H263"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263+"
)].
name
,
"H263+"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H264"
)].
name
,
"H264"
);
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H265"
)].
name
,
"H265"
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_profile_t
*
profile
=
&
avcodec_globals
.
profiles
[
i
];
profile
->
ctx
.
colorspace
=
AVCOL_SPC_RGB
;
profile
->
ctx
.
color_range
=
AVCOL_RANGE_JPEG
;
profile
->
ctx
.
flags
=
0
;
profile
->
ctx
.
me_cmp
=
-
1
;
profile
->
ctx
.
me_range
=
-
1
;
profile
->
ctx
.
max_b_frames
=
-
1
;
profile
->
ctx
.
refs
=
-
1
;
profile
->
ctx
.
gop_size
=
-
1
;
profile
->
ctx
.
keyint_min
=
-
1
;
profile
->
ctx
.
i_quant_factor
=
-
1
;
profile
->
ctx
.
b_quant_factor
=
-
1
;
profile
->
ctx
.
qcompress
=
-
1
;
profile
->
ctx
.
qmin
=
-
1
;
profile
->
ctx
.
qmax
=
-
1
;
profile
->
ctx
.
max_qdiff
=
-
1
;
profile
->
ctx
.
thread_count
=
switch_parse_cpu_string
(
"cpu/2/4"
);
profile
->
decoder_thread_count
=
switch_parse_cpu_string
(
"cpu/2/4"
);
if
(
!
strcasecmp
(
CODEC_MAPS
[
i
],
"H264"
))
{
profile
->
ctx
.
profile
=
FF_PROFILE_H264_BASELINE
;
profile
->
ctx
.
level
=
41
;
#ifdef AV_CODEC_FLAG_PSNR
profile
->
ctx
.
flags
|=
AV_CODEC_FLAG_PSNR
;
#endif
#ifdef CODEC_FLAG_LOOP_FILTER
profile
->
ctx
.
flags
|=
CODEC_FLAG_LOOP_FILTER
;
#endif
}
}
avcodec_globals
.
max_bitrate
=
0
;
xml
=
switch_xml_open_cfg
(
"avcodec.conf"
,
&
cfg
,
NULL
);
if
(
xml
)
{
switch_xml_t
settings
=
switch_xml_child
(
cfg
,
"settings"
);
switch_xml_t
profiles
=
switch_xml_child
(
cfg
,
"profiles"
);
if
(
settings
)
{
switch_xml_t
param
;
for
(
param
=
switch_xml_child
(
settings
,
"param"
);
param
;
param
=
param
->
next
)
{
const
char
*
name
=
switch_xml_attr
(
param
,
"name"
);
const
char
*
value
=
switch_xml_attr
(
param
,
"value"
);
if
(
zstr
(
name
)
||
zstr
(
value
))
continue
;
if
(
!
strcmp
(
name
,
"max-bitrate"
))
{
avcodec_globals
.
max_bitrate
=
switch_parse_bandwidth_string
(
value
);
}
else
if
(
!
strcmp
(
name
,
"rtp-slice-size"
))
{
int
val
=
atoi
(
value
);
avcodec_globals
.
rtp_slice_size
=
UINTVAL
(
val
);
}
else
if
(
!
strcmp
(
name
,
"key-frame-min-freq"
))
{
int
val
=
atoi
(
value
);
avcodec_globals
.
key_frame_min_freq
=
UINTVAL
(
val
);
avcodec_globals
.
key_frame_min_freq
*=
1000
;
}
else
if
(
!
strcmp
(
name
,
"dec-threads"
))
{
int
i
;
unsigned
int
threads
=
switch_parse_cpu_string
(
value
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_globals
.
profiles
[
i
].
decoder_thread_count
=
threads
;
}
}
else
if
(
!
strcmp
(
name
,
"enc-threads"
))
{
int
i
;
unsigned
int
threads
=
switch_parse_cpu_string
(
value
);
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_globals
.
profiles
[
i
].
ctx
.
thread_count
=
threads
;
}
}
else
if
(
!
strcasecmp
(
name
,
"h263-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h263+-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H263+"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h264-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H264"
)].
name
,
value
);
}
else
if
(
!
strcasecmp
(
name
,
"h265-profile"
))
{
switch_set_string
(
avcodec_globals
.
profiles
[
get_codec_index
(
"H265"
)].
name
,
value
);
}
}
}
if
(
profiles
)
{
switch_xml_t
profile
=
switch_xml_child
(
profiles
,
"profile"
);
for
(;
profile
;
profile
=
profile
->
next
)
{
parse_profile
(
profile
);
}
// for profile
}
// for profile
}
// profiles
}
// profiles
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论