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_ORTCFACTORYINTERFACE_H_ |
| 12 #define WEBRTC_API_ORTCFACTORYINTERFACE_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" |
| 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 OrtcFactoryInterface { |
| 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 // |signaling_thread| is used for callbacks to the consumer of the API. If |
| 41 // null, the current thread will be used, which assumes that the API consumer |
| 42 // is running a message loop on this thread (either using an existing |
| 43 // rtc::Thread, or by calling rtc::Thread::Current()->ProcessMessages). |
| 44 // |
| 45 // |network_manager| is used to determine which network interfaces are |
| 46 // available. This is used for ICE, for example. If null, a default |
| 47 // implementation will be used. Only accessed on |network_thread|. |
| 48 // |
| 49 // |socket_factory| is used (on the network thread) for creating sockets. If |
| 50 // it's null, a default implementation will be used, which assumes |
| 51 // |network_thread| is a normal rtc::Thread. |
| 52 // |
| 53 // Note that the OrtcFactoryInterface does not take ownership of any of the |
| 54 // objects |
| 55 // passed in, and as previously stated, these objects can't be destroyed |
| 56 // before the factory is. |
| 57 static std::unique_ptr<OrtcFactoryInterface> Create( |
| 58 rtc::Thread* network_thread, |
| 59 rtc::Thread* signaling_thread, |
| 60 rtc::NetworkManager* network_manager, |
| 61 rtc::PacketSocketFactory* socket_factory); |
| 62 // Constructor for convenience which uses default implementations of |
| 63 // everything (though does still require that the current thread runs a |
| 64 // message loop; see above). |
| 65 static std::unique_ptr<OrtcFactoryInterface> Create() { |
| 66 return Create(nullptr, nullptr, nullptr, nullptr); |
| 67 } |
| 68 |
| 69 virtual ~OrtcFactoryInterface() {} |
| 70 |
| 71 virtual std::unique_ptr<UdpTransportInterface> |
| 72 CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) = 0; |
| 73 // Method for convenience that has no port range restrictions. |
| 74 std::unique_ptr<UdpTransportInterface> CreateUdpTransport(int family) { |
| 75 return CreateUdpTransport(family, 0, 0); |
| 76 } |
| 77 }; |
| 78 |
| 79 } // namespace webrtc |
| 80 |
| 81 #endif // WEBRTC_API_ORTCFACTORYINTERFACE_H_ |
OLD | NEW |