no message

master
zcy 2022-05-13 00:58:26 +08:00
parent 6dc338bad5
commit b1f865dda7
6 changed files with 66 additions and 40 deletions

View File

@ -108,6 +108,7 @@ CPlayWidget::CPlayWidget(QWidget *parent):QOpenGLWidget(parent) {
m_nVideoH = 0;
m_nVideoW = 0;
mType = TYPE_I420;
m_start_render = false;
}
CPlayWidget::~CPlayWidget() {
@ -116,7 +117,19 @@ CPlayWidget::~CPlayWidget() {
int CPlayWidget::SetDataType(CPlayWidget::IMG_TYPE type){
this->mType = type;
// initializeGL();
initializeGL();
return 0;
}
int CPlayWidget::StartRender()
{
this->m_start_render = true;
return 0;
}
int CPlayWidget::StopRender()
{
this->m_start_render = false;
return 0;
}
@ -230,6 +243,7 @@ void CPlayWidget::resizeGL(int w, int h)
void CPlayWidget::paintGL()
{
if(m_start_render){
if(mType == TYPE_YUV420P)
loadYuvTexture();
if(mType == TYPE_RGB32){
@ -240,6 +254,7 @@ void CPlayWidget::paintGL()
}
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
return;
}

View File

@ -39,7 +39,8 @@ public:
CPlayWidget(QWidget* parent);
~CPlayWidget();
int SetDataType(IMG_TYPE);
int StartRender();
int StopRender();
int OnCameraData(uint8_t *);
int SetImgSize(uint32_t width,uint32_t );
protected:
@ -82,5 +83,6 @@ private:
int loadRtcI420Texture();
int loadRgbTexture();
rtc::scoped_refptr<webrtc::I420BufferInterface> m_buffer;
bool m_start_render;
};
#endif

View File

@ -56,6 +56,8 @@ void EnumCapture()
int main(int argc, char *argv[])
{
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>");
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>&");
rtc::WinsockInitializer winsock_init;
rtc::Win32SocketServer w32_ss;
@ -63,25 +65,11 @@ int main(int argc, char *argv[])
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
rtc::InitializeSSL();
// std::unique_ptr<CameraVideoSink> capturer;
// int num_devices = info->NumberOfDevices();
// for (int i = 0; i < num_devices; ++i) {
//// capturer.reset(CameraVideoSink::Create(kWidth, kHeight, kFps, i));
//// if (capturer) {
//// break;
//// }
// }
setbuf(stdout, NULL);
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>");
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>&");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
MainWindow w;
// QObject::connect((CameraVideoSink*)capturer.get(),SIGNAL(UpdateFrame(rtc::scoped_refptr<webrtc::I420BufferInterface>&)),&w,
// SLOT(OnUpdateFrame( rtc::scoped_refptr<webrtc::I420BufferInterface>&)),Qt::ConnectionType::AutoConnection);
w.setWindowTitle("webrtc easy demo");
w.show();
return a.exec();
}

View File

@ -45,7 +45,6 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
// ui->openGLWidget->SetImgSize(640,480);
ui->openGLWidget->show();
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
@ -59,7 +58,6 @@ MainWindow::MainWindow(QWidget *parent)
info->GetDeviceName(i,name,100,nullptr,0,nullptr,0);
ui->comboBox->addItem(QString::asprintf("%s",name),i);
}
}
MainWindow::~MainWindow()
@ -92,6 +90,7 @@ void MainWindow::on_pushButton_clicked()
ui->openGLWidget->SetDataType(CPlayWidget::TYPE_YUV420P);
ui->openGLWidget->SetImgSize(m_capturer->Capability().width,
m_capturer->Capability().height);
ui->openGLWidget->StartRender();
// ui->openGLWidget->moveToThread(&gRender->Thread());
if(gRender == nullptr){
gRender = new AsyncRennder(this,m_capturer->VideoBuffer(),ui->openGLWidget);
@ -105,3 +104,16 @@ void MainWindow::RenderDone()
}
void MainWindow::on_pushButton_2_clicked()
{
CPlayWidget *ptr = new CPlayWidget(this);
CPlayWidget *ptr1 = new CPlayWidget(this);
CPlayWidget *ptr2 = new CPlayWidget(this);
ui->gridLayout->addWidget(ptr,0,1);
ui->gridLayout->addWidget(ptr1,1,0);
ui->gridLayout->addWidget(ptr2,1,1);
}

View File

@ -21,6 +21,8 @@ public slots:
private slots:
void on_pushButton_clicked();
void RenderDone();
void on_pushButton_2_clicked();
private:
Ui::MainWindow *ui;
std::unique_ptr<CameraVideoSink> m_capturer;

View File

@ -22,7 +22,7 @@
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,9">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1,3">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1,0,3">
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -56,6 +56,13 @@
<item>
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>增加窗口</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">