58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::MainWindow),
|
|
m_bCameraOpen(false),
|
|
mCamera(nullptr),
|
|
m_bRtmpPushing(false)
|
|
{
|
|
ui->setupUi(this);
|
|
std::vector<std::wstring> cameras = Camera::EnumAllCamera();
|
|
for(std::wstring x : cameras){
|
|
ui->comboBox->addItem(QString::fromWCharArray(x.c_str(),x.size()),
|
|
QString::fromWCharArray(x.c_str(),x.size()));
|
|
}
|
|
}
|
|
|
|
MainWindow::~MainWindow(){
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::on_pushButton_clicked(){
|
|
if(nullptr == mPlayerWidget){
|
|
mPlayerWidget = new CPlayWidget(nullptr);
|
|
//mVideoCoder = new VideoCoder(mCamera->GetWidth(),mCamera->GetHeight(),);
|
|
}
|
|
if(!m_bCameraOpen){
|
|
mPlayerWidget->SetDataType(CPlayWidget::IMG_TYPE::TYPE_RGB32);
|
|
mPlayerWidget->SetImgSize(640,480);
|
|
|
|
qDebug()<<ui->comboBox->currentText().size()<<ui->comboBox->currentText();
|
|
wchar_t *opencamera = new wchar_t[ui->comboBox->currentText().size()];
|
|
ui->comboBox->currentText().toWCharArray(opencamera);
|
|
wstring ss = wstring(opencamera,ui->comboBox->currentText().size());
|
|
if(nullptr == mCamera){
|
|
this->mCamera = new Camera(ss);
|
|
}
|
|
this->mCamera->SetObserver(mPlayerWidget);
|
|
qDebug()<<ui->comboBox->currentText();
|
|
ui->pushButton->setText("关闭摄像头");
|
|
m_bCameraOpen = true;
|
|
mPlayerWidget->show();
|
|
}else{
|
|
m_bCameraOpen = false;
|
|
ui->pushButton->setText("打开摄像头");
|
|
}
|
|
}
|
|
|
|
void MainWindow::on_pushButton_2_clicked()
|
|
{
|
|
if(!m_bRtmpPushing){
|
|
if(!m_bCameraOpen){
|
|
ToastWidget::showTip("请打开摄像头",this);
|
|
}
|
|
}
|
|
}
|