Files
platform-external-webrtc/test/peer_scenario/scenario_connection.cc
Guido Urdaneta ff7913204c Revert "Reland "Replace sigslot usages with robocaller library.""
This reverts commit c5f71087589b18bb4df1b78f2c452c4083edf2d9.

Reason for revert: Causes Chromium WPT Tests to fail, preventing rolls.

Sample failed run:
https://ci.chromium.org/p/chromium/builders/try/linux-rel/511995?

Sample logs:

STDERR: # Fatal error in: ../../third_party/webrtc/pc/peer_connection.cc, line 575
STDERR: # last system error: 0
STDERR: # Check failed: (signaling_thread())->IsCurrent()
STDERR: # Received signal 6
STDERR: #0 0x7f81d39e3de9 base::debug::CollectStackTrace()
STDERR: #1 0x7f81d38f9ca3 base::debug::StackTrace::StackTrace()
STDERR: #2 0x7f81d39e393b base::debug::(anonymous namespace)::StackDumpSignalHandler()
STDERR: #3 0x7f81c9054140 (/lib/x86_64-linux-gnu/libpthread-2.31.so+0x1413f)
STDERR: #4 0x7f81c8d72db1 gsignal
STDERR: #5 0x7f81c8d5c537 abort
STDERR: #6 0x7f81c7344032 rtc::webrtc_checks_impl::FatalLog()
STDERR: #7 0x7f81c722e5c0 webrtc::webrtc_function_impl::CallHelpers<>::CallInlineStorage<>()
STDERR: #8 0x7f81c7348d99 webrtc::robo_caller_impl::RoboCallerReceivers::Foreach()
STDERR: #9 0x7f81c72d6e8e webrtc::webrtc_function_impl::CallHelpers<>::CallInlineStorage<>()
STDERR: #10 0x7f81c7348d99 webrtc::robo_caller_impl::RoboCallerReceivers::Foreach()
STDERR: #11 0x7f81c71c6df3 webrtc::webrtc_function_impl::CallHelpers<>::CallInlineStorage<>()
STDERR: #12 0x7f81c7348d99 webrtc::robo_caller_impl::RoboCallerReceivers::Foreach()
STDERR: #13 0x7f81c73135bc rtc::OpenSSLStreamAdapter::ContinueSSL()
STDERR: #14 0x7f81c7312fd4 rtc::OpenSSLStreamAdapter::OnEvent()
STDERR: #15 0x7f81c71c30d9 cricket::StreamInterfaceChannel::OnPacketReceived()
STDERR: #16 0x7f81c71c640a cricket::DtlsTransport::OnReadPacket()
STDERR: #17 0x7f81c71cad61 cricket::P2PTransportChannel::OnReadPacket()
STDERR: #18 0x7f81c71bc90f cricket::Connection::OnReadPacket()
STDERR: #19 0x7f81c71e6255 cricket::UDPPort::HandleIncomingPacket()
STDERR: #20 0x7f81cd1f1bff blink::(anonymous namespace)::IpcPacketSocket::OnDataReceived()
STDERR: #21 0x7f81cd1f645d blink::P2PSocketClientImpl::DataReceived()
STDERR: #22 0x7f81cd50a16b network::mojom::blink::P2PSocketClientStubDispatch::Accept()
STDERR: #23 0x7f81d2b4f642 mojo::InterfaceEndpointClient::HandleValidatedMessage()
STDERR: #24 0x7f81d2b5304b mojo::MessageDispatcher::Accept()
STDERR: #25 0x7f81d2b50bb1 mojo::InterfaceEndpointClient::HandleIncomingMessage()
STDERR: #26 0x7f81d2b58a3a mojo::internal::MultiplexRouter::ProcessIncomingMessage()
STDERR: #27 0x7f81d2b57f7f mojo::internal::MultiplexRouter::Accept()
STDERR: #28 0x7f81d2b5304b mojo::MessageDispatcher::Accept()
STDERR: #29 0x7f81d2b48851 mojo::Connector::DispatchMessage()
STDERR: #30 0x7f81d2b492e7 mojo::Connector::ReadAllAvailableMessages()
STDERR: #31 0x7f81d2b490a3 mojo::Connector::OnHandleReadyInternal()
STDERR: #32 0x7f81d2b498f0 mojo::SimpleWatcher::DiscardReadyState()
STDERR: #33 0x7f81d2d0e67a mojo::SimpleWatcher::OnHandleReady()
STDERR: #34 0x7f81d2d0eb2b base::internal::Invoker<>::RunOnce()
STDERR: #35 0x7f81d397f85b base::TaskAnnotator::RunTask()
STDERR: #36 0x7f81d399a04c base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl()
STDERR: #37 0x7f81d3999c78 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
STDERR: #38 0x7f81d391fe64 base::MessagePumpDefault::Run()
STDERR: #39 0x7f81d399a8dc base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run()
STDERR: #40 0x7f81d395ae55 base::RunLoop::Run()
STDERR: #41 0x7f81d39c87f2 base::Thread::Run()




