|
|
@@ -16,25 +16,95 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
m_settingsParam.liveUrl = "rtmp://192.168.3.76:1935/stream/V1";
|
|
|
m_settingsParam.liveName = "stream";
|
|
|
|
|
|
+ // 1. 视频预览区
|
|
|
m_glWidget = new OpenGLVideoWidget(this);
|
|
|
|
|
|
- auto layout = new QVBoxLayout;
|
|
|
- auto hLayout = new QHBoxLayout;
|
|
|
-
|
|
|
- hLayout->addLayout(initAudioUi(), 2);
|
|
|
- hLayout->addLayout(initListUi(), 2);
|
|
|
- hLayout->addLayout(initOtherUi(), 1);
|
|
|
+ // 2. 音频区
|
|
|
+ m_microphoneWidget = new AudioWidget;
|
|
|
+ m_speakerWidget = new AudioWidget;
|
|
|
+ m_microphoneWidget->SetName("麦克风");
|
|
|
+ m_speakerWidget->SetName("扬声器");
|
|
|
|
|
|
+ // 3. 捕获区
|
|
|
+ m_captureComboBox = new QComboBox;
|
|
|
+ m_updateListBtn = new QPushButton("刷新窗口列表");
|
|
|
+ QGroupBox* captureGroup = new QGroupBox("捕获源");
|
|
|
+ QVBoxLayout* captureLayout = new QVBoxLayout;
|
|
|
+ QHBoxLayout* captureRow = new QHBoxLayout;
|
|
|
+ captureRow->addWidget(m_captureComboBox);
|
|
|
+ captureRow->addWidget(m_updateListBtn);
|
|
|
+ captureLayout->addLayout(captureRow);
|
|
|
+ captureGroup->setLayout(captureLayout);
|
|
|
+ captureGroup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
|
|
+
|
|
|
+ // 4. 音频区分组
|
|
|
+ QGroupBox* audioGroup = new QGroupBox("音频");
|
|
|
+ QVBoxLayout* audioLayout = new QVBoxLayout;
|
|
|
+ audioLayout->addWidget(m_microphoneWidget);
|
|
|
+ audioLayout->addWidget(m_speakerWidget);
|
|
|
+ audioGroup->setLayout(audioLayout);
|
|
|
+ audioGroup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
|
|
+
|
|
|
+ // 5. 操作区
|
|
|
+ m_isDrawCursorBox = new QCheckBox("绘制鼠标指针");
|
|
|
+ m_isDrawCursorBox->setChecked(true);
|
|
|
+ m_isDrawCursorBox->setEnabled(false);
|
|
|
+ m_syncRecordBox = new QCheckBox("直播时同步录像");
|
|
|
+ m_syncRecordBox->setChecked(false);
|
|
|
+ m_recordBtn = new QPushButton("开始录制");
|
|
|
+ m_recordBtn->setEnabled(false);
|
|
|
+ m_liveBtn = new QPushButton("开始直播");
|
|
|
+ m_liveBtn->setEnabled(false);
|
|
|
+ m_settingsBtn = new QPushButton("设置");
|
|
|
+ QGroupBox* actionGroup = new QGroupBox("操作");
|
|
|
+ QVBoxLayout* actionLayout = new QVBoxLayout;
|
|
|
+ QHBoxLayout* checkBoxRow = new QHBoxLayout;
|
|
|
+ checkBoxRow->setContentsMargins(0, 0, 0, 0);
|
|
|
+ checkBoxRow->setSpacing(8);
|
|
|
+ checkBoxRow->addWidget(m_syncRecordBox);
|
|
|
+ checkBoxRow->addWidget(m_isDrawCursorBox);
|
|
|
+ actionLayout->addLayout(checkBoxRow);
|
|
|
+ actionLayout->addWidget(m_recordBtn);
|
|
|
+ actionLayout->addWidget(m_liveBtn);
|
|
|
+ actionGroup->setLayout(actionLayout);
|
|
|
+ actionGroup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
|
|
+
|
|
|
+ // 6. 设置区
|
|
|
+ QHBoxLayout* utilLayout = new QHBoxLayout;
|
|
|
+ utilLayout->addWidget(m_settingsBtn);
|
|
|
+
|
|
|
+ // 7. 左侧功能区(捕获区在上,音频区在下)
|
|
|
+ QVBoxLayout* leftLayout = new QVBoxLayout;
|
|
|
+ leftLayout->addWidget(captureGroup);
|
|
|
+ leftLayout->addWidget(audioGroup);
|
|
|
+ leftLayout->addStretch();
|
|
|
+
|
|
|
+ // 8. 右侧功能区
|
|
|
+ QVBoxLayout* rightLayout = new QVBoxLayout;
|
|
|
+ rightLayout->addWidget(actionGroup);
|
|
|
+ rightLayout->addLayout(utilLayout);
|
|
|
+ rightLayout->addStretch();
|
|
|
+
|
|
|
+ // 9. 中部主布局
|
|
|
+ QHBoxLayout* centerLayout = new QHBoxLayout;
|
|
|
+ centerLayout->addLayout(leftLayout, 2);
|
|
|
+ centerLayout->addLayout(rightLayout, 3);
|
|
|
+
|
|
|
+ // 10. 状态栏
|
|
|
initStatusBarUi();
|
|
|
|
|
|
- initConnect();
|
|
|
+ // 让视频区尽量大
|
|
|
+ m_glWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
|
- layout->addWidget(m_glWidget, 4);
|
|
|
- layout->addLayout(hLayout, 1);
|
|
|
- layout->addWidget(m_statusBar, 0);
|
|
|
- setLayout(layout);
|
|
|
+ // 11. 总体布局
|
|
|
+ QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
|
|
+ mainLayout->addWidget(m_glWidget, 100);
|
|
|
+ mainLayout->addLayout(centerLayout, 0);
|
|
|
+ mainLayout->addWidget(m_statusBar, 0);
|
|
|
+ setLayout(mainLayout);
|
|
|
|
|
|
- // 初始化数据信息
|
|
|
+ // 12. 连接信号槽、初始化数据
|
|
|
+ initConnect();
|
|
|
updateCaptureList();
|
|
|
}
|
|
|
|
|
|
@@ -207,7 +277,7 @@ void AvRecorder::startCapture(VideoCapturer::Method method)
|
|
|
if (idx < 0) {
|
|
|
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) { // 捕获屏幕
|
|
|
@@ -220,8 +290,8 @@ void AvRecorder::startCapture(VideoCapturer::Method method)
|
|
|
m_captureMethodBox->addItem("GDI");
|
|
|
}
|
|
|
if (type == "window") {
|
|
|
- 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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -350,49 +420,6 @@ void AvRecorder::updateCaptureList()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-QVBoxLayout* AvRecorder::initListUi()
|
|
|
-{
|
|
|
- auto layout = new QVBoxLayout;
|
|
|
- m_captureComboBox = new QComboBox;
|
|
|
- layout->addWidget(m_captureComboBox);
|
|
|
- return layout;
|
|
|
-}
|
|
|
-
|
|
|
-QVBoxLayout* AvRecorder::initAudioUi()
|
|
|
-{
|
|
|
- m_microphoneWidget = new AudioWidget;
|
|
|
- m_speakerWidget = new AudioWidget;
|
|
|
- m_microphoneWidget->SetName("麦克风");
|
|
|
- m_speakerWidget->SetName("扬声器");
|
|
|
- auto layout = new QVBoxLayout;
|
|
|
- layout->addWidget(m_microphoneWidget);
|
|
|
- layout->addWidget(m_speakerWidget);
|
|
|
- return layout;
|
|
|
-}
|
|
|
-
|
|
|
-QVBoxLayout* AvRecorder::initOtherUi()
|
|
|
-{
|
|
|
- m_isDrawCursorBox = new QCheckBox("绘制鼠标指针");
|
|
|
- m_isDrawCursorBox->setChecked(true);
|
|
|
- m_isDrawCursorBox->setEnabled(false);
|
|
|
- m_syncRecordBox = new QCheckBox("直播时同步录像");
|
|
|
- m_syncRecordBox->setChecked(false);
|
|
|
- m_updateListBtn = new QPushButton("刷新窗口列表");
|
|
|
- m_recordBtn = new QPushButton("开始录制");
|
|
|
- m_recordBtn->setEnabled(false);
|
|
|
- m_liveBtn = new QPushButton("开始直播");
|
|
|
- m_liveBtn->setEnabled(false);
|
|
|
- m_settingsBtn = new QPushButton("设置");
|
|
|
- auto layout = new QVBoxLayout;
|
|
|
- layout->addWidget(m_isDrawCursorBox);
|
|
|
- layout->addWidget(m_syncRecordBox);
|
|
|
- layout->addWidget(m_updateListBtn);
|
|
|
- layout->addWidget(m_recordBtn);
|
|
|
- layout->addWidget(m_liveBtn);
|
|
|
- layout->addWidget(m_settingsBtn);
|
|
|
- return layout;
|
|
|
-}
|
|
|
-
|
|
|
void AvRecorder::initStatusBarUi()
|
|
|
{
|
|
|
m_videoEncodeLabel = new QLabel;
|