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

Decodes and renders video frames using FFmpeg and SDL. More...

#include <video_decoder.h>

+ Collaboration diagram for VideoDecoder:

Public Member Functions

 VideoDecoder (FFmpegPlayer *player)
 Constructs a VideoDecoder instance.
 
 ~VideoDecoder ()
 Destroys the VideoDecoder instance and cleans up resources.
 
bool setup (AVFormatContext *formatContext, SDL_Renderer *renderer, int width, int height)
 Sets up the video decoder with format context and renderer.
 
void play ()
 Starts video playback.
 
void stop ()
 Stops video playback.
 
void update ()
 Updates the video frame based on playback timing.
 
SDL_Texture * getTexture () const
 Retrieves the current video texture.
 
bool decodeVideoFrame ()
 Decodes the next video frame.
 
void updateTexture ()
 Updates the SDL texture with the current RGB frame data.
 
void flush ()
 Flushes the decoder buffers.
 
void resetPlaybackTimes ()
 Resets playback timing variables.
 

Friends

class FFmpegPlayer
 

Detailed Description

Decodes and renders video frames using FFmpeg and SDL.

This class manages the decoding of video streams from an AVFormatContext, converts frames to RGB format using SwsContext, and updates an SDL texture for rendering. It works in conjunction with FFmpegPlayer and handles playback timing and cleanup.

Constructor & Destructor Documentation

◆ VideoDecoder()

VideoDecoder::VideoDecoder ( FFmpegPlayer player)

Constructs a VideoDecoder instance.

Initializes the decoder with a reference to the parent FFmpegPlayer.

Parameters
playerPointer to the FFmpegPlayer instance.

◆ ~VideoDecoder()

VideoDecoder::~VideoDecoder ( )

Destroys the VideoDecoder instance and cleans up resources.

Ensures all allocated FFmpeg and SDL resources are properly freed.

Member Function Documentation

◆ decodeVideoFrame()

bool VideoDecoder::decodeVideoFrame ( )

Decodes the next video frame.

Attempts to read and decode a video packet into a frame.

Returns
True if a valid frame was decoded, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush()

void VideoDecoder::flush ( )

Flushes the decoder buffers.

Clears any pending frames in the codec context.

+ Here is the caller graph for this function:

◆ getTexture()

SDL_Texture * VideoDecoder::getTexture ( ) const

Retrieves the current video texture.

Returns
Pointer to the SDL_Texture, or nullptr if not initialized.
+ Here is the caller graph for this function:

◆ play()

void VideoDecoder::play ( )

Starts video playback.

Resets playback timing to synchronize with the video stream.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetPlaybackTimes()

void VideoDecoder::resetPlaybackTimes ( )

Resets playback timing variables.

Sets the video clock and timestamps to initial states.

+ Here is the caller graph for this function:

◆ setup()

bool VideoDecoder::setup ( AVFormatContext *  formatContext,
SDL_Renderer *  renderer,
int  width,
int  height 
)

Sets up the video decoder with format context and renderer.

Configures the decoder with the video stream, codec, and rendering parameters.

Parameters
formatContextPointer to the AVFormatContext containing the video stream.
rendererPointer to the SDL_Renderer for texture creation.
widthDesired width of the output texture.
heightDesired height of the output texture.
Returns
True on successful setup, false otherwise.
+ Here is the caller graph for this function:

◆ stop()

void VideoDecoder::stop ( )

Stops video playback.

Flushes the decoder buffers to prepare for a new playback session.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void VideoDecoder::update ( )

Updates the video frame based on playback timing.

Decodes and renders the next frame if the video clock aligns with elapsed time.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTexture()

void VideoDecoder::updateTexture ( )

Updates the SDL texture with the current RGB frame data.

Copies the decoded frame data to the texture for rendering.

+ Here is the caller graph for this function:

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