Original change's description:
> Reland "Replace sigslot usages with robocaller library."
>
> This is a reland of 40261c3663fe316cfe40262c59cee993165ccf63
>
> Note: Instead of changing the type of JsepTransportController->SignalSSLHandshakeError
> added a new member with a different name and used it in webrtc code.
> After this change do two more follow up CLs to completely remove the old code
> from google3.
>
> Original change's description:
> > Replace sigslot usages with robocaller library.
> >
> > - Replace all the top level signals from jsep_transport_controller.
> > - There are still sigslot usages in this file so keep the inheritance
> >   and that is the reason for not having a binary size gain in this CL.
> >
> > Bug: webrtc:11943
> > Change-Id: I249d3b9710783aef70ba273e082ceeafe3056898
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185540
> > Commit-Queue: Lahiru Ginnaliya Gamathige <glahiru@webrtc.org>
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#32321}
>
> Bug: webrtc:11943
> Change-Id: Ia07394ee395f94836f6b576c3a97d119a7678e1a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186946
> Commit-Queue: Lahiru Ginnaliya Gamathige <glahiru@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32359}

TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,glahiru@webrtc.org

Change-Id: I6bce1775d10758ac4a9d05b855f473dd70bd9815
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11943
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/187487
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32372}
2020-10-09 18:07:56 +00:00

239 lines
9.6 KiB
C++

