blob: d981e0b27781e188ce1fc5c53f94edc50890c8e0 [file] [log] [blame]
Harald Alvestrand98462622019-01-30 13:57:031/*
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 Anton6fdfec12019-07-01 21:07:3314#include "api/async_resolver_factory.h"
Harald Alvestrand98462622019-01-30 13:57:0315#include "api/ice_transport_interface.h"
Steve Anton6fdfec12019-07-01 21:07:3316#include "api/rtc_event_log/rtc_event_log.h"
Harald Alvestrand98462622019-01-30 13:57:0317#include "api/scoped_refptr.h"
Mirko Bonadei66e76792019-04-02 09:33:5918#include "rtc_base/system/rtc_export.h"
Harald Alvestrand98462622019-01-30 13:57:0319
20namespace cricket {
21class PortAllocator;
22}
23
24namespace webrtc {
25
Steve Anton6fdfec12019-07-01 21:07:3326struct 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 Alvestrand98462622019-01-30 13:57:0356// 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 Anton6fdfec12019-07-01 21:07:3361// TODO(steveanton): Remove in favor of the overload that takes
62// IceTransportInit.
Mirko Bonadei66e76792019-04-02 09:33:5963RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
Harald Alvestrand98462622019-01-30 13:57:0364 cricket::PortAllocator* port_allocator);
65
Steve Anton6fdfec12019-07-01 21:07:3366// 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.
74RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
75 IceTransportInit);
76
Harald Alvestrand98462622019-01-30 13:57:0377} // namespace webrtc
78
79#endif // API_ICE_TRANSPORT_FACTORY_H_