ASAPCabinetFE
 
Loading...
Searching...
No Matches
vlc_player.h
1#ifndef VLC_PLAYER_H
2#define VLC_PLAYER_H
3
4#include "render/ivideo_player.h"
5#include <SDL2/SDL.h>
6#include <vlc/vlc.h>
7#include <string>
8
17public:
22
26 ~VlcVideoPlayer() override;
27
36 bool setup(SDL_Renderer* renderer, const std::string& path, int width, int height) override;
37
41 void play() override;
42
46 void stop() override;
47
51 void update() override;
52
57 SDL_Texture* getTexture() const override;
58
63 bool isPlaying() const override;
64
69 void setVolume(float volume) override;
70
75 void setMute(bool mute) override;
76
77private:
81 struct VideoContext {
82 libvlc_instance_t* instance;
83 libvlc_media_player_t* player;
84 SDL_Renderer* renderer;
85 SDL_Texture* texture;
86 void* pixels;
87 int pitch;
88 int width;
89 int height;
90 SDL_mutex* mutex;
91 bool isPlaying;
92 bool frameReady; // New: Flag to indicate if a new frame is ready for texture update
93 };
94
95 VideoContext* ctx_;
96
103 static void* lock(void* data, void** pixels);
104
111 static void unlock(void* data, void* id, void* const* pixels);
112
118 static void display(void* data, void* id);
119
123 void cleanupContext();
124};
125
126#endif // VLC_PLAYER_H
Interface for a video player.
Definition ivideo_player.h:19
Concrete implementation of IVideoPlayer using VLC (libVLC).
Definition vlc_player.h:16
VlcVideoPlayer()
Constructs a VlcVideoPlayer instance.
Definition vlc_player.cpp:11
void stop() override
Stops video playback.
Definition vlc_player.cpp:189
SDL_Texture * getTexture() const override
Retrieves the current video frame as an SDL_Texture.
Definition vlc_player.cpp:230
void setMute(bool mute) override
Sets the mute state for the video's audio track.
Definition vlc_player.cpp:253
void play() override
Starts video playback.
Definition vlc_player.cpp:175
bool isPlaying() const override
Checks if the video is currently playing.
Definition vlc_player.cpp:234
void setVolume(float volume) override
Sets the volume for the video's audio track.
Definition vlc_player.cpp:242
bool setup(SDL_Renderer *renderer, const std::string &path, int width, int height) override
Sets up the VLC video player with the given renderer, path, and dimensions.
Definition vlc_player.cpp:80
~VlcVideoPlayer() override
Destroys the VlcVideoPlayer instance and cleans up VLC resources.
Definition vlc_player.cpp:13
void update() override
Updates the video frame and texture.
Definition vlc_player.cpp:200