/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/peer_scenario/scenario_connection.h"
#include "absl/memory/memory.h"
#include "media/base/rtp_utils.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "p2p/client/basic_port_allocator.h"
#include "pc/jsep_transport_controller.h"
#include "pc/rtp_transport_internal.h"
#include "pc/session_description.h"
namespace webrtc {
class ScenarioIceConnectionImpl : public ScenarioIceConnection,
public sigslot::has_slots<>,
private JsepTransportController::Observer,
private RtpPacketSinkInterface {
public:
ScenarioIceConnectionImpl(test::NetworkEmulationManagerImpl* net,
IceConnectionObserver* observer);
~ScenarioIceConnectionImpl() override;
void SendRtpPacket(rtc::ArrayView<const uint8_t> packet_view) override;
void SendRtcpPacket(rtc::ArrayView<const uint8_t> packet_view) override;
void SetRemoteSdp(SdpType type, const std::string& remote_sdp) override;
void SetLocalSdp(SdpType type, const std::string& local_sdp) override;
EmulatedEndpoint* endpoint() override { return endpoint_; }
const cricket::TransportDescription& transport_description() const override {
return transport_description_;
}
private:
JsepTransportController::Config CreateJsepConfig();
bool OnTransportChanged(
const std::string& mid,
RtpTransportInternal* rtp_transport,
rtc::scoped_refptr<DtlsTransport> dtls_transport,
DataChannelTransportInterface* data_channel_transport) override;
void OnRtpPacket(const RtpPacketReceived& packet) override;
void OnCandidates(const std::string& mid,
const std::vector<cricket::Candidate>& candidates);
IceConnectionObserver* const observer_;
EmulatedEndpoint* const endpoint_;
EmulatedNetworkManagerInterface* const manager_;
rtc::Thread* const signaling_thread_;
rtc::Thread* const network_thread_;
rtc::scoped_refptr<rtc::RTCCertificate> const certificate_
RTC_GUARDED_BY(network_thread_);
cricket::TransportDescription const transport_description_
RTC_GUARDED_BY(signaling_thread_);
std::unique_ptr<cricket::BasicPortAllocator> port_allocator_
RTC_GUARDED_BY(network_thread_);
std::unique_ptr<JsepTransportController> jsep_controller_;
RtpTransportInternal* rtp_transport_ RTC_GUARDED_BY(network_thread_) =
nullptr;
std::unique_ptr<SessionDescriptionInterface> remote_description_
RTC_GUARDED_BY(signaling_thread_);
std::unique_ptr<SessionDescriptionInterface> local_description_
RTC_GUARDED_BY(signaling_thread_);
};
std::unique_ptr<ScenarioIceConnection> ScenarioIceConnection::Create(
webrtc::test::NetworkEmulationManagerImpl* net,
IceConnectionObserver* observer) {
return std::make_unique<ScenarioIceConnectionImpl>(net, observer);
}
ScenarioIceConnectionImpl::ScenarioIceConnectionImpl(
test::NetworkEmulationManagerImpl* net,
IceConnectionObserver* observer)
: observer_(observer),
endpoint_(net->CreateEndpoint(EmulatedEndpointConfig())),
manager_(net->CreateEmulatedNetworkManagerInterface({endpoint_})),
signaling_thread_(rtc::Thread::Current()),
network_thread_(manager_->network_thread()),
certificate_(rtc::RTCCertificate::Create(
rtc::SSLIdentity::Create("", ::rtc::KT_DEFAULT))),
transport_description_(
/*transport_options*/ {},
rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH),
rtc::CreateRandomString(cricket::ICE_PWD_LENGTH),
cricket::IceMode::ICEMODE_FULL,
cricket::ConnectionRole::CONNECTIONROLE_PASSIVE,
rtc::SSLFingerprint::CreateFromCertificate(*certificate_.get())
.get()),
port_allocator_(
new cricket::BasicPortAllocator(manager_->network_manager())),
jsep_controller_(
new JsepTransportController(signaling_thread_,
network_thread_,
port_allocator_.get(),
/*async_resolver_factory*/ nullptr,
CreateJsepConfig())) {
network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
RTC_DCHECK_RUN_ON(network_thread_);
uint32_t flags = cricket::PORTALLOCATOR_DISABLE_TCP;
port_allocator_->set_flags(port_allocator_->flags() | flags);
port_allocator_->Initialize();
RTC_CHECK(port_allocator_->SetConfiguration(/*stun_servers*/ {},
/*turn_servers*/ {}, 0,
webrtc::NO_PRUNE));
jsep_controller_->SetLocalCertificate(certificate_);
});
}
ScenarioIceConnectionImpl::~ScenarioIceConnectionImpl() {
network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
RTC_DCHECK_RUN_ON(network_thread_);
jsep_controller_.reset();
port_allocator_.reset();
rtp_transport_ = nullptr;
});
}
JsepTransportController::Config ScenarioIceConnectionImpl::CreateJsepConfig() {
JsepTransportController::Config config;
config.transport_observer = this;
config.bundle_policy =
PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle;
config.rtcp_handler = [this](const rtc::CopyOnWriteBuffer& packet,
int64_t packet_time_us) {
RTC_DCHECK_RUN_ON(network_thread_);
observer_->OnPacketReceived(packet);
};
return config;
}
void ScenarioIceConnectionImpl::SendRtpPacket(
rtc::ArrayView<const uint8_t> packet_view) {
rtc::CopyOnWriteBuffer packet(packet_view.data(), packet_view.size(),
::cricket::kMaxRtpPacketLen);
network_thread_->PostTask(
RTC_FROM_HERE, [this, packet = std::move(packet)]() mutable {
RTC_DCHECK_RUN_ON(network_thread_);
if (rtp_transport_ != nullptr)
rtp_transport_->SendRtpPacket(&packet, rtc::PacketOptions(),
cricket::PF_SRTP_BYPASS);
});
}
void ScenarioIceConnectionImpl::SendRtcpPacket(
rtc::ArrayView<const uint8_t> packet_view) {
rtc::CopyOnWriteBuffer packet(packet_view.data(), packet_view.size(),
::cricket::kMaxRtpPacketLen);
network_thread_->PostTask(
RTC_FROM_HERE, [this, packet = std::move(packet)]() mutable {
RTC_DCHECK_RUN_ON(network_thread_);
if (rtp_transport_ != nullptr)
rtp_transport_->SendRtcpPacket(&packet, rtc::PacketOptions(),
cricket::PF_SRTP_BYPASS);
});
}
void ScenarioIceConnectionImpl::SetRemoteSdp(SdpType type,
const std::string& remote_sdp) {
RTC_DCHECK_RUN_ON(signaling_thread_);
remote_description_ = webrtc::CreateSessionDescription(type, remote_sdp);
jsep_controller_->SignalIceCandidatesGathered.connect(
this, &ScenarioIceConnectionImpl::OnCandidates);
auto res = jsep_controller_->SetRemoteDescription(
remote_description_->GetType(), remote_description_->description());
RTC_CHECK(res.ok()) << res.message();
RtpDemuxerCriteria criteria;
for (const auto& content : remote_description_->description()->contents()) {
if (content.media_description()->as_audio()) {
for (const auto& codec :
content.media_description()->as_audio()->codecs()) {
criteria.payload_types.insert(codec.id);
}
}
if (content.media_description()->as_video()) {
for (const auto& codec :
content.media_description()->as_video()->codecs()) {
criteria.payload_types.insert(codec.id);
}
}
}
network_thread_->PostTask(RTC_FROM_HERE, [this, criteria]() {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(rtp_transport_);
rtp_transport_->RegisterRtpDemuxerSink(criteria, this);
});
}
void ScenarioIceConnectionImpl::SetLocalSdp(SdpType type,
const std::string& local_sdp) {
RTC_DCHECK_RUN_ON(signaling_thread_);
local_description_ = webrtc::CreateSessionDescription(type, local_sdp);
auto res = jsep_controller_->SetLocalDescription(
local_description_->GetType(), local_description_->description());
RTC_CHECK(res.ok()) << res.message();
jsep_controller_->MaybeStartGathering();
}
bool ScenarioIceConnectionImpl::OnTransportChanged(
const std::string& mid,
RtpTransportInternal* rtp_transport,
rtc::scoped_refptr<DtlsTransport> dtls_transport,
DataChannelTransportInterface* data_channel_transport) {
RTC_DCHECK_RUN_ON(network_thread_);
if (rtp_transport == nullptr) {
rtp_transport_->UnregisterRtpDemuxerSink(this);
} else {
RTC_DCHECK(rtp_transport_ == nullptr || rtp_transport_ == rtp_transport);
if (rtp_transport_ != rtp_transport) {
rtp_transport_ = rtp_transport;
}
RtpDemuxerCriteria criteria;
criteria.mid = mid;
rtp_transport_->RegisterRtpDemuxerSink(criteria, this);
}
return true;
}
void ScenarioIceConnectionImpl::OnRtpPacket(const RtpPacketReceived& packet) {
RTC_DCHECK_RUN_ON(network_thread_);
observer_->OnPacketReceived(packet.Buffer());
}
void ScenarioIceConnectionImpl::OnCandidates(
const std::string& mid,
const std::vector<cricket::Candidate>& candidates) {
RTC_DCHECK_RUN_ON(signaling_thread_);
observer_->OnIceCandidates(mid, candidates);
}
} // namespace webrtc