Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
12e3b717
提交
12e3b717
authored
6月 20, 2018
作者:
Seven Du
提交者:
Muteesa Fred
7月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11189 refactor to support any possible codec specific private options
上级
18bcc4dd
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
59 行增加
和
40 行删除
+59
-40
av.conf.xml
src/mod/applications/mod_av/autoload_configs/av.conf.xml
+9
-8
avcodec.c
src/mod/applications/mod_av/avcodec.c
+48
-32
mod_av.c
src/mod/applications/mod_av/mod_av.c
+2
-0
没有找到文件。
src/mod/applications/mod_av/autoload_configs/av.conf.xml
浏览文件 @
12e3b717
...
@@ -123,14 +123,15 @@ enum AVColorRange {
...
@@ -123,14 +123,15 @@ enum AVColorRange {
-->
-->
<param
name=
"color-range"
value=
"2"
/>
<param
name=
"color-range"
value=
"2"
/>
<!-- x264 private -->
<!-- x264 private options-->
<param
name=
"x264-preset"
value=
"veryfast"
/>
<options>
<param
name=
"x264-intra-refresh"
value=
"1"
/>
<option
name=
"preset"
value=
"veryfast"
/>
<param
name=
"x264-tune"
value=
"animation+zerolatency"
/>
<option
name=
"intra_refresh"
value=
"1"
/>
<!-- <param name="x264-sc-threshold" value="40"/> -->
<option
name=
"tune"
value=
"animation+zerolatency"
/>
<!-- <param name="x264-b-strategy" value="1"/> -->
<option
name=
"sc_threshold"
value=
"40"
/>
<!-- <param name="x264-crf" value="18"/> -->
<option
name=
"b_strategy"
value=
"1"
/>
<option
name=
"crf"
value=
"18"
/>
</options>
</profile>
</profile>
<profile
name=
"H265"
>
<profile
name=
"H265"
>
...
...
src/mod/applications/mod_av/avcodec.c
浏览文件 @
12e3b717
...
@@ -46,6 +46,7 @@ int SLICE_SIZE = SWITCH_DEFAULT_VIDEO_SIZE;
...
@@ -46,6 +46,7 @@ int SLICE_SIZE = SWITCH_DEFAULT_VIDEO_SIZE;
#define KEY_FRAME_MIN_FREQ 250000
#define KEY_FRAME_MIN_FREQ 250000
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avcodec_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avcodec_load
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_avcodec_shutdown
);
/* ff_avc_find_startcode is not exposed in the ffmpeg lib but you can use it
/* ff_avc_find_startcode is not exposed in the ffmpeg lib but you can use it
Either include the avc.h which available in the ffmpeg source, or
Either include the avc.h which available in the ffmpeg source, or
...
@@ -202,14 +203,7 @@ typedef struct avcodec_profile_s {
...
@@ -202,14 +203,7 @@ typedef struct avcodec_profile_s {
char
name
[
20
];
char
name
[
20
];
int
decoder_thread_count
;
int
decoder_thread_count
;
AVCodecContext
ctx
;
AVCodecContext
ctx
;
struct
{
switch_event_t
*
options
;
char
preset
[
20
];
char
tune
[
64
];
int
intra_refresh
;
int
sc_threshold
;
int
b_strategy
;
int
crf
;
}
x264
;
}
avcodec_profile_t
;
}
avcodec_profile_t
;
struct
avcodec_globals
{
struct
avcodec_globals
{
...
@@ -1010,18 +1004,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -1010,18 +1004,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"preset"
,
"llhp"
,
0
);
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"preset"
,
"llhp"
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"2pass"
,
1
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"2pass"
,
1
,
0
);
}
else
{
}
else
{
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"intra-refresh"
,
profile
->
x264
.
intra_refresh
,
0
);
if
(
profile
->
options
)
{
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"preset"
,
profile
->
x264
.
preset
,
0
);
switch_event_header_t
*
hp
;
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"tune"
,
profile
->
x264
.
tune
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"slice-max-size"
,
SLICE_SIZE
,
0
);
for
(
hp
=
profile
->
options
->
headers
;
hp
;
hp
=
hp
->
next
)
{
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: %s\n", hp->name, hp->value);
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
hp
->
name
,
hp
->
value
,
0
);
}
}
context
->
encoder_ctx
->
colorspace
=
profile
->
ctx
.
colorspace
;
context
->
encoder_ctx
->
colorspace
=
profile
->
ctx
.
colorspace
;
context
->
encoder_ctx
->
color_range
=
profile
->
ctx
.
color_range
;
context
->
encoder_ctx
->
color_range
=
profile
->
ctx
.
color_range
;
if
(
profile
->
x264
.
sc_threshold
>
0
)
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"sc_threshold"
,
profile
->
x264
.
sc_threshold
,
0
);
if
(
profile
->
x264
.
b_strategy
>
0
)
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"b_strategy"
,
profile
->
x264
.
b_strategy
,
0
);
if
(
profile
->
x264
.
crf
>
0
)
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"crf"
,
profile
->
x264
.
crf
,
0
);
context
->
encoder_ctx
->
flags
|=
profile
->
ctx
.
flags
;
// CODEC_FLAG_LOOP_FILTER; // flags=+loop
context
->
encoder_ctx
->
flags
|=
profile
->
ctx
.
flags
;
// CODEC_FLAG_LOOP_FILTER; // flags=+loop
if
(
profile
->
ctx
.
me_cmp
>=
0
)
context
->
encoder_ctx
->
me_cmp
=
profile
->
ctx
.
me_cmp
;
// cmp=+chroma, where CHROMA = 1
if
(
profile
->
ctx
.
me_cmp
>=
0
)
context
->
encoder_ctx
->
me_cmp
=
profile
->
ctx
.
me_cmp
;
// cmp=+chroma, where CHROMA = 1
if
(
profile
->
ctx
.
me_range
>=
0
)
context
->
encoder_ctx
->
me_range
=
profile
->
ctx
.
me_range
;
if
(
profile
->
ctx
.
me_range
>=
0
)
context
->
encoder_ctx
->
me_range
=
profile
->
ctx
.
me_range
;
...
@@ -1647,10 +1641,6 @@ static void load_config()
...
@@ -1647,10 +1641,6 @@ static void load_config()
profile
->
ctx
.
qmax
=
-
1
;
profile
->
ctx
.
qmax
=
-
1
;
profile
->
ctx
.
max_qdiff
=
-
1
;
profile
->
ctx
.
max_qdiff
=
-
1
;
profile
->
x264
.
sc_threshold
=
0
;
profile
->
x264
.
b_strategy
=
0
;
profile
->
x264
.
crf
=
0
;
if
(
!
strcasecmp
(
CODEC_MAPS
[
i
],
"H264"
))
{
if
(
!
strcasecmp
(
CODEC_MAPS
[
i
],
"H264"
))
{
profile
->
ctx
.
profile
=
FF_PROFILE_H264_BASELINE
;
profile
->
ctx
.
profile
=
FF_PROFILE_H264_BASELINE
;
profile
->
ctx
.
level
=
41
;
profile
->
ctx
.
level
=
41
;
...
@@ -1713,6 +1703,7 @@ static void load_config()
...
@@ -1713,6 +1703,7 @@ static void load_config()
switch_xml_t
profile
=
switch_xml_child
(
profiles
,
"profile"
);
switch_xml_t
profile
=
switch_xml_child
(
profiles
,
"profile"
);
for
(;
profile
;
profile
=
profile
->
next
)
{
for
(;
profile
;
profile
=
profile
->
next
)
{
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"
);
avcodec_profile_t
*
aprofile
=
NULL
;
avcodec_profile_t
*
aprofile
=
NULL
;
...
@@ -1778,8 +1769,6 @@ static void load_config()
...
@@ -1778,8 +1769,6 @@ static void load_config()
ctx
->
time_base
.
num
=
num
;
ctx
->
time_base
.
num
=
num
;
ctx
->
time_base
.
den
=
den
;
ctx
->
time_base
.
den
=
den
;
}
}
}
else
if
(
!
strcmp
(
name
,
"preset"
))
{
switch_set_string
(
aprofile
->
x264
.
preset
,
value
);
}
else
if
(
!
strcmp
(
name
,
"flags"
))
{
}
else
if
(
!
strcmp
(
name
,
"flags"
))
{
char
*
s
=
strdup
(
value
);
char
*
s
=
strdup
(
value
);
int
flags
=
0
;
int
flags
=
0
;
...
@@ -1872,18 +1861,30 @@ static void load_config()
...
@@ -1872,18 +1861,30 @@ static void load_config()
if
(
ctx
->
color_range
>
AVCOL_RANGE_NB
)
{
if
(
ctx
->
color_range
>
AVCOL_RANGE_NB
)
{
ctx
->
color_range
=
0
;
ctx
->
color_range
=
0
;
}
}
}
else
if
(
!
strcmp
(
name
,
"x264-preset"
))
{
switch_set_string
(
aprofile
->
x264
.
preset
,
value
);
}
else
if
(
!
strcmp
(
name
,
"x264-tune"
))
{
switch_set_string
(
aprofile
->
x264
.
tune
,
value
);
}
else
if
(
!
strcmp
(
name
,
"x264-sc-threshold"
))
{
aprofile
->
x264
.
sc_threshold
=
UINTVAL
(
val
);
}
else
if
(
!
strcmp
(
name
,
"x264-b-strategy"
))
{
aprofile
->
x264
.
b_strategy
=
UINTVAL
(
val
);
}
else
if
(
!
strcmp
(
name
,
"x264-crf"
))
{
aprofile
->
x264
.
crf
=
UINTVAL
(
val
);
}
}
}
// for param
}
// for param
if
(
options
)
{
switch_xml_t
option
=
switch_xml_child
(
options
,
"option"
);
if
(
aprofile
->
options
)
{
switch_event_destroy
(
&
aprofile
->
options
);
}
switch_event_create
(
&
aprofile
->
options
,
SWITCH_EVENT_CLONE
);
aprofile
->
options
->
flags
|=
EF_UNIQ_HEADERS
;
for
(;
option
;
option
=
option
->
next
)
{
const
char
*
name
=
switch_xml_attr
(
option
,
"name"
);
const
char
*
value
=
switch_xml_attr
(
option
,
"value"
);
if
(
zstr
(
name
)
||
zstr
(
value
))
continue
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s: %s
\n
"
,
name
,
value
);
switch_event_add_header_string
(
aprofile
->
options
,
SWITCH_STACK_BOTTOM
,
name
,
value
);
}
}
// for options
}
// for profile
}
// for profile
}
// profiles
}
// profiles
...
@@ -1928,6 +1929,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avcodec_load)
...
@@ -1928,6 +1929,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avcodec_load)
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_avcodec_shutdown
)
{
int
i
;
for
(
i
=
0
;
i
<
MAX_CODECS
;
i
++
)
{
avcodec_profile_t
*
profile
=
&
avcodec_globals
.
profiles
[
i
];
if
(
profile
->
options
)
{
switch_event_destroy
(
&
profile
->
options
);
}
}
return
SWITCH_STATUS_SUCCESS
;
}
/* For Emacs:
/* For Emacs:
* Local Variables:
* Local Variables:
* mode:c
* mode:c
...
...
src/mod/applications/mod_av/mod_av.c
浏览文件 @
12e3b717
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avformat_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avformat_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avcodec_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_avcodec_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_av_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_av_load
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_avcodec_shutdown
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_av_shutdown
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_av_shutdown
);
SWITCH_MODULE_DEFINITION
(
mod_av
,
mod_av_load
,
mod_av_shutdown
,
NULL
);
SWITCH_MODULE_DEFINITION
(
mod_av
,
mod_av_load
,
mod_av_shutdown
,
NULL
);
...
@@ -124,6 +125,7 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
...
@@ -124,6 +125,7 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_av_shutdown
)
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_av_shutdown
)
{
{
mod_avcodec_shutdown
();
avformat_network_deinit
();
avformat_network_deinit
();
av_log_set_callback
(
NULL
);
av_log_set_callback
(
NULL
);
av_lockmgr_register
(
NULL
);
av_lockmgr_register
(
NULL
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论