no message

master
zcy 2021-10-31 23:05:27 +08:00
parent 7eb86f31bd
commit 95cd1c24da
5 changed files with 40 additions and 28 deletions

View File

@ -115,22 +115,17 @@ void MyCapturer::OnCaptureResult(webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) {
if (result != webrtc::DesktopCapturer::Result::SUCCESS)
return;
int width = frame->size().width();
int height = frame->size().height();
if (!i420_buffer_.get() ||
i420_buffer_->width() * i420_buffer_->height() < width * height) {
i420_buffer_ = webrtc::I420Buffer::Create(width, height);
}
libyuv::ConvertToI420(frame->data(), 0, i420_buffer_->MutableDataY(),
i420_buffer_->StrideY(), i420_buffer_->MutableDataU(),
i420_buffer_->StrideU(), i420_buffer_->MutableDataV(),
i420_buffer_->StrideV(), 0, 0, width, height, width,
height, libyuv::kRotate0, libyuv::FOURCC_ARGB);
// RawToBmp(frame->data(),height,width,32,"d://sss.bmp");
OnFrame(webrtc::VideoFrame(i420_buffer_, 0, 0, webrtc::kVideoRotation_0));
}

View File

@ -150,13 +150,16 @@ int CPlayWidget::SetImgSize(uint32_t width, uint32_t height)
m_nVideoH = height;
m_nVideoW = width;
if(mType == TYPE_RGB32){
m_pBufRgb32 = new uint8_t[width * height *8];
m_pBufRgb32 = new uint8_t[width * height *4];
}
if(mType == TYPE_YUV420P){
m_pBufYuv420p = new uint8_t[width * height *3/2];
}
if(mType == TYPE_I420){
m_pBufYuv420p = new uint8_t[width * height *3/2];
memset(m_pBufYuv420p,0x00,width * height );
memset(m_pBufYuv420p + width * height ,0xff,width * height/2 );
}
return 0;
}

View File

@ -104,24 +104,6 @@ void InitCustomMetaType(){
int main(int argc, char *argv[])
{
InitCustomMetaType();
// const size_t kWidth = 1280;
// const size_t kHeight = 720;
// const size_t kFps = 30;
// std::unique_ptr<VcmCapturerTest> capturer;
// std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
// webrtc::VideoCaptureFactory::CreateDeviceInfo());
// if (!info) {
// RTC_LOG(LERROR) << "CreateDeviceInfo failed";
// return -1;
// }
// int num_devices = info->NumberOfDevices();
// for (int i = 0; i < num_devices; ++i) {
// capturer.reset(VcmCapturerTest::Create(kWidth, kHeight, kFps, i));
// if (capturer) {
// break;
// }
// }
rtc::WinsockInitializer winsock_init;
rtc::Win32SocketServer w32_ss;

View File

@ -45,6 +45,25 @@ MainWindow::MainWindow(QWidget *parent)
connect((WebrtcHanlder*)(mHandler.get()),SIGNAL(OnLocalTrack(webrtc::VideoTrackInterface* )),
this,SLOT(on_local_track_add(webrtc::VideoTrackInterface* )));
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
webrtc::VideoCaptureFactory::CreateDeviceInfo());
if (!info) {
RTC_LOG(LERROR) << "CreateDeviceInfo failed";
}
int num_devices = info->NumberOfDevices();
for (int i = 0; i < num_devices; ++i) {
char devicename[200];
char device_unique[200];
char product_unique[200];
info->GetDeviceName(i,devicename,200,device_unique,200,product_unique,200);
qDebug()<< "device name : "<< devicename<<"unique device: "<<device_unique<<"produce unique: "<<product_unique;
webrtc::VideoCaptureCapability p;
info->GetCapability(device_unique,0,p);
qDebug()<<devicename<<" capability: width"<<p.width << p.height<<int(p.videoType);
ui->comboBox->addItem(QString(devicename),device_unique);
}
}
MainWindow::~MainWindow()
@ -89,7 +108,7 @@ int WebrtcHanlder::InitWebrtc()
nullptr /* audio_processing */);
if (!m_peer_connection_factory_) {
auto x = new QMessageBox(nullptr);
auto x = new QMessageBox(nullptr);
x->setText("创建peerconnection factory失败");
x->show();
exit(0);
@ -319,6 +338,9 @@ void WebrtcHanlder::OnSuccess(webrtc::SessionDescriptionInterface *desc)
if(QString(desc->type().c_str()) == "offer"){
OnOfferSdp(QJsonDocument(addr).toJson());
}
if(QString(desc->type().c_str()) == "answer"){
OnOfferSdp(QJsonDocument(addr).toJson());
}
}
void WebrtcHanlder::OnFailure(webrtc::RTCError error)
@ -342,6 +364,7 @@ void MainWindow::signal_conneted()
ui->label_5->setText("信令服务器已连接");
this->mSignalClient->SendLogin();
ui->label_6->setText(QString("本节点名称: " + mSignalClient->PeerName()));
this->mPeerName = mSignalClient->PeerName();
}
void MainWindow::on_pushButton_2_clicked()
@ -396,7 +419,6 @@ void MainWindow::signal_response(int type,QJsonObject data)
this->mHandler.get()->SetRemoteCandidate(candidate);
mRemoteName = remote_names;
qDebug()<<"recv candidate"<<candidate;
break;
}
}
@ -408,11 +430,17 @@ void MainWindow::itemClicked(QModelIndex index)
qDebug()<<"请先连接信令服务";
return;
}
mHandler->CreateOffer();
qDebug()<<mModel->item(index.row())->text();
mRemoteName = mModel->item(index.row())->text();
if(mRemoteName == mPeerName){
auto x = new QMessageBox(nullptr);
x->setText("无法与自己通信");
x->show();
return;
}
mHandler->SetRemotePeerName(mRemoteName);
mCalling = true;
mHandler->CreateOffer();
}

View File

@ -98,7 +98,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEdit">
<property name="text">
<string>123</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">