-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMediaPlayer.h
88 lines (72 loc) · 1.64 KB
/
MediaPlayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef __MEDIAPLAYER_H__
#define __MEDIAPLAYER_H__
#include <pthread.h>
#include "AudioDecoder.h"
#include "VideoDecoder.h"
#include "FrameQueue.h"
#include "PlayerListener.h"
class MediaPlayer {
public:
MediaPlayer();
~MediaPlayer();
int setListener(PlayerListener *listener);
int setThreadNumber(int num);
int setLoopPlay(int loop);
int open(char* file);
int start();
int pause();
int go();
int stop();
int close();
bool isPlaying();
int getVideoWidth(int *w);
int getVideoHeight(int *h);
int seekTo(int msec);
int getCurrentPosition(int *msec);
int getDuration(int *msec);
int getAudioParams(int *params);
int wait();
private:
int mThreadNumber;
int mLoopPlay;
int mNeedSeek;
int mDemuxed;
int mPause;
int mStop;
int mPrepared;
int mFrameCount;
double mTimeStart;
int mFrames;
double mTimeLast;
AVPacket mFlushPacket;
AVPacket mEndPacket;
pthread_mutex_t mLock;
pthread_t mDemuxingThread;
pthread_t mRenderingThread;
PlayerListener* mListener;
AVFormatContext* mFormatContext;
int mAudioStreamIndex;
int mVideoStreamIndex;
AudioDecoder* mAudioDecoder;
VideoDecoder* mVideoDecoder;
int mVideoWidth;
int mVideoHeight;
FrameQueue* mFrameQueue;
// in ms
int64_t mDuration;
int64_t mCurrentPosition;
int64_t mSeekPosition;
// in seconds
double mTime;
double mAudioClock;
double mFrameLastDelay, mFrameLastPTS;
int prepareAudio();
int prepareVideo();
void demuxMedia(void* ptr);
void renderVideo(void* ptr);
static void* startDemuxing(void* ptr);
static void* startRendering(void* ptr);
static void videoOutput(AVFrame* frame, double pts);
static void audioOutput(void* buffer, int buffer_size);
};
#endif