Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ijkplayer
提交
ee5afeff
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,发现更多精彩内容 >>
提交
ee5afeff
编写于
6月 05, 2013
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ffplay: introduce minisdl_thread
上级
4c3787dc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
294 addition
and
24 deletion
+294
-24
ijkmediaplayer/jni/ffplay/Android.mk
ijkmediaplayer/jni/ffplay/Android.mk
+2
-1
ijkmediaplayer/jni/ffplay/demux_thread.c
ijkmediaplayer/jni/ffplay/demux_thread.c
+26
-0
ijkmediaplayer/jni/ffplay/internal.h
ijkmediaplayer/jni/ffplay/internal.h
+36
-0
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.c
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.c
+152
-0
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.h
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.h
+55
-0
ijkmediaplayer/jni/ffplay/pkt_queue.c
ijkmediaplayer/jni/ffplay/pkt_queue.c
+20
-20
ijkmediaplayer/jni/ffplay/pkt_queue.h
ijkmediaplayer/jni/ffplay/pkt_queue.h
+3
-3
未找到文件。
ijkmediaplayer/jni/ffplay/Android.mk
浏览文件 @
ee5afeff
...
...
@@ -4,7 +4,8 @@ include $(CLEAR_VARS)
LOCAL_C_INCLUDES
+=
$(LOCAL_PATH)
$(MY_APP_FFMPEG_INCLUDE_PATH)
# LOCAL_LDLIBS += -ldl -llog
LOCAL_SRC_FILES
:=
pkt_queue.c
LOCAL_SRC_FILES
:=
minisdl/minisdl_thread.c
LOCAL_SRC_FILES
+=
pkt_queue.c
LOCAL_SRC_FILES
+=
ffplay.c
LOCAL_SHARED_LIBRARIES
:=
ffmpeg
...
...
ijkmediaplayer/jni/ffplay/demux_thread.c
0 → 100644
浏览文件 @
ee5afeff
/*****************************************************************************
* demux_thread.c
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer 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.
*
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "internal.h"
ijkmediaplayer/jni/ffplay/internal.h
0 → 100644
浏览文件 @
ee5afeff
/*****************************************************************************
* internal.h
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer 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.
*
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLAYER_H
#define PLAYER_H
#include <inttypes.h>
enum
{
AV_SYNC_AUDIO_MASTER
,
/* default choice */
AV_SYNC_VIDEO_MASTER
,
AV_SYNC_EXTERNAL_CLOCK
,
/* synchronize to an external clock */
};
#endif
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.c
0 → 100644
浏览文件 @
ee5afeff
/*****************************************************************************
* minisdl_thread.c
*****************************************************************************
*
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer 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.
*
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <assert.h>
#include "minisdl_thread.h"
SDL_mutex
*
SDL_CreateMutex
(
void
)
{
SDL_mutex
*
mutex
;
mutex
=
(
SDL_mutex
*
)
malloc
(
sizeof
(
SDL_mutex
));
if
(
!
mutex
)
return
NULL
;
if
(
pthread_mutex_init
(
&
mutex
->
id
,
NULL
)
!=
0
)
{
free
(
mutex
);
}
return
mutex
;
}
void
SDL_DestroyMutex
(
SDL_mutex
*
mutex
)
{
if
(
mutex
)
{
pthread_mutex_destroy
(
&
mutex
->
id
);
free
(
mutex
);
}
}
int
SDL_LockMutex
(
SDL_mutex
*
mutex
)
{
assert
(
mutex
);
if
(
!
mutex
)
return
-
1
;
return
pthread_mutex_lock
(
&
mutex
->
id
);
}
int
SDL_UnlockMutex
(
SDL_mutex
*
mutex
)
{
assert
(
mutex
);
if
(
!
mutex
)
return
-
1
;
return
pthread_mutex_unlock
(
&
mutex
->
id
);
}
SDL_cond
*
SDL_CreateCond
(
void
)
{
SDL_cond
*
cond
;
cond
=
(
SDL_cond
*
)
malloc
(
sizeof
(
SDL_cond
));
if
(
!
cond
)
return
NULL
;
if
(
pthread_cond_init
(
&
cond
->
id
,
NULL
)
!=
0
)
{
free
(
cond
);
}
return
cond
;
}
void
SDL_DestroyCond
(
SDL_cond
*
cond
)
{
if
(
cond
)
{
pthread_cond_destroy
(
&
cond
->
id
);
free
(
cond
);
}
}
int
SDL_CondSignal
(
SDL_cond
*
cond
)
{
assert
(
cond
);
if
(
!
cond
)
return
-
1
;
return
pthread_cond_signal
(
&
cond
->
id
);
}
int
SDL_CondBroadcast
(
SDL_cond
*
cond
)
{
assert
(
cond
);
if
(
!
cond
)
return
-
1
;
return
pthread_cond_broadcast
(
&
cond
->
id
);
}
int
SDL_CondWaitTimeout
(
SDL_cond
*
cond
,
SDL_mutex
*
mutex
,
uint32_t
ms
)
{
int
retval
;
struct
timeval
delta
;
struct
timespec
abstime
;
assert
(
cond
);
assert
(
mutex
);
if
(
!
cond
||
!
mutex
)
{
return
-
1
;
}
gettimeofday
(
&
delta
,
NULL
);
abstime
.
tv_sec
=
delta
.
tv_sec
+
(
ms
/
1000
);
abstime
.
tv_nsec
=
(
delta
.
tv_usec
+
(
ms
%
1000
)
*
1000
)
*
1000
;
if
(
abstime
.
tv_nsec
>
1000000000
)
{
abstime
.
tv_sec
+=
1
;
abstime
.
tv_nsec
-=
1000000000
;
}
while
(
1
)
{
retval
=
pthread_cond_timedwait
(
&
cond
->
id
,
&
mutex
->
id
,
&
abstime
);
if
(
retval
==
0
)
return
0
;
else
if
(
retval
==
EINTR
)
continue
;
else
if
(
retval
==
ETIMEDOUT
)
return
SDL_MUTEX_TIMEDOUT
;
else
break
;
}
return
-
1
;
}
int
SDL_CondWait
(
SDL_cond
*
cond
,
SDL_mutex
*
mutex
)
{
assert
(
cond
);
assert
(
mutex
);
if
(
!
cond
||
!
mutex
)
return
-
1
;
return
pthread_cond_wait
(
&
cond
->
id
,
&
mutex
->
id
);
}
ijkmediaplayer/jni/ffplay/minisdl/minisdl_thread.h
0 → 100644
浏览文件 @
ee5afeff
/*****************************************************************************
* minisdl_thread.h
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer 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.
*
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MINISDL_THREAD_H
#define MINISDL_THREAD_H
#include <stdint.h>
#include <pthread.h>
#define SDL_MUTEX_TIMEDOUT 1
#define SDL_MUTEX_MAXWAIT (~(uint32_t)0)
typedef
struct
SDL_mutex
{
pthread_mutex_t
id
;
}
SDL_mutex
;
SDL_mutex
*
SDL_CreateMutex
(
void
);
void
SDL_DestroyMutex
(
SDL_mutex
*
mutex
);
int
SDL_LockMutex
(
SDL_mutex
*
mutex
);
int
SDL_UnlockMutex
(
SDL_mutex
*
mutex
);
//int SDL_TryLockMutex(SDL_mutex * mutex);
typedef
struct
SDL_cond
{
pthread_cond_t
id
;
}
SDL_cond
;
SDL_cond
*
SDL_CreateCond
(
void
);
void
SDL_DestroyCond
(
SDL_cond
*
cond
);
int
SDL_CondSignal
(
SDL_cond
*
cond
);
int
SDL_CondBroadcast
(
SDL_cond
*
cond
);
int
SDL_CondWaitTimeout
(
SDL_cond
*
cond
,
SDL_mutex
*
mutex
,
uint32_t
ms
);
int
SDL_CondWait
(
SDL_cond
*
cond
,
SDL_mutex
*
mutex
);
#endif
ijkmediaplayer/jni/ffplay/pkt_queue.c
浏览文件 @
ee5afeff
...
...
@@ -24,16 +24,16 @@
#include "pkt_queue.h"
AVPacket
g_flush_pkt
;
static
AVPacket
g_flush_pkt
;
int
packet_queue_put
(
PacketQueue
*
q
,
AVPacket
*
pkt
);
int
packet_queue_put_private
(
PacketQueue
*
q
,
AVPacket
*
pkt
)
static
int
packet_queue_put_private
(
PacketQueue
*
q
,
AVPacket
*
pkt
)
{
MyAVPacketList
*
pkt1
;
if
(
q
->
abort_request
)
return
-
1
;
return
-
1
;
pkt1
=
av_malloc
(
sizeof
(
MyAVPacketList
));
if
(
!
pkt1
)
...
...
@@ -52,7 +52,7 @@ int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
q
->
nb_packets
++
;
q
->
size
+=
pkt1
->
pkt
.
size
+
sizeof
(
*
pkt1
);
/* XXX: should duplicate packet data in DV case */
pthread_cond_signal
(
&
q
->
cond
);
SDL_CondSignal
(
q
->
cond
);
return
0
;
}
...
...
@@ -64,9 +64,9 @@ int packet_queue_put(PacketQueue *q, AVPacket *pkt)
if
(
pkt
!=
&
g_flush_pkt
&&
av_dup_packet
(
pkt
)
<
0
)
return
-
1
;
pthread_mutex_lock
(
&
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
ret
=
packet_queue_put_private
(
q
,
pkt
);
pthread_mutex_unlock
(
&
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
if
(
pkt
!=
&
g_flush_pkt
&&
ret
<
0
)
av_free_packet
(
pkt
);
...
...
@@ -78,8 +78,8 @@ int packet_queue_put(PacketQueue *q, AVPacket *pkt)
void
packet_queue_init
(
PacketQueue
*
q
)
{
memset
(
q
,
0
,
sizeof
(
PacketQueue
));
pthread_mutex_init
(
&
q
->
mutex
,
NULL
);
pthread_cond_init
(
&
q
->
cond
,
NULL
);
q
->
mutex
=
SDL_CreateMutex
(
);
q
->
cond
=
SDL_CreateCond
(
);
q
->
abort_request
=
1
;
}
...
...
@@ -87,7 +87,7 @@ void packet_queue_flush(PacketQueue *q)
{
MyAVPacketList
*
pkt
,
*
pkt1
;
pthread_mutex_lock
(
&
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
for
(
pkt
=
q
->
first_pkt
;
pkt
!=
NULL
;
pkt
=
pkt1
)
{
pkt1
=
pkt
->
next
;
av_free_packet
(
&
pkt
->
pkt
);
...
...
@@ -97,33 +97,33 @@ void packet_queue_flush(PacketQueue *q)
q
->
first_pkt
=
NULL
;
q
->
nb_packets
=
0
;
q
->
size
=
0
;
pthread_mutex_unlock
(
&
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
}
void
packet_queue_destroy
(
PacketQueue
*
q
)
{
packet_queue_flush
(
q
);
pthread_mutex_destroy
(
&
q
->
mutex
);
pthread_cond_destroy
(
&
q
->
cond
);
SDL_DestroyMutex
(
q
->
mutex
);
SDL_DestroyCond
(
q
->
cond
);
}
void
packet_queue_abort
(
PacketQueue
*
q
)
{
pthread_mutex_lock
(
&
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
q
->
abort_request
=
1
;
pthread_cond_signal
(
&
q
->
cond
);
SDL_CondSignal
(
q
->
cond
);
pthread_mutex_unlock
(
&
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
}
void
packet_queue_start
(
PacketQueue
*
q
)
{
pthread_mutex_lock
(
&
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
q
->
abort_request
=
0
;
packet_queue_put_private
(
q
,
&
g_flush_pkt
);
pthread_mutex_unlock
(
&
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
}
/* return < 0 if aborted, 0 if no packet and > 0 if packet. */
...
...
@@ -132,7 +132,7 @@ int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial)
MyAVPacketList
*
pkt1
;
int
ret
;
pthread_mutex_lock
(
&
q
->
mutex
);
SDL_LockMutex
(
q
->
mutex
);
for
(;;)
{
if
(
q
->
abort_request
)
{
...
...
@@ -157,9 +157,9 @@ int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial)
ret
=
0
;
break
;
}
else
{
pthread_cond_wait
(
&
q
->
cond
,
&
q
->
mutex
);
SDL_CondWait
(
q
->
cond
,
q
->
mutex
);
}
}
pthread_mutex_unlock
(
&
q
->
mutex
);
SDL_UnlockMutex
(
q
->
mutex
);
return
ret
;
}
ijkmediaplayer/jni/ffplay/pkt_queue.h
浏览文件 @
ee5afeff
...
...
@@ -25,7 +25,7 @@
#ifndef PKT_QUEUE_H
#define PKT_QUEUE_H
#include <
p
thread.h>
#include <
minisdl/minisdl_
thread.h>
#include <libavformat/avformat.h>
typedef
struct
MyAVPacketList
{
...
...
@@ -40,8 +40,8 @@ typedef struct PacketQueue {
int
size
;
int
abort_request
;
int
serial
;
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
SDL_mutex
*
mutex
;
SDL_cond
*
cond
;
}
PacketQueue
;
void
packet_queue_init
(
PacketQueue
*
q
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录