LibMedia: Move FFmpegIOContext into it's own file

This allows it to be reused for video.
This commit is contained in:
Luke Wilde 2025-03-06 14:30:41 +00:00 committed by Alexander Kalenik
commit 3412935a62
Notes: github-actions[bot] 2025-03-13 18:35:00 +00:00
5 changed files with 117 additions and 84 deletions

View file

@ -9,6 +9,7 @@
#include "Loader.h"
#include <AK/Error.h>
#include <AK/NonnullOwnPtr.h>
#include <LibMedia/FFmpeg/FFmpegIOContext.h>
extern "C" {
#include <libavcodec/avcodec.h>
@ -17,22 +18,9 @@ extern "C" {
namespace Audio {
class FFmpegIOContext {
public:
explicit FFmpegIOContext(AVIOContext*);
~FFmpegIOContext();
static ErrorOr<NonnullOwnPtr<FFmpegIOContext>> create(AK::SeekableStream& stream);
AVIOContext* avio_context() const { return m_avio_context; }
private:
AVIOContext* m_avio_context { nullptr };
};
class FFmpegLoaderPlugin : public LoaderPlugin {
public:
explicit FFmpegLoaderPlugin(NonnullOwnPtr<SeekableStream>, NonnullOwnPtr<FFmpegIOContext>);
explicit FFmpegLoaderPlugin(NonnullOwnPtr<SeekableStream>, NonnullOwnPtr<Media::FFmpeg::FFmpegIOContext>);
virtual ~FFmpegLoaderPlugin();
static bool sniff(SeekableStream& stream);
@ -58,7 +46,7 @@ private:
AVCodecContext* m_codec_context { nullptr };
AVFormatContext* m_format_context { nullptr };
AVFrame* m_frame { nullptr };
NonnullOwnPtr<FFmpegIOContext> m_io_context;
NonnullOwnPtr<Media::FFmpeg::FFmpegIOContext> m_io_context;
int m_loaded_samples { 0 };
AVPacket* m_packet { nullptr };
int m_total_samples { 0 };