xref: /aosp_15_r20/external/webrtc/p2p/base/default_ice_transport_factory.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "p2p/base/default_ice_transport_factory.h"
12 
13 #include <utility>
14 
15 #include "api/make_ref_counted.h"
16 #include "p2p/base/basic_ice_controller.h"
17 #include "p2p/base/ice_controller_factory_interface.h"
18 
19 namespace {
20 
21 class BasicIceControllerFactory
22     : public cricket::IceControllerFactoryInterface {
23  public:
Create(const cricket::IceControllerFactoryArgs & args)24   std::unique_ptr<cricket::IceControllerInterface> Create(
25       const cricket::IceControllerFactoryArgs& args) override {
26     return std::make_unique<cricket::BasicIceController>(args);
27   }
28 };
29 
30 }  // namespace
31 
32 namespace webrtc {
33 
DefaultIceTransport(std::unique_ptr<cricket::P2PTransportChannel> internal)34 DefaultIceTransport::DefaultIceTransport(
35     std::unique_ptr<cricket::P2PTransportChannel> internal)
36     : internal_(std::move(internal)) {}
37 
~DefaultIceTransport()38 DefaultIceTransport::~DefaultIceTransport() {
39   RTC_DCHECK_RUN_ON(&thread_checker_);
40 }
41 
42 rtc::scoped_refptr<IceTransportInterface>
CreateIceTransport(const std::string & transport_name,int component,IceTransportInit init)43 DefaultIceTransportFactory::CreateIceTransport(
44     const std::string& transport_name,
45     int component,
46     IceTransportInit init) {
47   BasicIceControllerFactory factory;
48   init.set_ice_controller_factory(&factory);
49   return rtc::make_ref_counted<DefaultIceTransport>(
50       cricket::P2PTransportChannel::Create(transport_name, component,
51                                            std::move(init)));
52 }
53 
54 }  // namespace webrtc
55