webrtc_m130/webrtc/api/ortcfactory.h
deadbeef d1c0998730 Adding OrtcFactory, and changing UdpTransport to match current plan.
The factory follows the same principles as PeerConnectionFactory;
various modules can be passed into its constructor but default
implementations are provided. Currently the only object the factory can
create is a UdpTransport (need to start somewhere).

UdpTransportChannel (renamed to UdpTransport)
will now accept a socket passed into its constructor,
relying on the factory to create the socket. This allows some
simplifications to be made, such as getting rid of "State" since the
only states are now "has destination set or doesn't".

BUG=webrtc:7013

Review-Url: https://codereview.webrtc.org/2632613002
Cr-Commit-Position: refs/heads/master@{#16154}
2017-01-18 23:16:37 +00:00

65 lines
2.2 KiB
C++

/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_API_ORTCFACTORY_H_
#define WEBRTC_API_ORTCFACTORY_H_
#include <memory>
#include "webrtc/api/ortcfactoryinterface.h"
#include "webrtc/base/constructormagic.h"
namespace webrtc {
// Implementation of OrtcFactoryInterface.
//
// See ortcfactoryinterface.h for documentation.
class OrtcFactory : public OrtcFactoryInterface {
public:
OrtcFactory(rtc::Thread* network_thread,
rtc::Thread* signaling_thread,
rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory);
~OrtcFactory() override;
std::unique_ptr<UdpTransportInterface>
CreateUdpTransport(int family, uint16_t min_port, uint16_t max_port) override;
rtc::Thread* network_thread() { return network_thread_; }
rtc::Thread* worker_thread() { return owned_worker_thread_.get(); }
rtc::Thread* signaling_thread() { return signaling_thread_; }
private:
rtc::Thread* network_thread_;
rtc::Thread* signaling_thread_;
rtc::NetworkManager* network_manager_;
rtc::PacketSocketFactory* socket_factory_;
// If we created/own the objects above, these will be non-null and thus will
// be released automatically upon destruction.
std::unique_ptr<rtc::Thread> owned_network_thread_;
std::unique_ptr<rtc::Thread> owned_worker_thread_;
bool wraps_signaling_thread_ = false;
std::unique_ptr<rtc::NetworkManager> owned_network_manager_;
std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
RTC_DISALLOW_COPY_AND_ASSIGN(OrtcFactory);
};
BEGIN_OWNED_PROXY_MAP(OrtcFactory)
PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_METHOD3(std::unique_ptr<UdpTransportInterface>,
CreateUdpTransport,
int,
uint16_t,
uint16_t)
END_PROXY_MAP()
} // namespace webrtc
#endif // WEBRTC_API_ORTCFACTORY_H_