TDME2  1.9.200
VideoDecoder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
8 
9 using std::string;
10 
12 
13 /**
14  * Video decoder base class
15  * @author Andreas Drewke
16  */
18 {
19 public:
20  static constexpr uint8_t AUDIO_CHANNELS_NONE { 0 };
21  static constexpr uint32_t AUDIO_SAMPLERATE_NONE { 0 };
22  static constexpr uint8_t AUDIO_BITSPERSAMPLES_NONE { 0 };
23  static constexpr uint64_t AUDIO_SAMPLES_NONE { 0 };
24 
25  static constexpr float VIDEO_FRAMERATE_NONE { 0.0f };
26  static constexpr float VIDEO_DURATION_NONE { 0.0f };
27  static constexpr uint16_t VIDEO_WIDTH_NONE { 0 };
28  static constexpr uint16_t VIDEO_HEIGHT_NONE { 0 };
29 
30 protected:
35 
40 
41  // forbid class copy
43 
44  /**
45  * Constructor
46  */
47  inline VideoDecoder() {}
48 
49  /**
50  * Destructor
51  */
52  inline virtual ~VideoDecoder() {}
53 
54 public:
55  /**
56  * Open a local file
57  * @param pathName path name
58  * @param fileName file name
59  * @throws tdme::video::decoder::VideoDecoderException
60  */
61  virtual void openFile(const string& pathName, const string& fileName) = 0;
62 
63  /**
64  * Resets this video decoder, if a stream was open it will be rewinded
65  */
66  virtual void reset() = 0;
67 
68  /**
69  * Update
70  * @param deltaTime delta time
71  */
72  virtual void update(float deltaTime) = 0;
73 
74  /**
75  * Update
76  * @param deltaTime delta time
77  */
78  virtual void seek(float time) = 0;
79 
80  /**
81  * @return number of channels or AUDIO_CHANNELS_NONE
82  */
83  inline uint8_t getAudioChannels() const {
84  return audioChannels;
85  }
86 
87  /**
88  * @return sample rate in hz or AUDIO_SAMPLERATE_NONE
89  */
90  inline uint32_t getAudioSampleRate() const {
91  return audioSampleRate;
92  }
93 
94  /**
95  * @return bits per sample or AUDIO_BITSPERSAMPLES_NONE
96  */
97  inline uint8_t getAudioBitsPerSample() const {
98  return audioBitsPerSample;
99  }
100 
101  /**
102  * @return samples or AUDIO_SAMPLES_NONE
103  */
104  inline int64_t getAudioSamples() {
105  return audioSamples;
106  }
107 
108  /**
109  * Read raw PCM data from stream
110  * @param data byte buffer
111  * @return number of bytes read
112  */
113  virtual int64_t readAudioFromStream(ByteBuffer* data) = 0;
114 
115  /**
116  * @return video frame rate
117  */
118  inline float getVideoFrameRate() const {
119  return videoFrameRate;
120  }
121 
122  /**
123  * @return video duration
124  */
125  inline float getVideoDuration() const {
126  return videoDuration;
127  }
128 
129  /**
130  * @return video width
131  */
132  inline uint16_t getVideoWidth() const {
133  return videoWidth;
134  }
135 
136  /**
137  * @return video height
138  */
139  inline uint16_t getVideoHeight() const {
140  return videoHeight;
141  }
142 
143  /**
144  * Read raw RGB video data from stream
145  * @param data byte buffer
146  * @return number of bytes read
147  */
148  virtual int64_t readVideoFromStream(ByteBuffer* data) = 0;
149 
150  /**
151  * Closes the audio file
152  * @throws tdme::os::filesystem::FileSystemException
153  * @throws tdme::audio::decoder::AudioDecoderException
154  */
155  virtual void close() = 0;
156 
157 };
Byte buffer class.
Definition: ByteBuffer.h:27
Video decoder base class.
Definition: VideoDecoder.h:18
virtual void openFile(const string &pathName, const string &fileName)=0
Open a local file.
static constexpr uint32_t AUDIO_SAMPLERATE_NONE
Definition: VideoDecoder.h:21
virtual void seek(float time)=0
Update.
virtual void reset()=0
Resets this video decoder, if a stream was open it will be rewinded.
static constexpr float VIDEO_FRAMERATE_NONE
Definition: VideoDecoder.h:25
static constexpr float VIDEO_DURATION_NONE
Definition: VideoDecoder.h:26
virtual void update(float deltaTime)=0
Update.
static constexpr uint8_t AUDIO_CHANNELS_NONE
Definition: VideoDecoder.h:20
virtual int64_t readAudioFromStream(ByteBuffer *data)=0
Read raw PCM data from stream.
virtual int64_t readVideoFromStream(ByteBuffer *data)=0
Read raw RGB video data from stream.
static constexpr uint16_t VIDEO_HEIGHT_NONE
Definition: VideoDecoder.h:28
static constexpr uint16_t VIDEO_WIDTH_NONE
Definition: VideoDecoder.h:27
virtual ~VideoDecoder()
Destructor.
Definition: VideoDecoder.h:52
static constexpr uint8_t AUDIO_BITSPERSAMPLES_NONE
Definition: VideoDecoder.h:22
virtual void close()=0
Closes the audio file.
static constexpr uint64_t AUDIO_SAMPLES_NONE
Definition: VideoDecoder.h:23
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6