ASAPCabinetFE
 
Loading...
Searching...
No Matches
FFmpegPlayer Class Reference

Implements video and audio playback using FFmpeg. More...

#include <ffmpeg_player.h>

+ Inheritance diagram for FFmpegPlayer:
+ Collaboration diagram for FFmpegPlayer:

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.
 
- Public Member Functions inherited from IVideoPlayer
virtual ~IVideoPlayer ()=default
 Destructor.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FFmpegPlayer()

FFmpegPlayer::FFmpegPlayer ( )

Constructs an FFmpegPlayer instance.

Initializes with null pointers for decoders and format context.

◆ ~FFmpegPlayer()

FFmpegPlayer::~FFmpegPlayer ( )
override

Destroys the FFmpegPlayer instance and cleans up resources.

Ensures all allocated resources, including decoders and format context, are freed.

Member Function Documentation

◆ getFormatContext()

AVFormatContext * FFmpegPlayer::getFormatContext ( ) const
inline

Gets the format context.

Provides access to the AVFormatContext for decoder use.

Returns
Pointer to the AVFormatContext.
+ Here is the caller graph for this function:

◆ getTexture()

SDL_Texture * FFmpegPlayer::getTexture ( ) const
overridevirtual

Retrieves the current video texture.

Returns
Pointer to the SDL_Texture, or nullptr if not initialized.

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ isPlaying()

bool FFmpegPlayer::isPlaying ( ) const
overridevirtual

Checks if the player is currently playing.

Returns
True if playing, false otherwise.

Implements IVideoPlayer.

+ Here is the caller graph for this function:

◆ play()

void FFmpegPlayer::play ( )
overridevirtual

Starts playback of the media file.

Initiates video and audio playback if not already playing.

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ seekToBeginning()

void FFmpegPlayer::seekToBeginning ( int  streamIndex)

Seeks to the beginning of the specified stream.

Used by decoders to reset playback position.

Parameters
streamIndexIndex of the stream to seek (-1 for all audio/video streams).
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMute()

void FFmpegPlayer::setMute ( bool  mute)
overridevirtual

Toggles audio mute state.

Parameters
muteTrue to mute, false to unmute.

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ setup()

bool FFmpegPlayer::setup ( SDL_Renderer *  renderer,
const std::string &  path,
int  width,
int  height 
)
overridevirtual

Sets up the player with renderer and media file.

Configures the player with the specified renderer, file path, and resolution.

Parameters
rendererPointer to the SDL_Renderer for texture rendering.
pathPath to the media file.
widthDesired width of the video output.
heightDesired height of the video output.
Returns
True on successful setup, false otherwise.

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ setVolume()

void FFmpegPlayer::setVolume ( float  volume)
overridevirtual

Sets the audio volume.

Parameters
volumeVolume level (0.0 to 1.0).

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ stop()

void FFmpegPlayer::stop ( )
overridevirtual

Stops playback of the media file.

Halts video and audio playback and resets stream positions if applicable.

Implements IVideoPlayer.

+ Here is the call graph for this function:

◆ update()

void FFmpegPlayer::update ( )
overridevirtual

Updates the playback state.

Calls update on video and audio decoders to process the next frame or audio sample.

Implements IVideoPlayer.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: