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
FFmpegAudioEncoder.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "FFmpegAudioShared.h"
4#include "IAudioEncoder.h"
5#include "AudioBuffer.h"
7#include <string>
8
11namespace HephAudio
12{
18 {
19 private:
20 AudioFormatInfo outputFormatInfo;
21 AVFormatContext* avFormatContext;
22 AVIOContext* avIoContext;
23 AVStream* avStream;
24 AVCodecContext* avCodecContext;
25 SwrContext* swrContext;
26 AVFrame* avFrame;
27 AVPacket* avPacket;
28
29 public:
32
40 FFmpegAudioEncoder(const std::filesystem::path& filePath, const AudioFormatInfo& outputFormatInfo, bool overwrite);
41
44
46
49
50 FFmpegAudioEncoder& operator=(const FFmpegAudioEncoder&) = delete;
51 FFmpegAudioEncoder& operator=(FFmpegAudioEncoder&& rhs) noexcept;
52 void ChangeFile(const std::filesystem::path& newAudioFilePath, const AudioFormatInfo& outputFormatInfo, bool overwrite) override;
53 void CloseFile() override;
54 bool IsFileOpen() const override;
55 void Encode(const AudioBuffer& bufferToEncode) override;
56 void Encode(const AudioBuffer& inputBuffer, EncodedAudioBuffer& outputBuffer) override;
57 void Transcode(const EncodedAudioBuffer& inputBuffer, EncodedAudioBuffer& outputBuffer) override;
58 static void Transcode(const std::filesystem::path& inputFilePath, const std::filesystem::path& outputFilePath, bool overwrite);
59 static void Transcode(const std::filesystem::path& inputFilePath, const std::filesystem::path& outputFilePath, AudioFormatInfo outputFormatInfo, bool overwrite);
60
61 private:
62 void OpenFile(const std::filesystem::path& filePath, const AudioFormatInfo& outputFormatInfo, bool overwrite);
63 static void Transcode(void* pDecoder, FFmpegAudioEncoder& encoder);
64 };
65}
#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 encoding via FFmpeg.
Definition FFmpegAudioEncoder.h:18
FFmpegAudioEncoder(FFmpegAudioEncoder &&rhs) noexcept
void Encode(const AudioBuffer &inputBuffer, EncodedAudioBuffer &outputBuffer) override
void ChangeFile(const std::filesystem::path &newAudioFilePath, const AudioFormatInfo &outputFormatInfo, bool overwrite) override
void Transcode(const EncodedAudioBuffer &inputBuffer, EncodedAudioBuffer &outputBuffer) override
void Encode(const AudioBuffer &bufferToEncode) override
bool IsFileOpen() const override
FFmpegAudioEncoder(const std::filesystem::path &filePath, const AudioFormatInfo &outputFormatInfo, bool overwrite)
interface for the audio encoders.
Definition IAudioEncoder.h:16
stores the properties of the audio signals
Definition AudioFormatInfo.h:20