Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_25606643
ijkplayer
提交
a52504b5
I
ijkplayer
项目概览
qq_25606643
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ijkplayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a52504b5
编写于
10月 30, 2013
作者:
B
bbcallen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ff_ffplay: do not use eof_pkt any more
上级
53a8c0ef
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
31 deletion
+23
-31
ijkmedia/ijkplayer/ff_ffplay.c
ijkmedia/ijkplayer/ff_ffplay.c
+23
-31
未找到文件。
ijkmedia/ijkplayer/ff_ffplay.c
浏览文件 @
a52504b5
...
@@ -46,7 +46,6 @@
...
@@ -46,7 +46,6 @@
// #define FFP_SHOW_DEMUX_CACHE
// #define FFP_SHOW_DEMUX_CACHE
static
AVPacket
flush_pkt
;
static
AVPacket
flush_pkt
;
static
AVPacket
eof_pkt
;
// FFP_MERGE: cmp_audio_fmts
// FFP_MERGE: cmp_audio_fmts
// FFP_MERGE: get_valid_channel_layout
// FFP_MERGE: get_valid_channel_layout
...
@@ -88,14 +87,14 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
...
@@ -88,14 +87,14 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
int
ret
;
int
ret
;
/* duplicate the packet */
/* duplicate the packet */
if
(
pkt
!=
&
flush_pkt
&&
pkt
!=
&
eof_pkt
&&
av_dup_packet
(
pkt
)
<
0
)
if
(
pkt
!=
&
flush_pkt
&&
av_dup_packet
(
pkt
)
<
0
)
return
-
1
;
return
-
1
;
SDL_LockMutex
(
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
ret
=
packet_queue_put_private
(
q
,
pkt
);
ret
=
packet_queue_put_private
(
q
,
pkt
);
SDL_UnlockMutex
(
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
if
(
pkt
!=
&
flush_pkt
&&
pkt
!=
&
eof_pkt
&&
ret
<
0
)
if
(
pkt
!=
&
flush_pkt
&&
ret
<
0
)
av_free_packet
(
pkt
);
av_free_packet
(
pkt
);
return
ret
;
return
ret
;
...
@@ -204,25 +203,22 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria
...
@@ -204,25 +203,22 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria
return
ret
;
return
ret
;
}
}
static
int
packet_queue_get_or_buffering
(
FFPlayer
*
ffp
,
PacketQueue
*
q
,
AVPacket
*
pkt
,
int
*
serial
)
static
int
packet_queue_get_or_buffering
(
FFPlayer
*
ffp
,
PacketQueue
*
q
,
AVPacket
*
pkt
,
int
*
serial
,
int
finished
)
{
{
int
eof
=
0
;
while
(
1
)
{
while
(
1
)
{
int
new_packet
=
packet_queue_get
(
q
,
pkt
,
0
,
serial
);
int
new_packet
=
packet_queue_get
(
q
,
pkt
,
0
,
serial
);
if
(
new_packet
<
0
)
if
(
new_packet
<
0
)
return
-
1
;
return
-
1
;
else
if
(
new_packet
==
0
)
{
else
if
(
new_packet
==
0
)
{
if
(
!
eof
)
if
(
!
finished
)
ffp_toggle_buffering
(
ffp
,
1
);
ffp_toggle_buffering
(
ffp
,
1
);
new_packet
=
packet_queue_get
(
q
,
pkt
,
1
,
serial
);
new_packet
=
packet_queue_get
(
q
,
pkt
,
1
,
serial
);
if
(
new_packet
<
0
)
if
(
new_packet
<
0
)
return
-
1
;
return
-
1
;
eof
=
0
;
}
}
if
(
pkt
->
data
==
eof_pkt
.
data
)
if
(
finished
)
eof
=
1
;
continue
;
else
else
break
;
break
;
}
}
...
@@ -886,7 +882,7 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
...
@@ -886,7 +882,7 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
VideoState
*
is
=
ffp
->
is
;
VideoState
*
is
=
ffp
->
is
;
int
got_picture
;
int
got_picture
;
if
(
packet_queue_get_or_buffering
(
ffp
,
&
is
->
videoq
,
pkt
,
serial
)
<
0
)
if
(
packet_queue_get_or_buffering
(
ffp
,
&
is
->
videoq
,
pkt
,
serial
,
is
->
video_finished
)
<
0
)
return
-
1
;
return
-
1
;
if
(
pkt
->
data
==
flush_pkt
.
data
)
{
if
(
pkt
->
data
==
flush_pkt
.
data
)
{
...
@@ -941,8 +937,10 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
...
@@ -941,8 +937,10 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
frame
->
pts
,
g_vdps_counter
,
(
int64_t
)
avg_frame_time
,
fps
,
dur
);
frame
->
pts
,
g_vdps_counter
,
(
int64_t
)
avg_frame_time
,
fps
,
dur
);
#endif
#endif
if
(
!
got_picture
&&
!
pkt
->
data
)
if
(
!
got_picture
&&
!
pkt
->
data
)
{
ALOGE
(
"video_finished"
);
is
->
video_finished
=
*
serial
;
is
->
video_finished
=
*
serial
;
}
if
(
got_picture
)
{
if
(
got_picture
)
{
int
ret
=
1
;
int
ret
=
1
;
...
@@ -1383,8 +1381,10 @@ static int audio_decode_frame(FFPlayer *ffp)
...
@@ -1383,8 +1381,10 @@ static int audio_decode_frame(FFPlayer *ffp)
pkt_temp
->
size
-=
len1
;
pkt_temp
->
size
-=
len1
;
if
((
pkt_temp
->
data
&&
pkt_temp
->
size
<=
0
)
||
(
!
pkt_temp
->
data
&&
!
got_frame
))
if
((
pkt_temp
->
data
&&
pkt_temp
->
size
<=
0
)
||
(
!
pkt_temp
->
data
&&
!
got_frame
))
pkt_temp
->
stream_index
=
-
1
;
pkt_temp
->
stream_index
=
-
1
;
if
(
!
pkt_temp
->
data
&&
!
got_frame
)
if
(
!
pkt_temp
->
data
&&
!
got_frame
)
{
ALOGE
(
"audio_finished"
);
is
->
audio_finished
=
is
->
audio_pkt_temp_serial
;
is
->
audio_finished
=
is
->
audio_pkt_temp_serial
;
}
if
(
!
got_frame
)
if
(
!
got_frame
)
continue
;
continue
;
...
@@ -1554,7 +1554,7 @@ static int audio_decode_frame(FFPlayer *ffp)
...
@@ -1554,7 +1554,7 @@ static int audio_decode_frame(FFPlayer *ffp)
SDL_CondSignal
(
is
->
continue_read_thread
);
SDL_CondSignal
(
is
->
continue_read_thread
);
/* read next packet */
/* read next packet */
if
(
packet_queue_get_or_buffering
(
ffp
,
&
is
->
audioq
,
pkt
,
&
is
->
audio_pkt_temp_serial
)
<=
0
)
if
(
packet_queue_get_or_buffering
(
ffp
,
&
is
->
audioq
,
pkt
,
&
is
->
audio_pkt_temp_serial
,
is
->
audio_finished
)
<=
0
)
return
-
1
;
return
-
1
;
if
(
pkt
->
data
==
flush_pkt
.
data
)
{
if
(
pkt
->
data
==
flush_pkt
.
data
)
{
...
@@ -2093,8 +2093,6 @@ static int read_thread(void *arg)
...
@@ -2093,8 +2093,6 @@ static int read_thread(void *arg)
}
}
#endif
#endif
if
(
is
->
seek_req
)
{
if
(
is
->
seek_req
)
{
completed
=
0
;
int64_t
seek_target
=
is
->
seek_pos
;
int64_t
seek_target
=
is
->
seek_pos
;
int64_t
seek_min
=
is
->
seek_rel
>
0
?
seek_target
-
is
->
seek_rel
+
2
:
INT64_MIN
;
int64_t
seek_min
=
is
->
seek_rel
>
0
?
seek_target
-
is
->
seek_rel
+
2
:
INT64_MIN
;
int64_t
seek_max
=
is
->
seek_rel
<
0
?
seek_target
-
is
->
seek_rel
-
2
:
INT64_MAX
;
int64_t
seek_max
=
is
->
seek_rel
<
0
?
seek_target
-
is
->
seek_rel
-
2
:
INT64_MAX
;
...
@@ -2129,6 +2127,7 @@ static int read_thread(void *arg)
...
@@ -2129,6 +2127,7 @@ static int read_thread(void *arg)
is
->
seek_req
=
0
;
is
->
seek_req
=
0
;
is
->
queue_attachments_req
=
1
;
is
->
queue_attachments_req
=
1
;
eof
=
0
;
eof
=
0
;
completed
=
0
;
SDL_LockMutex
(
ffp
->
is
->
play_mutex
);
SDL_LockMutex
(
ffp
->
is
->
play_mutex
);
if
(
ffp
->
auto_start
)
{
if
(
ffp
->
auto_start
)
{
// ALOGE("seek: auto_start\n");
// ALOGE("seek: auto_start\n");
...
@@ -2178,7 +2177,7 @@ static int read_thread(void *arg)
...
@@ -2178,7 +2177,7 @@ static int read_thread(void *arg)
SDL_UnlockMutex
(
wait_mutex
);
SDL_UnlockMutex
(
wait_mutex
);
continue
;
continue
;
}
}
if
(
!
is
->
paused
&&
if
(
(
!
is
->
paused
||
completed
)
&&
(
!
is
->
audio_st
||
is
->
audio_finished
==
is
->
audioq
.
serial
)
&&
(
!
is
->
audio_st
||
is
->
audio_finished
==
is
->
audioq
.
serial
)
&&
(
!
is
->
video_st
||
(
is
->
video_finished
==
is
->
videoq
.
serial
&&
is
->
pictq_size
==
0
)))
{
(
!
is
->
video_st
||
(
is
->
video_finished
==
is
->
videoq
.
serial
&&
is
->
pictq_size
==
0
)))
{
if
(
ffp
->
loop
!=
1
&&
(
!
ffp
->
loop
||
--
ffp
->
loop
))
{
if
(
ffp
->
loop
!=
1
&&
(
!
ffp
->
loop
||
--
ffp
->
loop
))
{
...
@@ -2188,17 +2187,20 @@ static int read_thread(void *arg)
...
@@ -2188,17 +2187,20 @@ static int read_thread(void *arg)
goto
fail
;
goto
fail
;
}
else
{
}
else
{
if
(
completed
)
{
if
(
completed
)
{
ALOGE
(
"ffp_toggle_buffering: eof
\n
"
);
SDL_LockMutex
(
wait_mutex
);
SDL_LockMutex
(
wait_mutex
);
// infinite wait may block shutdown
// infinite wait may block shutdown
while
(
!
is
->
abort_request
)
while
(
!
is
->
abort_request
&&
!
is
->
seek_req
)
SDL_CondWaitTimeout
(
is
->
continue_read_thread
,
wait_mutex
,
10
);
SDL_CondWaitTimeout
(
is
->
continue_read_thread
,
wait_mutex
,
10
);
SDL_UnlockMutex
(
wait_mutex
);
SDL_UnlockMutex
(
wait_mutex
);
if
(
!
is
->
abort_request
)
continue
;
}
else
{
}
else
{
completed
=
1
;
completed
=
1
;
ffp
->
auto_start
=
0
;
ffp
->
auto_start
=
0
;
// TODO: 0 it's a bit early to notify complete here
// TODO: 0 it's a bit early to notify complete here
ALOGE
(
"ffp_toggle_buffering:
eof
\n
"
);
ALOGE
(
"ffp_toggle_buffering:
completed
\n
"
);
ffp_toggle_buffering
(
ffp
,
0
);
ffp_toggle_buffering
(
ffp
,
0
);
toggle_pause
(
ffp
,
1
);
toggle_pause
(
ffp
,
1
);
ffp_notify_msg1
(
ffp
,
FFP_MSG_COMPLETED
);
ffp_notify_msg1
(
ffp
,
FFP_MSG_COMPLETED
);
...
@@ -2210,6 +2212,7 @@ static int read_thread(void *arg)
...
@@ -2210,6 +2212,7 @@ static int read_thread(void *arg)
packet_queue_put_nullpacket
(
&
is
->
videoq
,
is
->
video_stream
);
packet_queue_put_nullpacket
(
&
is
->
videoq
,
is
->
video_stream
);
if
(
is
->
audio_stream
>=
0
)
if
(
is
->
audio_stream
>=
0
)
packet_queue_put_nullpacket
(
&
is
->
audioq
,
is
->
audio_stream
);
packet_queue_put_nullpacket
(
&
is
->
audioq
,
is
->
audio_stream
);
ffp_toggle_buffering
(
ffp
,
0
);
SDL_Delay
(
10
);
SDL_Delay
(
10
);
eof
=
0
;
eof
=
0
;
continue
;
continue
;
...
@@ -2218,17 +2221,6 @@ static int read_thread(void *arg)
...
@@ -2218,17 +2221,6 @@ static int read_thread(void *arg)
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
ret
==
AVERROR_EOF
||
url_feof
(
ic
->
pb
))
{
if
(
ret
==
AVERROR_EOF
||
url_feof
(
ic
->
pb
))
{
eof
=
1
;
eof
=
1
;
if
(
is
->
audio_stream
>=
0
)
packet_queue_put
(
&
is
->
audioq
,
&
eof_pkt
);
#ifdef FFP_MERGE
if
(
is
->
subtitle_stream
>=
0
)
packet_queue_put
(
&
is
->
subtitleq
,
&
eof_pkt
);
#endif
if
(
is
->
video_stream
>=
0
)
packet_queue_put
(
&
is
->
videoq
,
&
eof_pkt
);
ffp_toggle_buffering
(
ffp
,
0
);
}
else
if
(
ic
->
pb
&&
ic
->
pb
->
error
)
{
}
else
if
(
ic
->
pb
&&
ic
->
pb
->
error
)
{
// TODO: 9 notify error until a/v finished
// TODO: 9 notify error until a/v finished
last_error
=
ic
->
pb
->
error
;
last_error
=
ic
->
pb
->
error
;
...
@@ -2699,7 +2691,7 @@ int ffp_seek_to_l(FFPlayer *ffp, long msec)
...
@@ -2699,7 +2691,7 @@ int ffp_seek_to_l(FFPlayer *ffp, long msec)
// FIXME: 9 seek by bytes
// FIXME: 9 seek by bytes
// FIXME: 9 seek out of range
// FIXME: 9 seek out of range
// FIXME: 9 seekable
// FIXME: 9 seekable
//
ALOGE("stream_seek %"PRId64"(%d) + %"PRId64", \n", seek_pos, (int)msec, start_time);
ALOGE
(
"stream_seek %"
PRId64
"(%d) + %"
PRId64
",
\n
"
,
seek_pos
,
(
int
)
msec
,
start_time
);
stream_seek
(
is
,
seek_pos
,
0
,
0
);
stream_seek
(
is
,
seek_pos
,
0
,
0
);
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录