Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
873a7bbd
提交
873a7bbd
authored
11月 02, 2017
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10769: [mod_av,mod_conference] Lipsync issues in conference recording #resolve
上级
7728273b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
40 行删除
+20
-40
avformat.c
src/mod/applications/mod_av/avformat.c
+20
-40
没有找到文件。
src/mod/applications/mod_av/avformat.c
浏览文件 @
873a7bbd
...
...
@@ -100,8 +100,6 @@ struct av_file_context {
switch_buffer_t
*
buf
;
switch_buffer_t
*
audio_buffer
;
switch_timer_t
video_timer
;
switch_timer_t
audio_timer
;
int
use_audio_timer
;
int
offset
;
int
audio_start
;
int
aud_ready
;
...
...
@@ -381,9 +379,9 @@ static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst,
int
buffer_bytes
=
2097152
;
/* 2 mb */
int
fps
=
15
;
if
(
mm
->
try_hardware_encoder
&&
codec_id
==
AV_CODEC_ID_H264
)
{
*
codec
=
avcodec_find_encoder_by_name
(
"nvenc_h264"
);
}
//
if (mm->try_hardware_encoder && codec_id == AV_CODEC_ID_H264) {
//
*codec = avcodec_find_encoder_by_name("nvenc_h264");
//
}
if
(
!*
codec
)
{
/* find the encoder */
...
...
@@ -842,7 +840,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
delta
=
33
;
}
context
->
eh
.
video_st
->
frame
->
pts
+=
delta
;
context
->
eh
.
video_st
->
frame
->
pts
+=
delta
*
90
;
}
else
{
uint64_t
delta_tmp
;
...
...
@@ -863,9 +861,9 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
delta_avg
=
(
int
)(
double
)(
delta_sum
/
delta_i
);
}
context
->
eh
.
video_st
->
frame
->
pts
=
context
->
eh
.
video_timer
->
samplecount
;
context
->
eh
.
video_st
->
frame
->
pts
=
context
->
eh
.
video_timer
->
samplecount
*
90
;
}
else
{
context
->
eh
.
video_st
->
frame
->
pts
=
(
context
->
eh
.
video_timer
->
samplecount
)
+
1
;
context
->
eh
.
video_st
->
frame
->
pts
=
(
(
context
->
eh
.
video_timer
->
samplecount
)
*
90
)
+
1
;
}
}
...
...
@@ -1590,10 +1588,6 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
if
((
tmp
=
switch_event_get_header
(
handle
->
params
,
"av_video_offset"
)))
{
context
->
offset
=
atoi
(
tmp
);
}
if
(
switch_true
(
switch_event_get_header
(
handle
->
params
,
"av_audio_use_timer"
)))
{
context
->
use_audio_timer
=
1
;
}
}
switch_mutex_init
(
&
context
->
mutex
,
SWITCH_MUTEX_NESTED
,
handle
->
memory_pool
);
...
...
@@ -1827,10 +1821,6 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
switch_core_timer_destroy
(
&
context
->
video_timer
);
}
if
(
context
->
audio_timer
.
interval
)
{
switch_core_timer_destroy
(
&
context
->
audio_timer
);
}
if
(
context
->
audio_buffer
)
{
switch_buffer_destroy
(
&
context
->
audio_buffer
);
}
...
...
@@ -1855,7 +1845,8 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
// uint32_t size = 0;
uint32_t
bytes
;
int
inuse
;
int
sample_start
;
if
(
!
switch_test_flag
(
handle
,
SWITCH_FILE_FLAG_WRITE
))
{
return
SWITCH_STATUS_FALSE
;
}
...
...
@@ -1910,11 +1901,6 @@ GCC_DIAG_ON(deprecated-declarations)
}
}
if
(
context
->
use_audio_timer
)
{
// timer only needed with record video
switch_core_timer_init
(
&
context
->
audio_timer
,
"soft"
,
1
,
handle
->
samplerate
/
1000
,
context
->
pool
);
}
while
((
inuse
=
switch_buffer_inuse
(
context
->
audio_buffer
))
>=
bytes
)
{
AVPacket
pkt
[
2
]
=
{
{
0
}
};
int
got_packet
[
2
]
=
{
0
};
...
...
@@ -1950,10 +1936,16 @@ GCC_DIAG_ON(deprecated-declarations)
switch_buffer_read
(
context
->
audio_buffer
,
context
->
audio_st
[
0
].
frame
->
data
[
0
],
bytes
);
}
if
(
context
->
audio_timer
.
interval
)
{
switch_core_timer_sync
(
&
context
->
audio_timer
);
}
/* Sync all audio stream timestamps to video timer */
if
(
context
->
video_timer
.
interval
)
{
switch_core_timer_sync
(
&
context
->
video_timer
);
sample_start
=
context
->
video_timer
.
samplecount
*
(
handle
->
samplerate
/
1000
);
for
(
j
=
0
;
j
<
audio_stream_count
;
j
++
)
{
context
->
audio_st
[
j
].
next_pts
=
sample_start
;
}
}
for
(
j
=
0
;
j
<
audio_stream_count
;
j
++
)
{
av_frame_make_writable
(
context
->
audio_st
[
j
].
frame
);
...
...
@@ -1979,12 +1971,7 @@ GCC_DIAG_ON(deprecated-declarations)
use_frame
=
context
->
audio_st
[
j
].
tmp_frame
;
}
if
(
context
->
audio_timer
.
interval
)
{
use_frame
->
pts
=
context
->
audio_timer
.
samplecount
;
}
else
{
context
->
audio_st
[
j
].
next_pts
+=
use_frame
->
nb_samples
;
use_frame
->
pts
=
context
->
audio_st
[
j
].
next_pts
;
}
use_frame
->
pts
=
context
->
audio_st
[
j
].
next_pts
;
// context->audio_st[j].next_pts = use_frame->pts + use_frame->nb_samples;
...
...
@@ -1992,6 +1979,7 @@ GCC_DIAG_OFF(deprecated-declarations)
ret
=
avcodec_encode_audio2
(
context
->
audio_st
[
j
].
st
->
codec
,
&
pkt
[
j
],
use_frame
,
&
got_packet
[
j
]);
GCC_DIAG_ON
(
deprecated
-
declarations
)
context
->
audio_st
[
j
].
next_pts
+=
use_frame
->
nb_samples
;
}
if
(
ret
<
0
)
{
...
...
@@ -2062,10 +2050,6 @@ static switch_status_t av_file_command(switch_file_handle_t *handle, switch_file
offset
=
(
uint32_t
)(
switch_micro_time_now
()
-
context
->
eh
.
record_timer_paused
);
context
->
video_timer
.
start
+=
offset
;
switch_core_timer_sync
(
&
context
->
video_timer
);
if
(
context
->
audio_timer
.
interval
)
{
context
->
audio_timer
.
start
+=
offset
;
switch_core_timer_sync
(
&
context
->
audio_timer
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s resume write
\n
"
,
handle
->
file_path
);
context
->
eh
.
record_timer_paused
=
0
;
}
...
...
@@ -2128,10 +2112,6 @@ static switch_status_t av_file_close(switch_file_handle_t *handle)
switch_core_timer_destroy
(
&
context
->
video_timer
);
}
if
(
context
->
audio_timer
.
interval
)
{
switch_core_timer_destroy
(
&
context
->
audio_timer
);
}
switch_img_free
(
&
context
->
last_img
);
switch_buffer_destroy
(
&
context
->
audio_buffer
);
...
...
@@ -2542,7 +2522,7 @@ GCC_DIAG_ON(deprecated-declarations)
switch_threadattr_create
(
&
thd_attr
,
handle
->
memory_pool
);
//switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_threadattr_stacksize_set
(
thd_attr
,
SWITCH_THREAD_STACKSIZE
);
switch_core_timer_init
(
&
context
->
video_timer
,
"soft"
,
1
,
90
,
context
->
pool
);
switch_core_timer_init
(
&
context
->
video_timer
,
"soft"
,
1
,
1
,
context
->
pool
);
context
->
eh
.
video_timer
=
&
context
->
video_timer
;
context
->
audio_st
[
0
].
frame
->
pts
=
0
;
context
->
audio_st
[
0
].
next_pts
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论