OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2017 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 WEBRTC_API_ORTCFACTORY_H_ | |
12 #define WEBRTC_API_ORTCFACTORY_H_ | |
13 | |
14 #include <memory> | |
15 | |
16 #include "webrtc/api/udptransportinterface.h" | |
17 #include "webrtc/base/network.h" | |
18 #include "webrtc/base/thread.h" | |
19 #include "webrtc/p2p/base/packetsocketfactory.h" | |
pthatcher1
2017/01/17 20:04:36
Should we have a TODO to move this into the api/ d
Taylor Brandstetter
2017/01/18 02:31:38
It should move, but I don't think a TODO helps; th
| |
20 | |
21 namespace webrtc { | |
22 | |
23 // WARNING: This is experimental/under development, so use at your own risk; no | |
24 // guarantee about API stability is guaranteed here yet. | |
25 // | |
26 // This class is the ORTC analog of PeerConnectionFactory. It acts as a factory | |
27 // for ORTC objects that can be connected to each other. | |
28 // | |
29 // Some of these objects may not be represented by the ORTC specification, but | |
30 // follow the same general principles. | |
31 // | |
32 // On object lifetimes: The factory must not be destroyed before destroying the | |
33 // objects it created, and the objects passed into the factory must not be | |
34 // destroyed before destroying the factory. | |
35 class OrtcFactory { | |
36 public: | |
37 // |network_thread| is the thread on which packets are sent and received. | |
38 // If null, a new rtc::Thread with a default socket server is created. | |
39 // | |
40 // |worker_thread| is used for CPU-intensive operations. | |
pthatcher1
2017/01/17 20:04:36
This kind of misleading. If the worker thread is
Taylor Brandstetter
2017/01/18 02:31:37
Technically that's just a limitation of our implem
| |
41 // If null, a new rtc::Thread is created. | |
42 // | |
43 // |signaling_thread| is used for callbacks to the consumer of the API. If | |
44 // null, the current thread will be used, which assumes that the API consumer | |
45 // is running a message loop on this thread (either using an existing | |
46 // rtc::Thread, or by calling rtc::Thread::Current()->ProcessMessages). | |
pthatcher1
2017/01/17 20:04:36
Is it also the case that all methods call on the A
Taylor Brandstetter
2017/01/18 02:31:38
Yes, but a proxy object should handle that for the
| |
47 // | |
48 // |network_manager| is used to determine which network interfaces are | |
49 // available. This is used for ICE, for example. If null, a default | |
50 // implementation will be used. Only accessed on |network_thread|. | |
51 // | |
52 // |socket_factory| is used (on the network thread) for creating sockets. If | |
53 // it's null, a default implementation will be used, which assumes | |
54 // |network_thread| is a normal rtc::Thread. | |
55 // | |
56 // Note that the OrtcFactory does not take ownership of any of the objects | |
57 // passed in. | |
pthatcher1
2017/01/17 20:04:36
You might want to repeat that none of these can be
Taylor Brandstetter
2017/01/18 02:31:38
Done
| |
58 OrtcFactory(rtc::Thread* network_thread, | |
59 rtc::Thread* worker_thread, | |
60 rtc::Thread* signaling_thread, | |
61 rtc::NetworkManager* network_manager, | |
62 rtc::PacketSocketFactory* socket_factory); | |
63 // Constructor for convenience which uses default implementations of | |
64 // everything (though does still require that the current thread runs a | |
65 // message loop; see above). | |
66 OrtcFactory() : OrtcFactory(nullptr, nullptr, nullptr, nullptr, nullptr) {} | |
67 ~OrtcFactory(); | |
68 | |
69 // Create a UDP transport with IP address family |family|, using a port | |
70 // within the specified range. | |
71 // | |
72 // |family| must be AF_INET or AF_INET6. | |
73 // | |
74 // |min_port|/|max_port| values of 0 indicate no range restriction. | |
75 // | |
76 // Returns nullptr if the transport wasn't successfully created. | |
77 std::unique_ptr<UdpTransportInterface> CreateUdpTransport(int family, | |
78 uint16_t min_port, | |
79 uint16_t max_port); | |
80 // Method for convenience that has no port range restrictions. | |
81 std::unique_ptr<UdpTransportInterface> CreateUdpTransport(int family) { | |
82 return CreateUdpTransport(family, 0, 0); | |
83 } | |
84 | |
85 private: | |
86 rtc::Thread* network_thread_; | |
87 rtc::Thread* worker_thread_; | |
88 rtc::Thread* signaling_thread_; | |
89 rtc::NetworkManager* network_manager_; | |
90 rtc::PacketSocketFactory* socket_factory_; | |
91 // Which of these objects do we own (we constructed a default implementation) | |
92 // vs. were passed in? | |
93 bool owns_network_thread_ = false; | |
94 bool owns_worker_thread_ = false; | |
95 bool wraps_signaling_thread_ = false; | |
96 bool owns_network_manager_ = false; | |
97 bool owns_socket_factory_ = false; | |
pthatcher1
2017/01/17 20:04:36
The alternative approach which many places in our
| |
98 }; | |
99 | |
100 } // namespace webrtc | |
101 | |
102 #endif // WEBRTC_API_ORTCFACTORY_H_ | |
OLD | NEW |