#ifndef RECORDER_H
#define RECORDER_H

#include <QtMultimedia/QAudioFormat>
#include <QtMultimedia/QAudioInput>

#include <QObject>
#include <QAudioRecorder>//录音
#include <QAudioEncoderSettings>//音频编码器
#include <QAudioBuffer>//音频缓存
#include <QAudioProbe> //音频探针
#include <QUdpSocket> //UDP套接字
#include <QHostAddress> //主机地址
#include <QUrl> //文件地址
#include <QAudioEncoderSettings>
#include <QFile>
#include <QBuffer>

#include <kylin-ai/ai-base/speech.h>
#include "msgpane.h"
#include "channelmessage.h"


#define TEST 1

class Recorder : public QObject
{
    Q_OBJECT
public:
    explicit Recorder(QObject *parent = nullptr);
    ~Recorder();
    void startRecord();
    void stopRecord();
    void sendAudio(const void *audio_data, unsigned int audio_data_length);

signals:
    void sigSendMsg(const QString msgHead, const QString str);

public slots:
    void onReadInfo();
    void handleStateChanged(QAudio::State state);
private:
    QBuffer m_audioBuffer;
    QAudioInput *m_audioInput = nullptr;  // 录音对象
    QAudioFormat m_audioFormat;
    void *session = nullptr;


    bool initSession();
    void closeSession();


};

#endif // RECORDER_H
