From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- third_party/libwebrtc/api/ice_transport_factory.cc | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 third_party/libwebrtc/api/ice_transport_factory.cc (limited to 'third_party/libwebrtc/api/ice_transport_factory.cc') diff --git a/third_party/libwebrtc/api/ice_transport_factory.cc b/third_party/libwebrtc/api/ice_transport_factory.cc new file mode 100644 index 0000000000..e88ac183fa --- /dev/null +++ b/third_party/libwebrtc/api/ice_transport_factory.cc @@ -0,0 +1,67 @@ +/* + * Copyright 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 "api/ice_transport_factory.h" + +#include +#include + +#include "api/make_ref_counted.h" +#include "p2p/base/ice_transport_internal.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/p2p_transport_channel.h" +#include "p2p/base/port_allocator.h" +#include "rtc_base/thread.h" + +namespace webrtc { + +namespace { + +// This implementation of IceTransportInterface is used in cases where +// the only reference to the P2PTransport will be through this class. +// It must be constructed, accessed and destroyed on the signaling thread. +class IceTransportWithTransportChannel : public IceTransportInterface { + public: + IceTransportWithTransportChannel( + std::unique_ptr internal) + : internal_(std::move(internal)) {} + + ~IceTransportWithTransportChannel() override { + RTC_DCHECK_RUN_ON(&thread_checker_); + } + + cricket::IceTransportInternal* internal() override { + RTC_DCHECK_RUN_ON(&thread_checker_); + return internal_.get(); + } + + private: + const SequenceChecker thread_checker_{}; + const std::unique_ptr internal_ + RTC_GUARDED_BY(thread_checker_); +}; + +} // namespace + +rtc::scoped_refptr CreateIceTransport( + cricket::PortAllocator* port_allocator) { + IceTransportInit init; + init.set_port_allocator(port_allocator); + return CreateIceTransport(std::move(init)); +} + +rtc::scoped_refptr CreateIceTransport( + IceTransportInit init) { + return rtc::make_ref_counted( + cricket::P2PTransportChannel::Create( + "", cricket::ICE_CANDIDATE_COMPONENT_RTP, std::move(init))); +} + +} // namespace webrtc -- cgit v1.2.3