create own namespace for ffmpeg components
This commit is contained in:
@@ -85,7 +85,7 @@ void AudioEngine::initEq() {
|
||||
void AudioEngine::playbackLoop() {
|
||||
m_state = State::Playing;
|
||||
|
||||
engine::FFmpegDecoder decoder;
|
||||
engine::ffmpeg::FFmpegDecoder decoder;
|
||||
if (!decoder.open(m_track.filePath)) {
|
||||
qWarning() << "[AudioEngine] Cannot open:" << m_track.filePath;
|
||||
m_state = State::Stopped;
|
||||
|
||||
@@ -5,7 +5,7 @@ extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
void CodecContext::Deleter::operator()(AVCodecContext *p) const {
|
||||
avcodec_free_context(&p);
|
||||
@@ -64,4 +64,4 @@ int CodecContext::channels() const {
|
||||
return m_ctx ? m_ctx->ch_layout.nb_channels : 0;
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -6,7 +6,7 @@ struct AVCodecParameters;
|
||||
struct AVPacket;
|
||||
struct AVFrame;
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
class CodecContext {
|
||||
public:
|
||||
@@ -35,4 +35,4 @@ private:
|
||||
std::unique_ptr<AVCodecContext, Deleter> m_ctx;
|
||||
};
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
}
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
FFmpegDecoder::FFmpegDecoder() = default;
|
||||
|
||||
@@ -103,4 +103,4 @@ bool FFmpegDecoder::drainCodec(AudioBuffer &buf) const {
|
||||
return gotSamples;
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
#include "CodecContext.h"
|
||||
#include "Resampler.h"
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
// Thin orchestrator: ties FormatContext, CodecContext, and Resampler together
|
||||
// to expose a simple open / seek / decodeNext interface.
|
||||
class FFmpegDecoder {
|
||||
public:
|
||||
FFmpegDecoder();
|
||||
@@ -34,8 +32,7 @@ private:
|
||||
|
||||
qint64 m_totalFrames { 0 };
|
||||
|
||||
// Drains all frames currently buffered in the codec into buf.
|
||||
bool drainCodec(AudioBuffer &buf) const;
|
||||
};
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -7,7 +7,7 @@ extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
}
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
void FormatContext::Deleter::operator()(AVFormatContext *p) const {
|
||||
avformat_close_input(&p);
|
||||
@@ -91,4 +91,4 @@ qint64 FormatContext::audioStreamDuration() const {
|
||||
return m_fmt->streams[m_audioIdx]->duration;
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
|
||||
struct AVPacket;
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
class FormatContext {
|
||||
public:
|
||||
@@ -39,4 +39,4 @@ private:
|
||||
int m_audioIdx { -1 };
|
||||
};
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -7,7 +7,7 @@ extern "C" {
|
||||
#include <libavutil/channel_layout.h>
|
||||
}
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
void Resampler::Deleter::operator()(SwrContext *p) const {
|
||||
swr_free(&p);
|
||||
@@ -65,4 +65,4 @@ int Resampler::convert(const AVFrame *frame, std::vector<float> &out) const {
|
||||
return converted;
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
@@ -6,7 +6,7 @@ struct SwrContext;
|
||||
struct AVCodecContext;
|
||||
struct AVFrame;
|
||||
|
||||
namespace engine {
|
||||
namespace engine::ffmpeg {
|
||||
|
||||
class Resampler {
|
||||
public:
|
||||
@@ -29,4 +29,4 @@ private:
|
||||
int m_sampleRate { 0 };
|
||||
};
|
||||
|
||||
} // namespace engine
|
||||
} // namespace engine::ffmpeg
|
||||
|
||||
Reference in New Issue
Block a user