ASAPCabinetFE
 
Loading...
Searching...
No Matches
ffmpeg_player.h
Go to the documentation of this file.
1#ifndef FFMPEG_PLAYER_H
2#define FFMPEG_PLAYER_H
3
4#include "render/ivideo_player.h"
5#include <SDL2/SDL.h>
6#include <string>
7
8// Forward declarations
9struct AVFormatContext;
10class VideoDecoder;
11class AudioDecoder;
12
30class FFmpegPlayer : public IVideoPlayer {
31public:
32 void seek(double time_seconds, int stream_index);
33
40
46 ~FFmpegPlayer() override;
47
59 bool setup(SDL_Renderer* renderer, const std::string& path, int width, int height) override;
60
66 void play() override;
67
73 void stop() override;
74
80 void update() override;
81
87 SDL_Texture* getTexture() const override;
88
94 bool isPlaying() const override;
95
101 void setVolume(float volume) override;
102
108 void setMute(bool mute) override;
109
117 void seekToBeginning(int streamIndex);
118
126 AVFormatContext* getFormatContext() const { return formatContext_; }
127
128private:
129 SDL_Renderer* renderer_;
130 std::string path_;
131 int width_;
132 int height_;
133 bool isPlaying_;
134 AVFormatContext* formatContext_;
135 VideoDecoder* videoDecoder_;
136 AudioDecoder* audioDecoder_;
137
143 void cleanup();
144};
145
146#endif // FFMPEG_PLAYER_H
Decodes and plays audio streams using FFmpeg and SDL.
Definition audio_decoder.h:34
Implements video and audio playback using FFmpeg.
Definition ffmpeg_player.h:30
void seekToBeginning(int streamIndex)
Seeks to the beginning of the specified stream.
Definition ffmpeg_player.cpp:127
SDL_Texture * getTexture() const override
Retrieves the current video texture.
Definition ffmpeg_player.cpp:109
void setVolume(float volume) override
Sets the audio volume.
Definition ffmpeg_player.cpp:117
bool setup(SDL_Renderer *renderer, const std::string &path, int width, int height) override
Sets up the player with renderer and media file.
Definition ffmpeg_player.cpp:24
void update() override
Updates the playback state.
Definition ffmpeg_player.cpp:103
void play() override
Starts playback of the media file.
Definition ffmpeg_player.cpp:76
bool isPlaying() const override
Checks if the player is currently playing.
Definition ffmpeg_player.cpp:113
AVFormatContext * getFormatContext() const
Gets the format context.
Definition ffmpeg_player.h:126
void stop() override
Stops playback of the media file.
Definition ffmpeg_player.cpp:84
~FFmpegPlayer() override
Destroys the FFmpegPlayer instance and cleans up resources.
Definition ffmpeg_player.cpp:18
void setMute(bool mute) override
Toggles audio mute state.
Definition ffmpeg_player.cpp:122
FFmpegPlayer()
Constructs an FFmpegPlayer instance.
Definition ffmpeg_player.cpp:14
Interface for a video player.
Definition ivideo_player.h:19
Decodes and renders video frames using FFmpeg and SDL.
Definition video_decoder.h:38