From 5fb054e574c1328f63ddf64970dea54b7a89f03a Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Sat, 30 Oct 2021 23:20:58 +0800 Subject: [PATCH] no message --- client/webrtc_demo/src/MyCapturer.cpp | 92 ++++++++++++++- client/webrtc_demo/src/MyCapturer.h | 2 +- client/webrtc_demo/src/cplaywidget.cpp | 20 +++- client/webrtc_demo/src/cplaywidget.h | 5 +- client/webrtc_demo/src/main.cpp | 3 + client/webrtc_demo/src/mainwindow.cpp | 151 +++++++++++++++++++++--- client/webrtc_demo/src/mainwindow.h | 61 ++++++---- client/webrtc_demo/webrtc_demo.pro | 2 +- client/webrtc_demo/webrtc_demo.pro.user | 2 +- 9 files changed, 282 insertions(+), 56 deletions(-) diff --git a/client/webrtc_demo/src/MyCapturer.cpp b/client/webrtc_demo/src/MyCapturer.cpp index 80a6b68..d49b812 100644 --- a/client/webrtc_demo/src/MyCapturer.cpp +++ b/client/webrtc_demo/src/MyCapturer.cpp @@ -1,6 +1,8 @@ #include "MyCapturer.h" #include "rtc_base/thread.h" #include +#include +#include MyCapturer::MyCapturer() { @@ -30,6 +32,85 @@ absl::optional MyCapturer::needs_denoising() const { return false; } +static void RawToBmp(unsigned char *pRawImage, int ImageHeight, int ImageWidth, int bitcount,std::string filePath) +{ + + unsigned char *imgData; + LONGLONG dataSizePerLine = ((ImageWidth * bitcount + 31) >> 5) << 2; + + + int plaLen = bitcount <= 8 ? 2 << (bitcount - 1) : 0; + std::cout << "plaLen = " << plaLen << endl; + int headerLength = 14 + 40 + plaLen * 4; + LONGLONG dataLength = dataSizePerLine*(ImageHeight - 1) + ImageWidth*bitcount / 8; + std::cout << "headerLength = " << headerLength << endl; + std::cout << "dataLength = " << dataLength << endl; + short int biPlanes = 1; + char bm[2] = { 'B', 'M' }; + long bfReserved1 = 0; + LONGLONG bfSize = headerLength + dataLength; + long biHeight = ImageHeight*(-1); + long bfOffBits = headerLength; + long bisize = 40; + long biCompression = 0; LONGLONG biSizeImage = dataLength; + long biXPelsPerMeter = 0, biYPelsPerMeter = 0; + long biClrUsed = plaLen; int biClrImportant = 0; + imgData = new unsigned char[headerLength + dataLength]; + memset(imgData, 0, headerLength + dataLength); + memcpy(imgData, &bm, 2); + memcpy(imgData + 2, &bfSize, 4); + memcpy(imgData + 6, &bfReserved1, 4); + memcpy(imgData + 10, &bfOffBits, 4); + memcpy(imgData + 14, &bisize, 4); + memcpy(imgData + 18, &ImageWidth, 4); + memcpy(imgData + 22, &biHeight, 4); + memcpy(imgData + 26, &biPlanes, 2); + memcpy(imgData + 28, &bitcount, 2); + memcpy(imgData + 30, &biCompression, 4); + memcpy(imgData + 34, &biSizeImage, 4); + memcpy(imgData + 38, &biXPelsPerMeter, 4); + memcpy(imgData + 42, &biYPelsPerMeter, 4); + memcpy(imgData + 46, &biClrUsed, 4); + memcpy(imgData + 50, &biCompression, 4); + + if (headerLength > 54) { + if (bitcount == 1) { + for (char i = 0; i < 2; i++) { + char gray[4] = { char(i * 255), char(i * 255), char(i * 255), char(255) }; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + else if (bitcount == 4) { + for (char i = 0; i < 16; i++) { + char gray[4] = { char(i * 17), char(i * 17), char(i * 17), char(255) }; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + else if (bitcount == 8) { + for (int i = 0; i < 255; i++) { + char gray[4] = { char(i), char(i), char(i), char(255)}; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + } + + + int dw = ImageWidth*bitcount / 8; + for (int i = 0; i < ImageHeight; i++) + { + memcpy(imgData + headerLength + dataSizePerLine*i, pRawImage + dw*i, dw); + } + + + + FILE *fp_bmp; + fp_bmp = fopen(filePath.c_str()/*"temp.bmp"*/, "wb"); + fwrite((void*)imgData, bfSize, 1, fp_bmp); + fclose(fp_bmp); + + +} + void MyCapturer::OnCaptureResult(webrtc::DesktopCapturer::Result result, std::unique_ptr frame) { if (result != webrtc::DesktopCapturer::Result::SUCCESS) @@ -43,11 +124,12 @@ void MyCapturer::OnCaptureResult(webrtc::DesktopCapturer::Result result, 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); + 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)); } diff --git a/client/webrtc_demo/src/MyCapturer.h b/client/webrtc_demo/src/MyCapturer.h index 96a4da1..b7c976e 100644 --- a/client/webrtc_demo/src/MyCapturer.h +++ b/client/webrtc_demo/src/MyCapturer.h @@ -10,7 +10,7 @@ #include "rtc_base/thread.h" #include "media/base/adapted_video_track_source.h" #include "rtc_base/message_handler.h" - +#include "libyuv.h" class MyCapturer : public rtc::AdaptedVideoTrackSource, public rtc::MessageHandler, diff --git a/client/webrtc_demo/src/cplaywidget.cpp b/client/webrtc_demo/src/cplaywidget.cpp index 1838a2e..4efa0ab 100644 --- a/client/webrtc_demo/src/cplaywidget.cpp +++ b/client/webrtc_demo/src/cplaywidget.cpp @@ -90,6 +90,8 @@ void CPlayWidget::OnPaintData(const rtc::scoped_refptr &buffer) +void CPlayWidget::CameraData( rtc::scoped_refptr &buffer) { m_buffer = buffer; - memcpy(this->m_pBufYuv420p,buffer->GetI420()->DataY(),640*480); - memcpy(this->m_pBufYuv420p + 640*480 ,buffer->GetI420()->DataU(),640*480/4); - memcpy(this->m_pBufYuv420p+ 640*480 + 640*480/4,buffer->GetI420()->DataV(),640*480/4); + memcpy(this->m_pBufYuv420p,buffer->GetI420()->DataY(),2560*1600); + memcpy(this->m_pBufYuv420p + 2560*1600 ,buffer->GetI420()->DataU(),2560*1600/4); + memcpy(this->m_pBufYuv420p+ 2560*1600+ 2560*1600/4,buffer->GetI420()->DataV(),2560*1600/4); update(); - return 0; } int CPlayWidget::OnCameraData(uint8_t *p) @@ -137,12 +138,19 @@ int CPlayWidget::OnCameraData(uint8_t *p) return 0; } +int CPlayWidget::OnCameraDataRgb(uint8_t *p) +{ + memcpy(m_pBufRgb32,p,this->m_nVideoH*this->m_nVideoW*4); + update(); + return 0; +} + 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 *4]; + m_pBufRgb32 = new uint8_t[width * height *8]; } if(mType == TYPE_YUV420P){ m_pBufYuv420p = new uint8_t[width * height *3/2]; diff --git a/client/webrtc_demo/src/cplaywidget.h b/client/webrtc_demo/src/cplaywidget.h index ac8c174..41c07e4 100644 --- a/client/webrtc_demo/src/cplaywidget.h +++ b/client/webrtc_demo/src/cplaywidget.h @@ -25,8 +25,10 @@ class CPlayWidget:public QOpenGLWidget,protected QOpenGLFunctions { Q_OBJECT +signals: public slots: void OnPaintData(const rtc::scoped_refptr &buffer); + void CameraData(rtc::scoped_refptr &buffer); public: typedef enum{ @@ -37,8 +39,9 @@ public: CPlayWidget(QWidget* parent); ~CPlayWidget(); int SetDataType(IMG_TYPE); - int OnCameraData(rtc::scoped_refptr &buffer); int OnCameraData(uint8_t *); + int OnCameraDataRgb(uint8_t *); + int SetImgSize(uint32_t width,uint32_t ); protected: QTimer tm; diff --git a/client/webrtc_demo/src/main.cpp b/client/webrtc_demo/src/main.cpp index 1b66f9b..db095e7 100644 --- a/client/webrtc_demo/src/main.cpp +++ b/client/webrtc_demo/src/main.cpp @@ -96,6 +96,9 @@ void InitCustomMetaType(){ qRegisterMetaType>("rtc::scoped_refptr&"); qRegisterMetaType("webrtc::VideoTrackInterface*"); qRegisterMetaType("webrtc::MediaStreamTrackInterface*"); + qRegisterMetaType("uint8_t*"); + qRegisterMetaType("uint64_t"); + } int main(int argc, char *argv[]) diff --git a/client/webrtc_demo/src/mainwindow.cpp b/client/webrtc_demo/src/mainwindow.cpp index ed443a6..fe7f759 100644 --- a/client/webrtc_demo/src/mainwindow.cpp +++ b/client/webrtc_demo/src/mainwindow.cpp @@ -7,6 +7,9 @@ #include #include #include +#include "MyCapturer.h" +#include + const char kCandidateSdpMidName[] = "sdpMid"; const char kCandidateSdpMlineIndexName[] = "sdpMLineIndex"; @@ -20,16 +23,19 @@ MainWindow::MainWindow(QWidget *parent) ,mModel(nullptr) ,mCalling(false) { + mHandler->SetParent(this); ui->setupUi(this); - ui->openGLWidget->SetImgSize(640,480); + ui->openGLWidget->SetDataType(CPlayWidget::TYPE_I420); + ui->openGLWidget->SetImgSize(2560,1600); ui->openGLWidget->show(); - mHandler->InitWebrtc(); TCHAR username[UNLEN + 1]; DWORD size = UNLEN + 1; GetUserName((TCHAR*)username, &size); mModel = new QStandardItemModel(this); ui->treeView->setModel(mModel); + + mHandler->InitWebrtc(); connect(ui->treeView,SIGNAL(doubleClicked(QModelIndex)), this,SLOT(itemClicked(QModelIndex))); connect((WebrtcHanlder*)(mHandler.get()),SIGNAL(OnOfferSdp(QString)), @@ -38,7 +44,7 @@ MainWindow::MainWindow(QWidget *parent) this,SLOT(on_track_add(webrtc::MediaStreamTrackInterface*))); connect((WebrtcHanlder*)(mHandler.get()),SIGNAL(OnLocalTrack(webrtc::VideoTrackInterface* )), this,SLOT(on_local_track_add(webrtc::VideoTrackInterface* ))); - mHandler.get()->setParent(this); + } MainWindow::~MainWindow() @@ -46,15 +52,19 @@ MainWindow::~MainWindow() delete ui; } +CPlayWidget *MainWindow::OpenglWidget() +{ + return this->ui->openGLWidget; +} + void MainWindow::OnUpdateFrame( rtc::scoped_refptr& buffer) { qDebug()<<"1234"; - ui->openGLWidget->OnCameraData(buffer); +// ui->openGLWidget->OnCameraData(buffer); } void MainWindow::OnUpdateFrame1(uint8_t *dat) { - qDebug()<<"4321"; ui->openGLWidget->OnCameraData(dat); } @@ -101,7 +111,10 @@ int WebrtcHanlder::InitWebrtc() x->show(); exit(0); } - + if (!m_peer_connection_->GetSenders().empty()) { + return -1; // Already added tracks. + } + // add audio tracks rtc::scoped_refptr audio_track( m_peer_connection_factory_->CreateAudioTrack( kAudioLabel, m_peer_connection_factory_->CreateAudioSource( @@ -109,7 +122,7 @@ int WebrtcHanlder::InitWebrtc() auto result_or_error = m_peer_connection_->AddTrack(audio_track, {kStreamId}); if (!result_or_error.ok()) { - qDebug() << "Failed to add audio track to PeerConnection: " + RTC_LOG(LS_ERROR) << "Failed to add audio track to PeerConnection: " << result_or_error.error().message(); } @@ -118,17 +131,16 @@ int WebrtcHanlder::InitWebrtc() video_device->startCapturer(); rtc::scoped_refptr video_track_( m_peer_connection_factory_->CreateVideoTrack(kVideoLabel, video_device)); -// main_wnd_->StartLocalRenderer(video_track_); -// mParent->on_local_track_add(video_track_); + auto p = video_device.get(); + result_or_error = m_peer_connection_->AddTrack(video_track_, { kStreamId }); if (!result_or_error.ok()) { - qDebug() << "Failed to add video track to PeerConnection: " + RTC_LOG(LS_ERROR) << "Failed to add video track to PeerConnection: " << result_or_error.error().message(); } } else { - qDebug()<< "OpenVideoCaptureDevice failed"; + RTC_LOG(LS_ERROR) << "OpenVideoCaptureDevice failed"; } - } @@ -237,7 +249,7 @@ void WebrtcHanlder::OnSignalingChange(webrtc::PeerConnectionInterface::Signaling } - +// 接受者创建track成功 void WebrtcHanlder::OnAddTrack(rtc::scoped_refptr receiver, const std::vector > &streams) { @@ -310,7 +322,7 @@ void WebrtcHanlder::OnFailure(webrtc::RTCError error) void MainWindow::on_pushButton_clicked() { - mSignalClient = new SignalClient(QUrl("ws://127.0.0.1:9555/ws"),true,this); + mSignalClient = new SignalClient(QUrl(ui->lineEdit_2->text()),true,this); connect(this->mSignalClient,SIGNAL(connected()),this,SLOT(signal_conneted())); connect(this->mSignalClient,SIGNAL(response(int ,QJsonObject)), this,SLOT( signal_response(int,QJsonObject))); @@ -386,6 +398,7 @@ void MainWindow::itemClicked(QModelIndex index) { if(!mSignalClient->Connected()){ qDebug()<<"请先连接信令服务"; + return; } mHandler->CreateOffer(); qDebug()<item(index.row())->text(); @@ -407,7 +420,13 @@ void MainWindow::on_track_add(webrtc::MediaStreamTrackInterface *data) auto* track = reinterpret_cast(data); if (track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { auto* video_track = static_cast(track); + qDebug()<<"remote trackid is "<id().c_str(); remote_renderer_.reset(new VideoRenderer( 1, 1, video_track)); + auto p = remote_renderer_.get(); + + connect((VideoRenderer*)(p),SIGNAL(UpdateFrame(rtc::scoped_refptr&)), + ui->openGLWidget,SLOT(CameraData(rtc::scoped_refptr &)), + Qt::ConnectionType::QueuedConnection); } track->Release(); } @@ -418,6 +437,11 @@ void MainWindow::on_local_track_add(webrtc::VideoTrackInterface* data) local_renderer_.reset(new VideoRenderer( 1, 1, data)); } +void MainWindow::rgba_data(uint8_t *buffer, uint64_t) +{ + ui->openGLWidget->OnCameraDataRgb(buffer); +} + VideoRenderer::VideoRenderer(int width, int height, webrtc::VideoTrackInterface *track_to_render) : rendered_track_(track_to_render) @@ -441,9 +465,86 @@ VideoRenderer::~VideoRenderer() ::DeleteCriticalSection(&buffer_lock_); } +static void RawToBmp(unsigned char *pRawImage, int ImageHeight, int ImageWidth, int bitcount,std::string filePath) +{ + + unsigned char *imgData; + LONGLONG dataSizePerLine = ((ImageWidth * bitcount + 31) >> 5) << 2; + + + int plaLen = bitcount <= 8 ? 2 << (bitcount - 1) : 0; + std::cout << "plaLen = " << plaLen << endl; + int headerLength = 14 + 40 + plaLen * 4; + LONGLONG dataLength = dataSizePerLine*(ImageHeight - 1) + ImageWidth*bitcount / 8; + std::cout << "headerLength = " << headerLength << endl; + std::cout << "dataLength = " << dataLength << endl; + short int biPlanes = 1; + char bm[2] = { 'B', 'M' }; + long bfReserved1 = 0; + LONGLONG bfSize = headerLength + dataLength; + long biHeight = ImageHeight*(-1); + long bfOffBits = headerLength; + long bisize = 40; + long biCompression = 0; LONGLONG biSizeImage = dataLength; + long biXPelsPerMeter = 0, biYPelsPerMeter = 0; + long biClrUsed = plaLen; int biClrImportant = 0; + imgData = new unsigned char[headerLength + dataLength]; + memset(imgData, 0, headerLength + dataLength); + memcpy(imgData, &bm, 2); + memcpy(imgData + 2, &bfSize, 4); + memcpy(imgData + 6, &bfReserved1, 4); + memcpy(imgData + 10, &bfOffBits, 4); + memcpy(imgData + 14, &bisize, 4); + memcpy(imgData + 18, &ImageWidth, 4); + memcpy(imgData + 22, &biHeight, 4); + memcpy(imgData + 26, &biPlanes, 2); + memcpy(imgData + 28, &bitcount, 2); + memcpy(imgData + 30, &biCompression, 4); + memcpy(imgData + 34, &biSizeImage, 4); + memcpy(imgData + 38, &biXPelsPerMeter, 4); + memcpy(imgData + 42, &biYPelsPerMeter, 4); + memcpy(imgData + 46, &biClrUsed, 4); + memcpy(imgData + 50, &biCompression, 4); + + if (headerLength > 54) { + if (bitcount == 1) { + for (char i = 0; i < 2; i++) { + char gray[4] = { char(i * 255), char(i * 255), char(i * 255), char(255) }; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + else if (bitcount == 4) { + for (char i = 0; i < 16; i++) { + char gray[4] = { char(i * 17), char(i * 17), char(i * 17), char(255) }; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + else if (bitcount == 8) { + for (int i = 0; i < 255; i++) { + char gray[4] = { char(i), char(i), char(i), char(255)}; + memcpy(imgData + 54 + 4 * i, gray, 4); + } + } + } + + + int dw = ImageWidth*bitcount / 8; + for (int i = 0; i < ImageHeight; i++) + { + memcpy(imgData + headerLength + dataSizePerLine*i, pRawImage + dw*i, dw); + } + + + + FILE *fp_bmp; + fp_bmp = fopen(filePath.c_str()/*"temp.bmp"*/, "wb"); + fwrite((void*)imgData, bfSize, 1, fp_bmp); + fclose(fp_bmp); + + +} void VideoRenderer::OnFrame(const webrtc::VideoFrame &video_frame) { - qDebug()<<"onframe"; { AutoLock lock(this); rtc::scoped_refptr buffer( @@ -452,13 +553,25 @@ void VideoRenderer::OnFrame(const webrtc::VideoFrame &video_frame) buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation()); } SetSize(buffer->width(), buffer->height()); - RTC_DCHECK(image_.get() != NULL); - qDebug()<width() << buffer->height(); + RTC_DCHECK(image_ != NULL); // libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), buffer->DataU(), // buffer->StrideU(), buffer->DataV(), buffer->StrideV(), -// image_.get(), +// image_, // bmi_.bmiHeader.biWidth * bmi_.bmiHeader.biBitCount / 8, // buffer->width(), buffer->height()); +// rgbadata(image_, +// (uint64_t)(buffer->width()*buffer->height()*4)); + //UpdateFrame(buffer); + auto i420_buffer_ = video_frame.video_frame_buffer()->ToI420(); + auto type = video_frame.video_frame_buffer()->type(); + libyuv::I420ToARGB(i420_buffer_->DataY(), i420_buffer_->StrideY(), i420_buffer_->DataU(), + i420_buffer_->StrideU(), i420_buffer_->DataV(), i420_buffer_->StrideV(), + image_, + i420_buffer_->width()*4, + i420_buffer_->width(), i420_buffer_->height()); + RawToBmp(image_,i420_buffer_->height(),i420_buffer_->width(),32,"d://sss2.bmp"); + qDebug()<<"local size: "<width() << i420_buffer_->height(); + } } @@ -472,5 +585,5 @@ void VideoRenderer::SetSize(int width, int height) bmi_.bmiHeader.biHeight = -height; bmi_.bmiHeader.biSizeImage = width * height * (bmi_.bmiHeader.biBitCount >> 3); - image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); + image_ = new uint8_t[bmi_.bmiHeader.biSizeImage]; } diff --git a/client/webrtc_demo/src/mainwindow.h b/client/webrtc_demo/src/mainwindow.h index 3d79ac2..273c14e 100644 --- a/client/webrtc_demo/src/mainwindow.h +++ b/client/webrtc_demo/src/mainwindow.h @@ -29,44 +29,53 @@ #include "api/video/i420_buffer.h" #include "signal_client.h" #include +#include "cplaywidget.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE -class VideoRenderer : public rtc::VideoSinkInterface { +class VideoRenderer : public QObject, + public rtc::VideoSinkInterface - public: - VideoRenderer( +{ +Q_OBJECT +public: + VideoRenderer( int width, int height, webrtc::VideoTrackInterface* track_to_render); - virtual ~VideoRenderer(); + virtual ~VideoRenderer(); - void Lock() { ::EnterCriticalSection(&buffer_lock_); } + void Lock() { ::EnterCriticalSection(&buffer_lock_); } - void Unlock() { ::LeaveCriticalSection(&buffer_lock_); } + void Unlock() { ::LeaveCriticalSection(&buffer_lock_); } - // VideoSinkInterface implementation - void OnFrame(const webrtc::VideoFrame& frame) override; + // VideoSinkInterface implementation + void OnFrame(const webrtc::VideoFrame& frame) override; - const BITMAPINFO& bmi() const { return bmi_; } - const uint8_t* image() const { return image_.get(); } + const BITMAPINFO& bmi() const { return bmi_; } + const uint8_t* image() const { return image_; } - protected: - void SetSize(int width, int height); - enum { - SET_SIZE, - RENDER_FRAME, - }; +signals: + void rgbadata(uint8_t *data,uint64_t len); + void UpdateFrame(rtc::scoped_refptr& buffer); - HWND wnd_; - BITMAPINFO bmi_; - std::unique_ptr image_; - CRITICAL_SECTION buffer_lock_; - rtc::scoped_refptr rendered_track_; +protected: + void SetSize(int width, int height); + + enum { + SET_SIZE, + RENDER_FRAME, + }; + + HWND wnd_; + BITMAPINFO bmi_; + uint8_t* image_; + CRITICAL_SECTION buffer_lock_; + rtc::scoped_refptr rendered_track_; }; // A little helper class to make sure we always to proper locking and @@ -86,6 +95,9 @@ class WebrtcHanlder :public QObject, public webrtc::PeerConnectionObserver, public webrtc::CreateSessionDescriptionObserver{ Q_OBJECT + +public: + signals: void OnOfferSdp(QString); void OnAnswerSdp(QString); @@ -101,6 +113,7 @@ public: void SetRemoteCandidate(QString); void SetParent(MainWindow *p); void CreateAnwer(); + protected: ~WebrtcHanlder(); // @@ -140,8 +153,12 @@ class MainWindow :public QMainWindow { Q_OBJECT public: + Ui::MainWindow *ui; + MainWindow(QWidget *parent = nullptr); ~MainWindow(); + + CPlayWidget* OpenglWidget(); protected: public slots: @@ -157,9 +174,9 @@ public slots: void on_local_sdp(QString); void on_track_add(webrtc::MediaStreamTrackInterface*); void on_local_track_add(webrtc::VideoTrackInterface* ); + void rgba_data(uint8_t *,uint64_t ); private: - Ui::MainWindow *ui; rtc::scoped_refptr mHandler; SignalClient *mSignalClient; QStandardItemModel *mModel; diff --git a/client/webrtc_demo/webrtc_demo.pro b/client/webrtc_demo/webrtc_demo.pro index 6efb41d..7b3a0fc 100644 --- a/client/webrtc_demo/webrtc_demo.pro +++ b/client/webrtc_demo/webrtc_demo.pro @@ -18,7 +18,7 @@ DEFINES += QT_DEPRECATED_WARNINGS NOMINMAX WEBRTC_WIN NOMINMAX WIN32_LEAN_AND_ME INCLUDEPATH += third/include/ -LIBS += -L$$PWD/third/lib libwebrtc.lib ole32.lib oleaut32.lib strmiids.lib +LIBS += -L$$PWD/third/lib libwebrtc.lib ole32.lib oleaut32.lib strmiids.lib yuv.lib SOURCES += \ src/MyCapturer.cpp \ diff --git a/client/webrtc_demo/webrtc_demo.pro.user b/client/webrtc_demo/webrtc_demo.pro.user index 33ddd4d..dcdfa67 100644 --- a/client/webrtc_demo/webrtc_demo.pro.user +++ b/client/webrtc_demo/webrtc_demo.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId