mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 00:51:48 +08:00
refactor: 大规模调整项目目录结构,将ChatClient和ChatServer整合为Monorepo结构,并分为两个独立文件夹:chatclient/ 和 chatserver/。更新了ChatClient的CMakeLists.txt配置以适配新结构。
This commit is contained in:
59
ChatClient/include/soundrecorder.h
Normal file
59
ChatClient/include/soundrecorder.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef SOUNDRECORDER_H
|
||||
#define SOUNDRECORDER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStandardPaths>
|
||||
#include <QFile>
|
||||
#include <QAudioSource>
|
||||
#include <QAudioSink>
|
||||
#include <QMediaDevices>
|
||||
|
||||
class SoundRecorder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
const QString RECORD_PATH = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sound/tmpRecord.pcm";
|
||||
const QString PLAY_PATH = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/sound/tmpPlay.pcm";
|
||||
|
||||
public:
|
||||
static SoundRecorder* getInstance();
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
/// 录制语音语音
|
||||
/////////////////////////////////////////////////
|
||||
// 开始录制
|
||||
void startRecord();
|
||||
// 停止录制
|
||||
void stopRecord();
|
||||
|
||||
private:
|
||||
static SoundRecorder* instance;
|
||||
explicit SoundRecorder(QObject *parent = nullptr);
|
||||
|
||||
QFile soundFile;
|
||||
QAudioSource* audioSource;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
/// 播放语音
|
||||
/////////////////////////////////////////////////
|
||||
public:
|
||||
// 开始播放
|
||||
void startPlay(const QByteArray& content);
|
||||
// 停止播放
|
||||
void stopPlay();
|
||||
|
||||
private:
|
||||
QAudioSink *audioSink;
|
||||
QMediaDevices *outputDevices;
|
||||
QAudioDevice outputDevice;
|
||||
QFile inputFile;
|
||||
|
||||
signals:
|
||||
// 录制完毕后发送这个信号
|
||||
void soundRecordDone(const QString& path);
|
||||
// 播放完毕发送这个信号
|
||||
void soundPlayDone();
|
||||
|
||||
};
|
||||
|
||||
#endif // SOUNDRECORDER_H
|
||||
Reference in New Issue
Block a user