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