galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Video.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_MEDIA_VIDEO_HPP_
9#define GALAXY_MEDIA_VIDEO_HPP_
10
11#include <miniaudio.h>
12#include <pl_mpeg.h>
13
15#include "galaxy/media/RingBuffer.hpp"
16
17namespace galaxy
18{
19 namespace media
20 {
26 class Video final
27 {
28 public:
32 Video();
33
37 ~Video();
38
46 [[nodiscard]]
47 bool load(const std::string& file);
48
52 void build();
53
57 void update();
58
62 void render();
63
69 [[nodiscard]]
70 bool is_finished() const;
71
77 [[nodiscard]]
78 double get_time() const;
79
85 [[nodiscard]]
86 double get_framerate() const;
87
93 [[nodiscard]]
94 int get_samplerate() const;
95
101 [[nodiscard]]
102 double get_duration() const;
103
104 private:
113 unsigned int create_texture(unsigned int index, const char* uniform);
114
122 void update_texture(unsigned int unit, unsigned int texture, const plm_plane_t* plane);
123
124 private:
128 plm_t* m_plm;
129
133 ma_device* m_audio;
134
138 meta::vector<uint8_t> m_buffer;
139
143 std::unique_ptr<RingBuffer> m_audio_buffer;
144
148 unsigned int m_texture_y;
149
153 unsigned int m_texture_cb;
154
158 unsigned int m_texture_cr;
159
163 unsigned int m_vao;
164
168 unsigned int m_vbo;
169
173 unsigned int m_ibo;
174
179 };
180 } // namespace media
181} // namespace galaxy
182
183#endif
OpenGL Shader Program.
Definition Shader.hpp:29
Plays an MPEG-1 video.
Definition Video.hpp:27
void build()
Build opengl data.
Definition Video.cpp:178
void render()
Render video.
Definition Video.cpp:212
Video()
Constructor.
Definition Video.cpp:48
double get_time() const
Get current playtime.
Definition Video.cpp:231
double get_framerate() const
Get video framerate.
Definition Video.cpp:241
~Video()
Destructor.
Definition Video.cpp:61
meta::vector< uint8_t > m_buffer
Video data buffer.
Definition Video.hpp:138
unsigned int m_texture_cb
PLM video frame cb.
Definition Video.hpp:153
std::unique_ptr< RingBuffer > m_audio_buffer
Buffer for audio decoding.
Definition Video.hpp:143
unsigned int m_vao
PLM video frame vertex array object.
Definition Video.hpp:163
ma_device * m_audio
Audio data.
Definition Video.hpp:133
plm_t * m_plm
PLM decoder data.
Definition Video.hpp:128
graphics::Shader m_shader
PLM video shader.
Definition Video.hpp:178
bool is_finished() const
Check if video is finished.
Definition Video.cpp:221
unsigned int m_texture_cr
PLM video frame cr.
Definition Video.hpp:158
double get_duration() const
Get video duration.
Definition Video.cpp:261
void update()
Update video decoder.
Definition Video.cpp:199
unsigned int create_texture(unsigned int index, const char *uniform)
Internal function to generate video frame texture.
Definition Video.cpp:271
bool load(const std::string &file)
Load a MPEG-1 from video file.
Definition Video.cpp:101
unsigned int m_ibo
PLM video frame index buffer.
Definition Video.hpp:173
unsigned int m_vbo
PLM video frame vertex buffer.
Definition Video.hpp:168
unsigned int m_texture_y
PLM video frame y.
Definition Video.hpp:148
void update_texture(unsigned int unit, unsigned int texture, const plm_plane_t *plane)
Internal function to update video frame data.
Definition Video.cpp:292
int get_samplerate() const
Get video sample rate.
Definition Video.cpp:251
Animated.cpp galaxy.
Definition Animated.cpp:16