diff --git a/client/webrtc_demo/src/mainwindow.cpp b/client/webrtc_demo/src/mainwindow.cpp index 025daed..eed0f92 100644 --- a/client/webrtc_demo/src/mainwindow.cpp +++ b/client/webrtc_demo/src/mainwindow.cpp @@ -58,6 +58,7 @@ MainWindow::MainWindow(QWidget *parent) ,mSignalClient(nullptr) ,mModel(nullptr) ,mCalling(false) + ,mRemoteStream(nullptr) { ui->setupUi(this); ui->openGLWidget->show(); @@ -451,10 +452,10 @@ void MainWindow::on_local_sdp(QString sdp) void MainWindow::on_track_add(webrtc::MediaStreamTrackInterface *data) { qDebug()<<"on_track_add"<kind().c_str(); - auto* track = reinterpret_cast(data); + mRemoteStream = reinterpret_cast(data); - if (track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { - auto* video_track = static_cast(track); + if (mRemoteStream->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { + auto* video_track = static_cast(mRemoteStream); qDebug()<<"remote trackid is "<id().c_str(); remote_renderer_.reset(new VideoRenderer( 1, 1, video_track)); @@ -466,8 +467,10 @@ void MainWindow::on_track_add(webrtc::MediaStreamTrackInterface *data) connect((VideoRenderer*)(remote_renderer_.get()),SIGNAL(NotifySize(uint32_t ,uint32_t )), this,SLOT(on_notify_size(uint32_t ,uint32_t)), Qt::ConnectionType::QueuedConnection); + + gLog()->Log((QString::asprintf("%s %d",__FILE__,__LINE__) + + " on_track_add ").toStdString()); } - track->Release(); } void MainWindow::on_notify_size(uint32_t width, uint32_t height) @@ -614,3 +617,16 @@ void VideoRenderer::SetSize(int width, int height) width * height * (bmi_.bmiHeader.biBitCount >> 3); image_ = new uint8_t[bmi_.bmiHeader.biSizeImage]; } + +void MainWindow::on_pushButton_3_clicked() +{ + if(mRemoteStream != nullptr){ + mRemoteStream->set_enabled(false); + } + +} + +void MainWindow::on_pushButton_4_clicked() +{ + +} diff --git a/client/webrtc_demo/src/mainwindow.h b/client/webrtc_demo/src/mainwindow.h index 01c3172..e1248d9 100644 --- a/client/webrtc_demo/src/mainwindow.h +++ b/client/webrtc_demo/src/mainwindow.h @@ -157,6 +157,8 @@ private slots: void on_local_sdp(QString); void on_track_add(webrtc::MediaStreamTrackInterface*); void on_notify_size(uint32_t,uint32_t); + void on_pushButton_3_clicked(); + private: Ui::MainWindow *ui; rtc::scoped_refptr mHandler; @@ -167,6 +169,6 @@ private: bool mCalling; std::unique_ptr local_renderer_; std::unique_ptr remote_renderer_; - + webrtc::MediaStreamTrackInterface* mRemoteStream; }; #endif // MAINWINDOW_H diff --git a/client/webrtc_demo/src/mainwindow.ui b/client/webrtc_demo/src/mainwindow.ui index 864af62..1831f3f 100644 --- a/client/webrtc_demo/src/mainwindow.ui +++ b/client/webrtc_demo/src/mainwindow.ui @@ -14,7 +14,7 @@ MainWindow - + @@ -136,6 +136,50 @@ + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 暂停对方视频流 + + + + + + + 暂停本地视频流 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + +