Implements video and audio playback using FFmpeg. More...
#include <ffmpeg_player.h>
Public Member Functions | |
void | seek (double time_seconds, int stream_index) |
FFmpegPlayer () | |
Constructs an FFmpegPlayer instance. | |
~FFmpegPlayer () override | |
Destroys the FFmpegPlayer instance and cleans up resources. | |
bool | setup (SDL_Renderer *renderer, const std::string &path, int width, int height) override |
Sets up the player with renderer and media file. | |
void | play () override |
Starts playback of the media file. | |
void | stop () override |
Stops playback of the media file. | |
void | update () override |
Updates the playback state. | |
SDL_Texture * | getTexture () const override |
Retrieves the current video texture. | |
bool | isPlaying () const override |
Checks if the player is currently playing. | |
void | setVolume (float volume) override |
Sets the audio volume. | |
void | setMute (bool mute) override |
Toggles audio mute state. | |
void | seekToBeginning (int streamIndex) |
Seeks to the beginning of the specified stream. | |
AVFormatContext * | getFormatContext () const |
Gets the format context. | |
![]() | |
virtual | ~IVideoPlayer ()=default |
Destructor. | |
Implements video and audio playback using FFmpeg.
This class extends IVideoPlayer to handle media file playback with FFmpeg, managing format context, video, and audio decoding. It provides methods for setup, playback control, and volume management, with cleanup handled via RAII.
FFmpegPlayer::FFmpegPlayer | ( | ) |
Constructs an FFmpegPlayer instance.
Initializes with null pointers for decoders and format context.
|
override |
Destroys the FFmpegPlayer instance and cleans up resources.
Ensures all allocated resources, including decoders and format context, are freed.
|
inline |
Gets the format context.
Provides access to the AVFormatContext for decoder use.
|
overridevirtual |
Retrieves the current video texture.
Implements IVideoPlayer.
|
overridevirtual |
Checks if the player is currently playing.
Implements IVideoPlayer.
|
overridevirtual |
Starts playback of the media file.
Initiates video and audio playback if not already playing.
Implements IVideoPlayer.
void FFmpegPlayer::seekToBeginning | ( | int | streamIndex | ) |
Seeks to the beginning of the specified stream.
Used by decoders to reset playback position.
streamIndex | Index of the stream to seek (-1 for all audio/video streams). |
|
overridevirtual |
Toggles audio mute state.
mute | True to mute, false to unmute. |
Implements IVideoPlayer.
|
overridevirtual |
Sets up the player with renderer and media file.
Configures the player with the specified renderer, file path, and resolution.
renderer | Pointer to the SDL_Renderer for texture rendering. |
path | Path to the media file. |
width | Desired width of the video output. |
height | Desired height of the video output. |
Implements IVideoPlayer.
|
overridevirtual |
Sets the audio volume.
volume | Volume level (0.0 to 1.0). |
Implements IVideoPlayer.
|
overridevirtual |
Stops playback of the media file.
Halts video and audio playback and resets stream positions if applicable.
Implements IVideoPlayer.
|
overridevirtual |
Updates the playback state.
Calls update on video and audio decoders to process the next frame or audio sample.
Implements IVideoPlayer.