代码拉取完成,页面将自动刷新
#include <QTimer>
#include <QThread>
#include <QDebug>
#include "common/LoopBuffer.h"
#include "AudioDataDispatcher.h"
#ifdef WIN32
#include "render/WinAudioRender.h"
#include "capture/win/WinMediaDevice.h"
#include "capture/win/WinSpeakerRecord.h"
#include "capture/win/WinMicRecord.h"
#else
#include "capture/mac/MacMicRecord.h"
#include "capture/mac/MacMediaDevice.h"
#include "capture/mac/MacMicRecord.h"
#endif
#include "RecordManager.h"
RecordManager::RecordManager(QObject *parent) : QObject(parent)
{
qDebug() << QThread::currentThread();
#ifdef WIN32
/* 此deviceid要求和spk一致 */
QThread *renderThread = new QThread;
WinAudioRender *render = new WinAudioRender(0);
render->moveToThread(renderThread);
renderThread->start();
QTimer *renderTimer = new QTimer;
renderTimer->setSingleShot(true);
connect(renderTimer,&QTimer::timeout,render,&WinAudioRender::run);
renderTimer->start();
QThread * speakerThread = new QThread;
WinSpeakerRecord *speakerThreadObj = new WinSpeakerRecord;
speakerThreadObj->moveToThread(speakerThread);
speakerThread->start();
QTimer *speakerTimer = new QTimer;
speakerTimer->setSingleShot(true);
QObject::connect(speakerTimer,&QTimer::timeout,speakerThreadObj,&WinSpeakerRecord::run);
QThread * micThread = new QThread;
WinMicRecord *micThreadObj = new WinMicRecord;
micThreadObj->moveToThread(micThread);
micThread->start();
QTimer *micTimer = new QTimer;
micTimer->setSingleShot(true);
QObject::connect(micTimer,&QTimer::timeout,micThreadObj,&WinMicRecord::run);
QThread *audioThread = new QThread;
AudioDataDispatcher *audioThreadObj = new AudioDataDispatcher;
audioThreadObj->moveToThread(audioThread);
audioThread->start();
QTimer *mp3Timer = new QTimer;
mp3Timer->setSingleShot(true);
QObject::connect(mp3Timer,&QTimer::timeout,audioThreadObj,&AudioDataDispatcher::run);
QObject::connect(micThreadObj,&WinMicRecord::audioData,audioThreadObj,&AudioDataDispatcher::acceptMicData);
QObject::connect(speakerThreadObj,&WinSpeakerRecord::audioData,audioThreadObj,&AudioDataDispatcher::acceptSpeakerData);
qDebug() << "main thread" << QThread::currentThreadId();
speakerTimer->start(0);
mp3Timer->start(0);
micTimer->start(0);
qDebug() << WinMediaDevice::getDeviceList(WinMediaDevice::MediaDeviceType_Input);
qDebug() << WinMediaDevice::getDeviceList(WinMediaDevice::MediaDeviceType_Output);
#else
qDebug() << MacMediaDevice::getDeviceList(MacMediaDevice::MediaDeviceType_Input);
qDebug() << MacMediaDevice::getDeviceList(MacMediaDevice::MediaDeviceType_Output);
QThread *micThread = new QThread;
MacAudio *record = new MacAudio;
record->setDeviceId("51");
record->moveToThread(micThread);
micThread->start();
QThread *audioThread = new QThread;
AudioDataDispatcher *audioThreadObj = new AudioDataDispatcher;
audioThreadObj->moveToThread(audioThread);
audioThread->start();
QTimer *micTimer = new QTimer;
micTimer->setSingleShot(true);
connect(micTimer,&QTimer::timeout,record,&MacAudio::run);
micTimer->start(0);
QTimer *mp3Timer = new QTimer;
mp3Timer->setSingleShot(true);
QObject::connect(mp3Timer,&QTimer::timeout,audioThreadObj,&AudioDataDispatcher::run);
connect(record,&MacAudio::GotAVFrame,audioThreadObj,&AudioDataDispatcher::acceptMacMicData);
mp3Timer->start();
#endif
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。