Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ijkplayer
提交
148353ca
I
ijkplayer
项目概览
NotesChapter
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
148353ca
编写于
6月 04, 2013
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ijkmedia: ffplay: introduce pkt_queue
上级
7e59d851
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
226 addition
and
1 deletion
+226
-1
ijkmedia/jni/ffplay/Android.mk
ijkmedia/jni/ffplay/Android.mk
+4
-1
ijkmedia/jni/ffplay/pkt_queue.c
ijkmedia/jni/ffplay/pkt_queue.c
+165
-0
ijkmedia/jni/ffplay/pkt_queue.h
ijkmedia/jni/ffplay/pkt_queue.h
+57
-0
未找到文件。
ijkmedia/jni/ffplay/Android.mk
浏览文件 @
148353ca
...
...
@@ -4,7 +4,10 @@ include $(CLEAR_VARS)
LOCAL_C_INCLUDES
+=
$(LOCAL_PATH)
$(MY_APP_FFMPEG_INCLUDE_PATH)
# LOCAL_LDLIBS += -ldl -llog
LOCAL_SRC_FILES
:=
ffplay.c
LOCAL_SRC_FILES
:=
pkt_queue.c
LOCAL_SRC_FILES
+=
ffplay.c
LOCAL_SHARED_LIBRARIES
:=
ffmpeg
LOCAL_MODULE
:=
ffplay
include
$(BUILD_SHARED_LIBRARY)
\ No newline at end of file
ijkmedia/jni/ffplay/pkt_queue.c
0 → 100644
浏览文件 @
148353ca
/*****************************************************************************
* pkt_queue.c
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* Based on ffmpeg/ffplay.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pkt_queue.h"
AVPacket
g_flush_pkt
;
int
packet_queue_put
(
PacketQueue
*
q
,
AVPacket
*
pkt
);
int
packet_queue_put_private
(
PacketQueue
*
q
,
AVPacket
*
pkt
)
{
MyAVPacketList
*
pkt1
;
if
(
q
->
abort_request
)
return
-
1
;
pkt1
=
av_malloc
(
sizeof
(
MyAVPacketList
));
if
(
!
pkt1
)
return
-
1
;
pkt1
->
pkt
=
*
pkt
;
pkt1
->
next
=
NULL
;
if
(
pkt
==
&
g_flush_pkt
)
q
->
serial
++
;
pkt1
->
serial
=
q
->
serial
;
if
(
!
q
->
last_pkt
)
q
->
first_pkt
=
pkt1
;
else
q
->
last_pkt
->
next
=
pkt1
;
q
->
last_pkt
=
pkt1
;
q
->
nb_packets
++
;
q
->
size
+=
pkt1
->
pkt
.
size
+
sizeof
(
*
pkt1
);
/* XXX: should duplicate packet data in DV case */
pthread_cond_signal
(
&
q
->
cond
);
return
0
;
}
int
packet_queue_put
(
PacketQueue
*
q
,
AVPacket
*
pkt
)
{
int
ret
;
/* duplicate the packet */
if
(
pkt
!=
&
g_flush_pkt
&&
av_dup_packet
(
pkt
)
<
0
)
return
-
1
;
pthread_mutex_lock
(
&
q
->
mutex
);
ret
=
packet_queue_put_private
(
q
,
pkt
);
pthread_mutex_unlock
(
&
q
->
mutex
);
if
(
pkt
!=
&
g_flush_pkt
&&
ret
<
0
)
av_free_packet
(
pkt
);
return
ret
;
}
/* packet queue handling */
void
packet_queue_init
(
PacketQueue
*
q
)
{
memset
(
q
,
0
,
sizeof
(
PacketQueue
));
pthread_mutex_init
(
&
q
->
mutex
,
NULL
);
pthread_cond_init
(
&
q
->
cond
,
NULL
);
q
->
abort_request
=
1
;
}
void
packet_queue_flush
(
PacketQueue
*
q
)
{
MyAVPacketList
*
pkt
,
*
pkt1
;
pthread_mutex_lock
(
&
q
->
mutex
);
for
(
pkt
=
q
->
first_pkt
;
pkt
!=
NULL
;
pkt
=
pkt1
)
{
pkt1
=
pkt
->
next
;
av_free_packet
(
&
pkt
->
pkt
);
av_freep
(
&
pkt
);
}
q
->
last_pkt
=
NULL
;
q
->
first_pkt
=
NULL
;
q
->
nb_packets
=
0
;
q
->
size
=
0
;
pthread_mutex_unlock
(
&
q
->
mutex
);
}
void
packet_queue_destroy
(
PacketQueue
*
q
)
{
packet_queue_flush
(
q
);
pthread_mutex_destroy
(
&
q
->
mutex
);
pthread_cond_destroy
(
&
q
->
cond
);
}
void
packet_queue_abort
(
PacketQueue
*
q
)
{
pthread_mutex_lock
(
&
q
->
mutex
);
q
->
abort_request
=
1
;
pthread_cond_signal
(
&
q
->
cond
);
pthread_mutex_unlock
(
&
q
->
mutex
);
}
void
packet_queue_start
(
PacketQueue
*
q
)
{
pthread_mutex_lock
(
&
q
->
mutex
);
q
->
abort_request
=
0
;
packet_queue_put_private
(
q
,
&
g_flush_pkt
);
pthread_mutex_unlock
(
&
q
->
mutex
);
}
/* return < 0 if aborted, 0 if no packet and > 0 if packet. */
int
packet_queue_get
(
PacketQueue
*
q
,
AVPacket
*
pkt
,
int
block
,
int
*
serial
)
{
MyAVPacketList
*
pkt1
;
int
ret
;
pthread_mutex_lock
(
&
q
->
mutex
);
for
(;;)
{
if
(
q
->
abort_request
)
{
ret
=
-
1
;
break
;
}
pkt1
=
q
->
first_pkt
;
if
(
pkt1
)
{
q
->
first_pkt
=
pkt1
->
next
;
if
(
!
q
->
first_pkt
)
q
->
last_pkt
=
NULL
;
q
->
nb_packets
--
;
q
->
size
-=
pkt1
->
pkt
.
size
+
sizeof
(
*
pkt1
);
*
pkt
=
pkt1
->
pkt
;
if
(
serial
)
*
serial
=
pkt1
->
serial
;
av_free
(
pkt1
);
ret
=
1
;
break
;
}
else
if
(
!
block
)
{
ret
=
0
;
break
;
}
else
{
pthread_cond_wait
(
&
q
->
cond
,
&
q
->
mutex
);
}
}
pthread_mutex_unlock
(
&
q
->
mutex
);
return
ret
;
}
ijkmedia/jni/ffplay/pkt_queue.h
0 → 100644
浏览文件 @
148353ca
/*****************************************************************************
* pkt_queue.h
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* Based on ffmpeg/ffplay.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PKT_QUEUE_H
#define PKT_QUEUE_H
#include <pthread.h>
#include <libavformat/avformat.h>
typedef
struct
MyAVPacketList
{
AVPacket
pkt
;
struct
MyAVPacketList
*
next
;
int
serial
;
}
MyAVPacketList
;
typedef
struct
PacketQueue
{
MyAVPacketList
*
first_pkt
,
*
last_pkt
;
int
nb_packets
;
int
size
;
int
abort_request
;
int
serial
;
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
}
PacketQueue
;
void
packet_queue_init
(
PacketQueue
*
q
);
void
packet_queue_destroy
(
PacketQueue
*
q
);
void
packet_queue_start
(
PacketQueue
*
q
);
void
packet_queue_abort
(
PacketQueue
*
q
);
void
packet_queue_flush
(
PacketQueue
*
q
);
int
packet_queue_put
(
PacketQueue
*
q
,
AVPacket
*
pkt
);
int
packet_queue_get
(
PacketQueue
*
q
,
AVPacket
*
pkt
,
int
block
,
int
*
serial
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录