no message
parent
5fb054e574
commit
7eb86f31bd
|
@ -97,7 +97,7 @@ int WebrtcHanlder::InitWebrtc()
|
|||
|
||||
webrtc::PeerConnectionInterface::RTCConfiguration config;
|
||||
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
|
||||
config.enable_dtls_srtp = true;
|
||||
config.enable_dtls_srtp = false;
|
||||
webrtc::PeerConnectionInterface::IceServer server;
|
||||
server.uri = "stun:stun.l.google.com:19302"; // stun服务器
|
||||
config.servers.push_back(server);
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
|
||||
void WebrtcHanlder::SetRemoteSdp(QString sdp)
|
||||
{
|
||||
qDebug()<<"recv" << sdp;
|
||||
qDebug()<<"SetRemoteSdp" << sdp;
|
||||
auto doc = QJsonDocument::fromJson(sdp.toUtf8());
|
||||
auto obj = doc.object();
|
||||
auto ssdp = obj["sdp"].toString();
|
||||
|
@ -219,6 +219,7 @@ void WebrtcHanlder::SetRemoteCandidate(QString scandidate)
|
|||
sdp_mlineindex = obj[kCandidateSdpMlineIndexName].toInt();
|
||||
sdp_mid = obj[kCandidateSdpMlineIndexName].toString().toStdString();
|
||||
sdps = obj[kCandidateSdpName].toString().toStdString();
|
||||
qDebug()<<"remote candidate"<<sdp_mlineindex<<sdp_mid.c_str()<<sdps.c_str();
|
||||
webrtc::SdpParseError error;
|
||||
std::unique_ptr<webrtc::IceCandidateInterface> candidate(
|
||||
webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdps, &error));
|
||||
|
@ -253,8 +254,13 @@ void WebrtcHanlder::OnSignalingChange(webrtc::PeerConnectionInterface::Signaling
|
|||
void WebrtcHanlder::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
|
||||
const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface> > &streams)
|
||||
{
|
||||
RTC_LOG(INFO) << __FUNCTION__ << " " << receiver->id();
|
||||
OnRemoteTrack(receiver->track().release());
|
||||
qDebug() << __FUNCTION__ << " " << receiver->id().c_str();
|
||||
auto srcs = receiver->GetSources();
|
||||
for (auto x : srcs){
|
||||
qDebug()<<"sources "<<x.source_id();
|
||||
}
|
||||
if (receiver->track().release()->kind() == webrtc::MediaStreamTrackInterface::kVideoKind)
|
||||
OnRemoteTrack(receiver->track().release());
|
||||
}
|
||||
|
||||
void WebrtcHanlder::OnRemoveTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver)
|
||||
|
@ -276,6 +282,8 @@ void WebrtcHanlder::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGat
|
|||
|
||||
void WebrtcHanlder::OnIceCandidate(const webrtc::IceCandidateInterface *candidate)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << " " <<candidate->sdp_mid().c_str()<< " " <<candidate->sdp_mline_index();
|
||||
|
||||
QJsonObject addr;
|
||||
addr.insert(kCandidateSdpMidName, candidate->sdp_mid().c_str());
|
||||
addr.insert(kCandidateSdpMlineIndexName,candidate->sdp_mline_index());
|
||||
|
@ -422,9 +430,8 @@ void MainWindow::on_track_add(webrtc::MediaStreamTrackInterface *data)
|
|||
auto* video_track = static_cast<webrtc::VideoTrackInterface*>(track);
|
||||
qDebug()<<"remote trackid is "<<video_track->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<webrtc::I420BufferInterface>&)),
|
||||
connect((VideoRenderer*)(remote_renderer_.get()),SIGNAL(UpdateFrame(rtc::scoped_refptr<webrtc::I420BufferInterface>&)),
|
||||
ui->openGLWidget,SLOT(CameraData(rtc::scoped_refptr<webrtc::I420BufferInterface> &)),
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
}
|
||||
|
@ -543,6 +550,7 @@ static void RawToBmp(unsigned char *pRawImage, int ImageHeight, int ImageWidth,
|
|||
|
||||
|
||||
}
|
||||
|
||||
void VideoRenderer::OnFrame(const webrtc::VideoFrame &video_frame)
|
||||
{
|
||||
{
|
||||
|
@ -552,7 +560,6 @@ void VideoRenderer::OnFrame(const webrtc::VideoFrame &video_frame)
|
|||
if (video_frame.rotation() != webrtc::kVideoRotation_0) {
|
||||
buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
|
||||
}
|
||||
SetSize(buffer->width(), buffer->height());
|
||||
RTC_DCHECK(image_ != NULL);
|
||||
// libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), buffer->DataU(),
|
||||
// buffer->StrideU(), buffer->DataV(), buffer->StrideV(),
|
||||
|
@ -561,16 +568,18 @@ void VideoRenderer::OnFrame(const webrtc::VideoFrame &video_frame)
|
|||
// 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: "<<i420_buffer_->width() << i420_buffer_->height();
|
||||
SetSize(i420_buffer_->width(), i420_buffer_->height());
|
||||
UpdateFrame(buffer);
|
||||
|
||||
// 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: "<<i420_buffer_->width() << i420_buffer_->height();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="text">
|
||||
<string>ws://127.0.0.1:9555/ws</string>
|
||||
<string>ws://192.168.5.192:9555/ws</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue