6#include <libavutil/buffer.h>
7#include <libavutil/pixfmt.h>
15struct AVFormatContext;
69 bool setup(AVFormatContext* formatContext, SDL_Renderer* renderer,
int width,
int height);
129 void applyPendingTextureUpdate();
130 void queueFrameForTextureUpdate();
135 AVCodecContext* videoCodecContext_;
136 SDL_Renderer* renderer_;
139 AVFrame* videoFrame_;
141 AVPacket* videoPacket_;
142 SwsContext* swsContext_;
143 int videoStreamIndex_;
145 SDL_Texture* texture_;
147 std::chrono::high_resolution_clock::time_point lastFrameTime_;
148 std::chrono::high_resolution_clock::time_point playbackStartTime_;
150 AVBufferRef* hwDeviceCtx_ =
nullptr;
151 AVPixelFormat expectedSwFormat_ = AV_PIX_FMT_NONE;
153 std::mutex pendingMutex_;
154 std::vector<uint8_t> pendingBuffer_;
155 std::atomic_bool hasPendingFrame_{
false};
156 int pendingPitch_{0};
Implements video and audio playback using FFmpeg.
Definition ffmpeg_player.h:30
Decodes and renders video frames using FFmpeg and SDL.
Definition video_decoder.h:40
void resetPlaybackTimes()
Resets playback timing variables.
Definition video_decoder.cpp:517
void stop()
Stops video playback.
Definition video_decoder.cpp:223
void updateTexture()
Updates the SDL texture with the current RGB frame data.
Definition video_decoder.cpp:480
void play()
Starts video playback.
Definition video_decoder.cpp:218
SDL_Texture * getTexture() const
Retrieves the current video texture.
Definition video_decoder.cpp:266
void flush()
Flushes the decoder buffers.
Definition video_decoder.cpp:510
~VideoDecoder()
Destroys the VideoDecoder instance and cleans up resources.
Definition video_decoder.cpp:27
void update()
Updates the video frame based on playback timing.
Definition video_decoder.cpp:228
bool decodeVideoFrame()
Decodes the next video frame.
Definition video_decoder.cpp:320
bool setup(AVFormatContext *formatContext, SDL_Renderer *renderer, int width, int height)
Sets up the video decoder with format context and renderer.
Definition video_decoder.cpp:32