File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,7 +34,14 @@ set(SRC_METADATA
3434
3535set (SRC_FFPLAYER
3636 ffplayer/queue/FrameQueue.cpp
37- ffplayer/queue/PacketQueue.cpp)
37+ ffplayer/queue/PacketQueue.cpp
38+ ffplayer/decode/BaseDecoder.cpp
39+ ffplayer/decode/FFAudioDecoder.cpp
40+ ffplayer/decode/FFVideoDecoder.cpp
41+ ffplayer/clock/MediaClock.cpp
42+ ffplayer/render/android /AudioAndroidRender.cpp
43+ ffplayer/FFMessageQueue.cpp
44+ ffplayer/FFMediaPlayer.cpp)
3845
3946add_library ( # Sets the name of the library.
4047 media-handle
@@ -74,6 +81,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
7481include_directories (. )
7582include_directories (include )
7683include_directories (metadata )
84+ include_directories (ffplayer )
7785
7886if (${CMAKE_ANDROID_ARCH_ABI} MATCHES "armeabi-v7a" )
7987 include_directories (include /armeabi-v7a )
Original file line number Diff line number Diff line change 1- //
2- // Created by xu fulong on 2022/9/24.
3- //
41
52#include " FFMessageQueue.h"
63
Original file line number Diff line number Diff line change 1- //
2- // Created by xu fulong on 2022/9/24.
3- //
41
52#ifndef FFMPEGANDROID_FFMESSAGEQUEUE_H
63#define FFMPEGANDROID_FFMESSAGEQUEUE_H
2623#define FFP_MSG_COMPONENT_OPEN 409
2724#define FFP_MSG_VIDEO_SEEK_RENDERING_START 410
2825#define FFP_MSG_AUDIO_SEEK_RENDERING_START 411
26+ #define FFP_MSG_DECODER_OPEN_ERROR 412
27+ #define FFP_MSG_DEMUX_ERROR 413
2928
3029#define FFP_MSG_BUFFERING_START 500
3130#define FFP_MSG_BUFFERING_END 501
3635#define FFP_MSG_PLAYBACK_STATE_CHANGED 700
3736#define FFP_MSG_TIMED_TEXT 800
3837#define FFP_MSG_VIDEO_DECODER_OPEN 900
38+ #define FFP_MSG_OPEN_ERROR 901
3939
4040#define FFP_REQ_START 1001
4141#define FFP_REQ_PAUSE 1002
Original file line number Diff line number Diff line change 1+
2+ #include < ffplay_define.h>
3+ #include " MediaClock.h"
4+
5+ MediaClock::MediaClock () {
6+ m_speed = 1.0 ;
7+ m_pause = false ;
8+ setClock (NAN );
9+ }
10+
11+ void MediaClock::setClock (double pts) {
12+ double time = (double ) av_gettime_relative () / 1000000.0 ;
13+ setClock (pts, time);
14+ }
15+
16+ void MediaClock::setClock (double pts, double time) {
17+ m_pts = pts;
18+ m_last_update = time;
19+ m_pts_drift = m_pts - time;
20+ }
21+
22+ double MediaClock::getClock () const {
23+ if (m_pause) {
24+ return m_pts;
25+ } else {
26+ double time = (double ) av_gettime_relative () / 1000000.0 ;
27+ return m_pts_drift + time - (time - m_last_update) * (1.0 - m_speed);
28+ }
29+ }
30+
31+ void MediaClock::setSpeed (double speed) {
32+ setClock (getClock ());
33+ m_speed = speed;
34+ }
35+
36+ double MediaClock::getSpeed () const {
37+ return m_speed;
38+ }
39+
40+ void MediaClock::syncToSlave (MediaClock *slave) {
41+ double clock = getClock ();
42+ double slave_clock = slave->getClock ();
43+ if (!isnan (slave_clock) && (isnan (clock) || fabs (clock - slave_clock) > AV_NOSYNC_THRESHOLD )) {
44+ setClock (slave_clock);
45+ }
46+ }
47+
48+ MediaClock::~MediaClock () {
49+
50+ }
Original file line number Diff line number Diff line change 1+
2+ #ifndef FFMPEGANDROID_MEDIACLOCK_H
3+ #define FFMPEGANDROID_MEDIACLOCK_H
4+
5+ #include < math.h>
6+
7+ #ifdef __cplusplus
8+ extern " C" {
9+ #endif
10+ #include < libavutil/time.h>
11+ #ifdef __cplusplus
12+ }
13+ #endif
14+
15+ class MediaClock {
16+
17+ private:
18+ bool m_pause;
19+ double m_pts;
20+ double m_speed;
21+ double m_pts_drift;
22+ double m_last_update;
23+
24+ public:
25+
26+ MediaClock ();
27+
28+ void setClock (double pts);
29+
30+ void setClock (double pts, double time);
31+
32+ double getClock () const ;
33+
34+ void setSpeed (double speed);
35+
36+ double getSpeed () const ;
37+
38+ void syncToSlave (MediaClock *slave);
39+
40+ virtual ~MediaClock ();
41+
42+ };
43+
44+
45+ #endif // FFMPEGANDROID_MEDIACLOCK_H
Original file line number Diff line number Diff line change 1- //
2- // Created by xu fulong on 2022/9/22.
3- //
41
52#ifndef FFMPEGANDROID_FFPLAY_DEFINE_H
63#define FFMPEGANDROID_FFPLAY_DEFINE_H
@@ -57,7 +54,7 @@ class PlayerParams {
5754public:
5855 std::mutex mutex;
5956
60- MessageQueue *messageQueue;
57+ FFMessageQueue *messageQueue;
6158 int64_t videoDuration;
6259
6360 AVInputFormat *iformat;
You can’t perform that action at this time.
0 commit comments