FaceAccess/Record/main.h

60 lines
1.2 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-04 17:57:23 +08:00
class Task {
public:
virtual void run() = 0;
};
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;
};
class EchoRecordTask : public Task {
public:
void setVqeEnabled(bool enabled);
void setChannels(int channels);
void run() final;
private:
int m_channels = 2;
bool m_vqeEnabled = false;
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-04 17:57:23 +08:00
};
#endif // __MAIN_H__