|
@@ -18,8 +18,6 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
|
|
|
|
|
m_glWidget = new OpenGLVideoWidget(this);
|
|
m_glWidget = new OpenGLVideoWidget(this);
|
|
|
|
|
|
|
|
- WgcCapturer::Init();
|
|
|
|
|
-
|
|
|
|
|
auto layout = new QVBoxLayout;
|
|
auto layout = new QVBoxLayout;
|
|
|
auto hLayout = new QHBoxLayout;
|
|
auto hLayout = new QHBoxLayout;
|
|
|
|
|
|
|
@@ -28,7 +26,6 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
hLayout->addLayout(initOtherUi(), 1);
|
|
hLayout->addLayout(initOtherUi(), 1);
|
|
|
|
|
|
|
|
initStatusBarUi();
|
|
initStatusBarUi();
|
|
|
- updateCaptureList();
|
|
|
|
|
|
|
|
|
|
initConnect();
|
|
initConnect();
|
|
|
|
|
|
|
@@ -36,6 +33,9 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
layout->addLayout(hLayout, 1);
|
|
layout->addLayout(hLayout, 1);
|
|
|
layout->addWidget(m_statusBar, 0);
|
|
layout->addWidget(m_statusBar, 0);
|
|
|
setLayout(layout);
|
|
setLayout(layout);
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化数据信息
|
|
|
|
|
+ updateCaptureList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void AvRecorder::setSettings(const SettingsPage::Param& param)
|
|
void AvRecorder::setSettings(const SettingsPage::Param& param)
|
|
@@ -50,7 +50,7 @@ void AvRecorder::setSettings(const SettingsPage::Param& param)
|
|
|
}
|
|
}
|
|
|
void AvRecorder::initConnect()
|
|
void AvRecorder::initConnect()
|
|
|
{
|
|
{
|
|
|
- connect(m_recordBtn, &QPushButton::released, [this] {
|
|
|
|
|
|
|
+ connect(m_recordBtn, &QPushButton::released, this, [this] {
|
|
|
if (!m_isRecord) {
|
|
if (!m_isRecord) {
|
|
|
auto fileName = m_settingsParam.outputDir;
|
|
auto fileName = m_settingsParam.outputDir;
|
|
|
if (fileName.back() != '\\') {
|
|
if (fileName.back() != '\\') {
|
|
@@ -70,7 +70,7 @@ void AvRecorder::initConnect()
|
|
|
}
|
|
}
|
|
|
m_isRecord = !m_isRecord;
|
|
m_isRecord = !m_isRecord;
|
|
|
});
|
|
});
|
|
|
- connect(m_liveBtn, &QPushButton::released, [this] {
|
|
|
|
|
|
|
+ connect(m_liveBtn, &QPushButton::released, this, [this] {
|
|
|
if (!m_isLive) {
|
|
if (!m_isLive) {
|
|
|
auto fileName = m_settingsParam.liveUrl + "/" + m_settingsParam.liveName;
|
|
auto fileName = m_settingsParam.liveUrl + "/" + m_settingsParam.liveName;
|
|
|
bool isRtsp = m_settingsParam.liveUrl.find("rtsp") != std::string::npos;
|
|
bool isRtsp = m_settingsParam.liveUrl.find("rtsp") != std::string::npos;
|
|
@@ -94,14 +94,14 @@ void AvRecorder::initConnect()
|
|
|
}
|
|
}
|
|
|
m_isLive = !m_isLive;
|
|
m_isLive = !m_isLive;
|
|
|
});
|
|
});
|
|
|
- connect(m_microphoneWidget, &AudioWidget::SetVolumeScale, [this](float scale) {
|
|
|
|
|
|
|
+ connect(m_microphoneWidget, &AudioWidget::SetVolumeScale, this, [this](float scale) {
|
|
|
m_audioRecorder.SetVolumeScale(scale, MICROPHONE_INDEX);
|
|
m_audioRecorder.SetVolumeScale(scale, MICROPHONE_INDEX);
|
|
|
});
|
|
});
|
|
|
- connect(m_speakerWidget, &AudioWidget::SetVolumeScale, [this](float scale) {
|
|
|
|
|
|
|
+ connect(m_speakerWidget, &AudioWidget::SetVolumeScale, this, [this](float scale) {
|
|
|
m_audioRecorder.SetVolumeScale(scale, SPEAKER_INDEX);
|
|
m_audioRecorder.SetVolumeScale(scale, SPEAKER_INDEX);
|
|
|
});
|
|
});
|
|
|
- connect(m_updateListBtn, &QPushButton::released, [this] { updateCaptureList(); });
|
|
|
|
|
- connect(m_captureListWidget, &QListWidget::currentTextChanged, [this](const QString& text) {
|
|
|
|
|
|
|
+ connect(m_updateListBtn, &QPushButton::released, this, [this] { updateCaptureList(); });
|
|
|
|
|
+ connect(m_captureComboBox, &QComboBox::currentTextChanged, this, [this](const QString& text) {
|
|
|
if (text.isEmpty() || m_isLocked) {
|
|
if (text.isEmpty() || m_isLocked) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -112,10 +112,10 @@ void AvRecorder::initConnect()
|
|
|
startPreview();
|
|
startPreview();
|
|
|
m_isLocked = false;
|
|
m_isLocked = false;
|
|
|
});
|
|
});
|
|
|
- connect(m_isDrawCursorBox, &QCheckBox::stateChanged, [this] {
|
|
|
|
|
|
|
+ connect(m_isDrawCursorBox, &QCheckBox::stateChanged, this, [this] {
|
|
|
m_videoRecorder.SetIsDrawCursor(m_isDrawCursorBox->isChecked());
|
|
m_videoRecorder.SetIsDrawCursor(m_isDrawCursorBox->isChecked());
|
|
|
});
|
|
});
|
|
|
- connect(m_captureMethodBox, &QComboBox::currentTextChanged, [this](const QString& text) {
|
|
|
|
|
|
|
+ connect(m_captureMethodBox, &QComboBox::currentTextChanged, this, [this](const QString& text) {
|
|
|
if (m_isLocked || text.isEmpty()) {
|
|
if (m_isLocked || text.isEmpty()) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -130,7 +130,7 @@ void AvRecorder::initConnect()
|
|
|
}
|
|
}
|
|
|
startPreview();
|
|
startPreview();
|
|
|
});
|
|
});
|
|
|
- connect(m_settingsBtn, &QPushButton::released, [this] {
|
|
|
|
|
|
|
+ connect(m_settingsBtn, &QPushButton::released, this, [this] {
|
|
|
auto settingsPage = std::make_unique<SettingsPage>(&m_settingsParam, this);
|
|
auto settingsPage = std::make_unique<SettingsPage>(&m_settingsParam, this);
|
|
|
settingsPage->exec();
|
|
settingsPage->exec();
|
|
|
m_isLocked = true;
|
|
m_isLocked = true;
|
|
@@ -184,7 +184,7 @@ AvRecorder::~AvRecorder()
|
|
|
bool AvRecorder::start()
|
|
bool AvRecorder::start()
|
|
|
{
|
|
{
|
|
|
auto timer = new QTimer(this);
|
|
auto timer = new QTimer(this);
|
|
|
- connect(timer, &QTimer::timeout, [this, timer] {
|
|
|
|
|
|
|
+ connect(timer, &QTimer::timeout, this, [this, timer] {
|
|
|
m_isLocked = true;
|
|
m_isLocked = true;
|
|
|
stopPreview();
|
|
stopPreview();
|
|
|
stopCapture();
|
|
stopCapture();
|
|
@@ -203,43 +203,27 @@ void AvRecorder::startCapture(VideoCapturer::Method method)
|
|
|
m_captureMethodBox->clear();
|
|
m_captureMethodBox->clear();
|
|
|
m_captureMethodBox->addItem("WGC");
|
|
m_captureMethodBox->addItem("WGC");
|
|
|
}
|
|
}
|
|
|
- QListWidgetItem* item = m_captureListWidget->currentItem();
|
|
|
|
|
- if (!item) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const QString type = item->data(Qt::UserRole + 1).toString();
|
|
|
|
|
-
|
|
|
|
|
- // 判断是要捕获屏幕还是窗口
|
|
|
|
|
- int idx = m_captureListWidget->currentRow();
|
|
|
|
|
|
|
+ int idx = m_captureComboBox->currentIndex();
|
|
|
if (idx < 0) {
|
|
if (idx < 0) {
|
|
|
- idx = 0;
|
|
|
|
|
- m_captureListWidget->setCurrentRow(idx);
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- int monitorCnt = (int) MonitorFinder::GetList().size();
|
|
|
|
|
|
|
+ int monitorCnt = (int)MonitorFinder::GetList().size();
|
|
|
|
|
+ QString type = (idx < monitorCnt) ? "monitor" : "window";
|
|
|
|
|
+ qintptr ptrHwnd = m_captureComboBox->currentData().value<qintptr>();
|
|
|
if (idx < monitorCnt) { // 捕获屏幕
|
|
if (idx < monitorCnt) { // 捕获屏幕
|
|
|
if (m_captureMethodBox->count() < 2) {
|
|
if (m_captureMethodBox->count() < 2) {
|
|
|
m_captureMethodBox->addItem("DXGI");
|
|
m_captureMethodBox->addItem("DXGI");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
m_videoRecorder.Open(idx, m_settingsParam.videoParam, method);
|
|
m_videoRecorder.Open(idx, m_settingsParam.videoParam, method);
|
|
|
-
|
|
|
|
|
} else {
|
|
} else {
|
|
|
if (m_captureMethodBox->count() < 2) {
|
|
if (m_captureMethodBox->count() < 2) {
|
|
|
m_captureMethodBox->addItem("GDI");
|
|
m_captureMethodBox->addItem("GDI");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if (type == "window") {
|
|
if (type == "window") {
|
|
|
- qintptr ptrHwnd = item->data(Qt::UserRole + 2).value<qintptr>();
|
|
|
|
|
- if (::IsWindow((HWND) ptrHwnd)) {
|
|
|
|
|
- m_videoRecorder.Open((HWND) ptrHwnd, m_settingsParam.videoParam, method);
|
|
|
|
|
|
|
+ if (::IsWindow((HWND)ptrHwnd)) {
|
|
|
|
|
+ m_videoRecorder.Open((HWND)ptrHwnd, m_settingsParam.videoParam, method);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // auto hwnd = WindowFinder::GetList()[idx - monitorCnt].hwnd;
|
|
|
|
|
-
|
|
|
|
|
- // m_videoRecorder.Open(hwnd, m_settingsParam.videoParam, method);
|
|
|
|
|
}
|
|
}
|
|
|
dealCapture();
|
|
dealCapture();
|
|
|
m_isDrawCursorBox->setEnabled(true);
|
|
m_isDrawCursorBox->setEnabled(true);
|
|
@@ -302,7 +286,7 @@ bool AvRecorder::startStream(std::string_view path, std::string_view format)
|
|
|
m_recordTime = QTime::currentTime();
|
|
m_recordTime = QTime::currentTime();
|
|
|
m_captureStatusLabel->setText("状态: 正在工作");
|
|
m_captureStatusLabel->setText("状态: 正在工作");
|
|
|
m_settingsBtn->setEnabled(false);
|
|
m_settingsBtn->setEnabled(false);
|
|
|
- m_captureListWidget->setEnabled(false);
|
|
|
|
|
|
|
+ m_captureComboBox->setEnabled(false);
|
|
|
m_updateListBtn->setEnabled(false);
|
|
m_updateListBtn->setEnabled(false);
|
|
|
m_captureMethodBox->setEnabled(false);
|
|
m_captureMethodBox->setEnabled(false);
|
|
|
return true;
|
|
return true;
|
|
@@ -322,7 +306,7 @@ void AvRecorder::stopStream()
|
|
|
|
|
|
|
|
m_captureStatusLabel->setText("状态: 正常");
|
|
m_captureStatusLabel->setText("状态: 正常");
|
|
|
m_settingsBtn->setEnabled(true);
|
|
m_settingsBtn->setEnabled(true);
|
|
|
- m_captureListWidget->setEnabled(true);
|
|
|
|
|
|
|
+ m_captureComboBox->setEnabled(true);
|
|
|
m_updateListBtn->setEnabled(true);
|
|
m_updateListBtn->setEnabled(true);
|
|
|
m_captureMethodBox->setEnabled(true);
|
|
m_captureMethodBox->setEnabled(true);
|
|
|
}
|
|
}
|
|
@@ -353,31 +337,24 @@ void AvRecorder::stopSyncRecord()
|
|
|
}
|
|
}
|
|
|
void AvRecorder::updateCaptureList()
|
|
void AvRecorder::updateCaptureList()
|
|
|
{
|
|
{
|
|
|
- m_captureListWidget->clear();
|
|
|
|
|
|
|
+ m_captureComboBox->clear();
|
|
|
auto&& monitorList = MonitorFinder::GetList(true);
|
|
auto&& monitorList = MonitorFinder::GetList(true);
|
|
|
for (auto&& monitor : monitorList) {
|
|
for (auto&& monitor : monitorList) {
|
|
|
- QListWidgetItem* item = new QListWidgetItem("屏幕: "
|
|
|
|
|
- + QString::fromStdWString(monitor.title));
|
|
|
|
|
-
|
|
|
|
|
- item->setData(Qt::UserRole + 1, "monitor");
|
|
|
|
|
- item->setData(Qt::UserRole + 2, qintptr(monitor.monitor));
|
|
|
|
|
- m_captureListWidget->addItem(item);
|
|
|
|
|
|
|
+ QString text = "屏幕: " + QString::fromStdWString(monitor.title);
|
|
|
|
|
+ m_captureComboBox->addItem(text, QVariant::fromValue(qintptr(monitor.monitor)));
|
|
|
}
|
|
}
|
|
|
auto&& windowList = WindowFinder::GetList(true);
|
|
auto&& windowList = WindowFinder::GetList(true);
|
|
|
for (auto&& window : windowList) {
|
|
for (auto&& window : windowList) {
|
|
|
- QListWidgetItem* item = new QListWidgetItem("窗口: "
|
|
|
|
|
- + QString::fromStdWString(window.title));
|
|
|
|
|
- item->setData(Qt::UserRole + 1, "window");
|
|
|
|
|
- item->setData(Qt::UserRole + 2, qintptr(window.hwnd));
|
|
|
|
|
- m_captureListWidget->addItem(item);
|
|
|
|
|
|
|
+ QString text = "窗口: " + QString::fromStdWString(window.title);
|
|
|
|
|
+ m_captureComboBox->addItem(text, QVariant::fromValue(qintptr(window.hwnd)));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
QVBoxLayout* AvRecorder::initListUi()
|
|
QVBoxLayout* AvRecorder::initListUi()
|
|
|
{
|
|
{
|
|
|
auto layout = new QVBoxLayout;
|
|
auto layout = new QVBoxLayout;
|
|
|
- m_captureListWidget = new QListWidget;
|
|
|
|
|
- layout->addWidget(m_captureListWidget);
|
|
|
|
|
|
|
+ m_captureComboBox = new QComboBox;
|
|
|
|
|
+ layout->addWidget(m_captureComboBox);
|
|
|
return layout;
|
|
return layout;
|
|
|
}
|
|
}
|
|
|
|
|
|