forked from fecf/ffmpeg-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideoplayer.h
52 lines (37 loc) · 1.18 KB
/
videoplayer.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
#pragma once
#include <functional>
#include <memory>
#include <string>
struct VideoContext;
enum class BinkColorSpace { Jpeg, Mpeg };
class VideoPlayer {
public:
// Format is ALWAYS RGBx
using OnVideoFrame = std::function<void(double time, uint8_t* pixelData, int size, int stride)>;
using OnAudioSamples = std::function<void(float* planes[], int sampleCount, bool interleaved)>;
using OnStop = std::function<void()>;
VideoPlayer() noexcept;
virtual ~VideoPlayer() noexcept;
bool open(const char* path) noexcept;
void play(OnVideoFrame onVideoFrame, OnAudioSamples onAudioSamples, OnStop onStop) noexcept;
void stop() noexcept;
bool atEnd() const noexcept;
const std::string& error() const noexcept;
bool hasVideo() const noexcept;
int width() const noexcept;
int height() const noexcept;
/**
* @return True if this video has audio data.
*/
bool hasAudio() const noexcept;
/**
* @return The audio sample rate in samples per second.
*/
int audioSampleRate() const noexcept;
/**
* @return The number of audio channels, guaranteed to be 1 or 2.
*/
int audioChannels() const noexcept;
private:
std::unique_ptr<VideoContext> video;
};