FaceAccess/Record/main.h

78 lines
1.5 KiB
C
Raw Normal View History

2024-09-04 17:57:23 +08:00
#ifndef __MAIN_H__
#define __MAIN_H__
#include "RkAudio.h"
#include <fstream>
#include <memory>
2024-09-04 20:17:15 +08:00
class SpeexDsp;
2024-09-05 12:24:05 +08:00
class WebRtcAecm;
2024-09-06 09:45:44 +08:00
enum Dsp {
Vqe,
Speex,
AecMobile,
Aec3,
};
2024-09-04 17:57:23 +08:00
class Task {
public:
virtual void run() = 0;
2024-09-06 09:45:44 +08:00
virtual ~Task() {
}
2024-09-04 17:57:23 +08:00
};
class RecorderTask : public Task {
public:
void run() final;
private:
std::shared_ptr<RkAudio::Input> m_input;
std::shared_ptr<std::ofstream> m_ofs;
};
class PlayerTask : public Task {
public:
2024-09-04 20:17:15 +08:00
void setChannels(int channels);
2024-09-04 17:57:23 +08:00
void setPath(const std::string &path);
void run() final;
protected:
void play();
private:
2024-09-04 20:17:15 +08:00
int m_channels = 2;
2024-09-04 17:57:23 +08:00
std::string m_path;
2024-09-04 20:17:15 +08:00
std::vector<char> m_buffer;
2024-09-04 17:57:23 +08:00
std::shared_ptr<std::ifstream> m_ifs;
std::shared_ptr<RkAudio::Output> m_output;
};
2024-09-06 09:45:44 +08:00
class EchoRecordPrivate;
2024-09-04 17:57:23 +08:00
class EchoRecordTask : public Task {
public:
2024-09-06 09:45:44 +08:00
EchoRecordTask();
~EchoRecordTask();
void setDsp(Dsp dsp);
2024-09-04 17:57:23 +08:00
void setChannels(int channels);
void run() final;
private:
int m_channels = 2;
2024-09-06 09:45:44 +08:00
Dsp m_dsp = Vqe;
2024-09-04 17:57:23 +08:00
std::shared_ptr<RkAudio::Output> m_output;
std::shared_ptr<RkAudio::Input> m_input;
2024-09-04 20:17:15 +08:00
std::shared_ptr<SpeexDsp> m_speex;
2024-09-05 12:24:05 +08:00
std::shared_ptr<WebRtcAecm> m_webRtcAecm;
std::vector<uint8_t> m_outBuffer;
std::vector<uint8_t> m_nearendBuffer;
std::vector<uint8_t> m_farendBuffer;
2024-09-06 09:45:44 +08:00
EchoRecordPrivate *m_d = nullptr;
2024-09-04 17:57:23 +08:00
};
2024-09-06 09:45:44 +08:00
Dsp dspFromString(const std::string &dsp);
std::string dspToString(Dsp dsp);
2024-09-04 17:57:23 +08:00
#endif // __MAIN_H__