-
Notifications
You must be signed in to change notification settings - Fork 3
/
player.h
72 lines (51 loc) · 1.72 KB
/
player.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
#pragma once
#include "videodevice.h"
#include "audiodevice.h"
#include "mediadecoder.h"
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 26495) // uninitialized variable
#endif
#include <boost/function.hpp>
#ifdef WIN32
#pragma warning( pop )
#endif
#include <thread>
namespace player
{
typedef boost::function<void ()> SwapBufferCallback;
struct Player
{
std::string path;
mediadecoder::Decoder* decoder = nullptr;
mediadecoder::Producer* producer = nullptr;
mediadecoder::VideoFrame* videoFrame = nullptr;
mediadecoder::Subtitle* subtitle = nullptr;
mediadecoder::Subtitle* nextSubtitle = nullptr;
audiodevice::Device* audioDevice = nullptr;
videodevice::Device* videoDevice = nullptr;
uint64_t playbackStartTimeUs = 0;
uint64_t currentTimeUs = 0;
std::atomic<bool> playing = false;
std::atomic<bool> pause = false;
std::atomic<bool> buffering = false;
std::atomic<bool> queueAudio = false;;
std::thread audioThread;
};
Result Init(SwapBufferCallback);
Result Create(Player*& player);
Result Open(Player*, const std::string& filename);
void SetWindowSize(Player*,uint32_t, uint32_t);
void ToggleSubtitleTrack(Player*);
void AddSubtitleTrack(Player*, std::shared_ptr<subtitle::SubRip> srt);
void Play(Player*);
void Seek(Player*, uint64_t timeUs);
void Pause(Player*);
bool IsPlaying(Player*);
uint64_t GetDuration(Player*);
uint64_t GetCurrentTime(Player*);
const std::string& GetPath(Player*);
void Present(Player*);
void Close(Player*);
void Destroy(Player*&);
};