basic_packet_socket_factory.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2011 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. #ifndef P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_
  11. #define P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_
  12. #include <string>
  13. #include "api/packet_socket_factory.h"
  14. namespace rtc {
  15. class AsyncSocket;
  16. class SocketFactory;
  17. class Thread;
  18. class BasicPacketSocketFactory : public PacketSocketFactory {
  19. public:
  20. BasicPacketSocketFactory();
  21. explicit BasicPacketSocketFactory(Thread* thread);
  22. explicit BasicPacketSocketFactory(SocketFactory* socket_factory);
  23. ~BasicPacketSocketFactory() override;
  24. AsyncPacketSocket* CreateUdpSocket(const SocketAddress& local_address,
  25. uint16_t min_port,
  26. uint16_t max_port) override;
  27. AsyncPacketSocket* CreateServerTcpSocket(const SocketAddress& local_address,
  28. uint16_t min_port,
  29. uint16_t max_port,
  30. int opts) override;
  31. AsyncPacketSocket* CreateClientTcpSocket(
  32. const SocketAddress& local_address,
  33. const SocketAddress& remote_address,
  34. const ProxyInfo& proxy_info,
  35. const std::string& user_agent,
  36. const PacketSocketTcpOptions& tcp_options) override;
  37. AsyncResolverInterface* CreateAsyncResolver() override;
  38. private:
  39. int BindSocket(AsyncSocket* socket,
  40. const SocketAddress& local_address,
  41. uint16_t min_port,
  42. uint16_t max_port);
  43. SocketFactory* socket_factory();
  44. Thread* thread_;
  45. SocketFactory* socket_factory_;
  46. };
  47. } // namespace rtc
  48. #endif // P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_