HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
FFmpegAudioDecoder.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "FFmpegAudioShared.h"
4#include "IAudioDecoder.h"
6
9namespace HephAudio
10{
16 {
17 private:
18 static constexpr size_t AUDIO_STREAM_INDEX_NOT_FOUND = -1;
19
20 private:
21 size_t fileDuration_frame;
22 size_t audioStreamIndex;
23 int64_t firstPacketPts;
24 AVFormatContext* avFormatContext;
25 AVCodecContext* avCodecContext;
26 SwrContext* swrContext;
27 AVFrame* avFrame;
28 AVPacket* avPacket;
29
30 public:
33
39 FFmpegAudioDecoder(const std::filesystem::path& filePath);
40
43
45
48
49 FFmpegAudioDecoder& operator=(const FFmpegAudioDecoder&) = delete;
50 FFmpegAudioDecoder& operator=(FFmpegAudioDecoder&& rhs) noexcept;
51 void ChangeFile(const std::filesystem::path& newFilePath) override;
52 void CloseFile() override;
53 bool IsFileOpen() const override;
55 size_t GetFrameCount() const override;
56 bool Seek(size_t frameIndex) override;
57 AudioBuffer Decode() override;
58 AudioBuffer Decode(size_t frameCount) override;
59 AudioBuffer Decode(size_t frameIndex, size_t frameCount) override;
60 AudioBuffer Decode(const EncodedAudioBuffer& encodedBuffer) override;
61
62 private:
63 void OpenFile(const std::filesystem::path& filePath);
64 int SeekFrame(size_t& frameIndex);
65 };
66}
#define HEPH_API
Definition HephShared.h:132
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
stores encoded audio data.
Definition EncodedAudioBuffer.h:15
implements audio decoding via FFmpeg.
Definition FFmpegAudioDecoder.h:16
size_t GetFrameCount() const override
AudioBuffer Decode(size_t frameIndex, size_t frameCount) override
bool IsFileOpen() const override
FFmpegAudioDecoder(FFmpegAudioDecoder &&rhs) noexcept
AudioFormatInfo GetOutputFormatInfo() const override
AudioBuffer Decode(size_t frameCount) override
AudioBuffer Decode(const EncodedAudioBuffer &encodedBuffer) override
void ChangeFile(const std::filesystem::path &newFilePath) override
FFmpegAudioDecoder(const std::filesystem::path &filePath)
AudioBuffer Decode() override
bool Seek(size_t frameIndex) override
interface for the audio decoders.
Definition IAudioDecoder.h:16
stores the properties of the audio signals
Definition AudioFormatInfo.h:20