代码拉取完成,页面将自动刷新
同步操作将从 cNull/rtsp-mediasoup-demo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "MainWgt.h"
#include <QPushButton>
#include <QDebug>
#include <QPainter>
#include <QMessageBox>
MainWgt::MainWgt(QWidget *parent): QWidget(parent)
{
ui.setupUi(this);
setFixedSize(983,705);
setWindowTitle("mediasoup demo");
connect(ui.videoBtn, &QPushButton::clicked, this, [=] {
m_mediaCtrl->pauseVideo(m_pauseVideo);
m_pauseVideo = !m_pauseVideo;
});
connect(ui.audioBtn, &QPushButton::clicked, this, [=] {
m_mediaCtrl->pauseAudio(m_pauseAudio);
m_pauseAudio = !m_pauseAudio;
});
m_mediaCtrl = new vi::MediaCtroller;
m_mediaCtrl->regiestCallback(this);
m_mediaCtrl->regiestRemoteVideo(std::bind(&MainWgt::remoteVideoCb,this,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
connect(ui.start, &QPushButton::clicked, this, &MainWgt::onConnectWss);
}
void MainWgt::onConnectWss()
{
//wss://192.168.20.59:4443/?roomId=1&peerId=1
if (ui.wssEdit->text().isEmpty() || ui.roomEdit->text().isEmpty() || ui.peerEdit->text().isEmpty()) {
QMessageBox::question(this, "warning", u8"ֶβΪ");
return;
}
QString wssUrl = ui.wssEdit->text() + QString("/?roomId=") + ui.roomEdit->text() + QString("&peerId=") + ui.peerEdit->text();
QString rtspUrl = ui.rtspEdit->text().toStdString().c_str();
m_mediaCtrl->setRtspUrl(rtspUrl.toUtf8().data());
m_mediaCtrl->connectServer(wssUrl.toUtf8());
}
MainWgt::~MainWgt()
{
}
void MainWgt::remoteVideoCb(QString peerId, unsigned char* yuv, int width, int height)
{
YangPlayWidget* canvas = nullptr;
if (m_canvasMap.find(peerId) == m_canvasMap.end()) {
if (m_index == 2){
canvas = ui.canvas2;
}
else if (m_index == 3){
canvas = ui.canvas3;
}
else if (m_index == 4){
canvas = ui.canvas4;
}
else if (m_index == 5){
canvas = ui.canvas5;
}
else if (m_index == 6){
canvas = ui.canvas6;
}
m_canvasMap.insert(peerId, canvas);
m_index++;
}
else {
canvas = m_canvasMap.value(peerId);
}
canvas->playVideo(yuv, width, height);
}
void MainWgt::onNewPeer(QString peerId)
{
}
void MainWgt::onLocalVideoFrame(unsigned char* pdata, int width, int height)
{
ui.canvas1->playVideo(pdata,width,height);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。