Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 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 | #ifndef API_ICE_TRANSPORT_FACTORY_H_ |
| 12 | #define API_ICE_TRANSPORT_FACTORY_H_ |
| 13 | |
Steve Anton | 6fdfec1 | 2019-07-01 21:07:33 | [diff] [blame] | 14 | #include "api/async_resolver_factory.h" |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 15 | #include "api/ice_transport_interface.h" |
Steve Anton | 6fdfec1 | 2019-07-01 21:07:33 | [diff] [blame] | 16 | #include "api/rtc_event_log/rtc_event_log.h" |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 17 | #include "api/scoped_refptr.h" |
Mirko Bonadei | 66e7679 | 2019-04-02 09:33:59 | [diff] [blame] | 18 | #include "rtc_base/system/rtc_export.h" |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 19 | |
| 20 | namespace cricket { |
| 21 | class PortAllocator; |
| 22 | } |
| 23 | |
| 24 | namespace webrtc { |
| 25 | |
Steve Anton | 6fdfec1 | 2019-07-01 21:07:33 | [diff] [blame] | 26 | struct IceTransportInit final { |
| 27 | public: |
| 28 | IceTransportInit() = default; |
| 29 | IceTransportInit(const IceTransportInit&) = delete; |
| 30 | IceTransportInit(IceTransportInit&&) = default; |
| 31 | IceTransportInit& operator=(const IceTransportInit&) = delete; |
| 32 | IceTransportInit& operator=(IceTransportInit&&) = default; |
| 33 | |
| 34 | cricket::PortAllocator* port_allocator() { return port_allocator_; } |
| 35 | void set_port_allocator(cricket::PortAllocator* port_allocator) { |
| 36 | port_allocator_ = port_allocator; |
| 37 | } |
| 38 | |
| 39 | AsyncResolverFactory* async_resolver_factory() { |
| 40 | return async_resolver_factory_; |
| 41 | } |
| 42 | void set_async_resolver_factory( |
| 43 | AsyncResolverFactory* async_resolver_factory) { |
| 44 | async_resolver_factory_ = async_resolver_factory; |
| 45 | } |
| 46 | |
| 47 | RtcEventLog* event_log() { return event_log_; } |
| 48 | void set_event_log(RtcEventLog* event_log) { event_log_ = event_log; } |
| 49 | |
| 50 | private: |
| 51 | cricket::PortAllocator* port_allocator_ = nullptr; |
| 52 | AsyncResolverFactory* async_resolver_factory_ = nullptr; |
| 53 | RtcEventLog* event_log_ = nullptr; |
| 54 | }; |
| 55 | |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 56 | // Static factory for an IceTransport object that can be created |
| 57 | // without using a webrtc::PeerConnection. |
| 58 | // The returned object must be accessed and destroyed on the thread that |
| 59 | // created it. |
| 60 | // The PortAllocator must outlive the created IceTransportInterface object. |
Steve Anton | 6fdfec1 | 2019-07-01 21:07:33 | [diff] [blame] | 61 | // TODO(steveanton): Remove in favor of the overload that takes |
| 62 | // IceTransportInit. |
Mirko Bonadei | 66e7679 | 2019-04-02 09:33:59 | [diff] [blame] | 63 | RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport( |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 64 | cricket::PortAllocator* port_allocator); |
| 65 | |
Steve Anton | 6fdfec1 | 2019-07-01 21:07:33 | [diff] [blame] | 66 | // Static factory for an IceTransport object that can be created |
| 67 | // without using a webrtc::PeerConnection. |
| 68 | // The returned object must be accessed and destroyed on the thread that |
| 69 | // created it. |
| 70 | // |init.port_allocator()| is required and must outlive the created |
| 71 | // IceTransportInterface object. |
| 72 | // |init.async_resolver_factory()| and |init.event_log()| are optional, but if |
| 73 | // provided must outlive the created IceTransportInterface object. |
| 74 | RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport( |
| 75 | IceTransportInit); |
| 76 | |
Harald Alvestrand | 9846262 | 2019-01-30 13:57:03 | [diff] [blame] | 77 | } // namespace webrtc |
| 78 | |
| 79 | #endif // API_ICE_TRANSPORT_FACTORY_H_ |