no message

master
zcy 2021-12-10 00:32:32 +08:00
parent 0cd57f751f
commit 8466492420
3 changed files with 68 additions and 6 deletions

View File

@ -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"<<data->kind().c_str();
auto* track = reinterpret_cast<webrtc::MediaStreamTrackInterface*>(data);
mRemoteStream = reinterpret_cast<webrtc::MediaStreamTrackInterface*>(data);
if (track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) {
auto* video_track = static_cast<webrtc::VideoTrackInterface*>(track);
if (mRemoteStream->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) {
auto* video_track = static_cast<webrtc::VideoTrackInterface*>(mRemoteStream);
qDebug()<<"remote trackid is "<<video_track->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()
{
}

View File

@ -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<WebrtcHanlder> mHandler;
@ -167,6 +169,6 @@ private:
bool mCalling;
std::unique_ptr<VideoRenderer> local_renderer_;
std::unique_ptr<VideoRenderer> remote_renderer_;
webrtc::MediaStreamTrackInterface* mRemoteStream;
};
#endif // MAINWINDOW_H

View File

@ -14,7 +14,7 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,15,0">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,15,1,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,1,0,2,0,0,1,0">
<item>
@ -136,6 +136,50 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0,8">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>暂停对方视频流</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>暂停本地视频流</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0">
<item>