LibWebRTCSocketFactory.h [plain text]
#pragma once
#if USE(LIBWEBRTC)
#include "LibWebRTCResolver.h"
#include "LibWebRTCSocket.h"
#include <WebCore/LibWebRTCMacros.h>
#include <webrtc/rtc_base/nethelpers.h>
#include <webrtc/p2p/base/packetsocketfactory.h>
#include <wtf/HashMap.h>
namespace WebKit {
class LibWebRTCSocketFactory final : public rtc::PacketSocketFactory {
public:
LibWebRTCSocketFactory() { }
void detach(LibWebRTCSocket&);
LibWebRTCSocket* socket(uint64_t identifier) { return m_sockets.get(identifier); }
LibWebRTCResolver* resolver(uint64_t identifier) { return m_resolvers.get(identifier); }
std::unique_ptr<LibWebRTCResolver> takeResolver(uint64_t identifier) { return m_resolvers.take(identifier); }
rtc::AsyncPacketSocket* createNewConnectionSocket(LibWebRTCSocket&, uint64_t newConnectionSocketIdentifier, const rtc::SocketAddress&);
void disableNonLocalhostConnections() { m_disableNonLocalhostConnections = true; }
private:
rtc::AsyncPacketSocket* CreateUdpSocket(const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort) final;
rtc::AsyncPacketSocket* CreateServerTcpSocket(const rtc::SocketAddress&, uint16_t min_port, uint16_t max_port, int options) final;
rtc::AsyncPacketSocket* CreateClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, const rtc::ProxyInfo&, const std::string&, int options);
rtc::AsyncResolverInterface* CreateAsyncResolver() final;
HashMap<uint64_t, LibWebRTCSocket*> m_sockets;
static uint64_t s_uniqueSocketIdentifier;
HashMap<uint64_t, std::unique_ptr<LibWebRTCResolver>> m_resolvers;
static uint64_t s_uniqueResolverIdentifier;
bool m_disableNonLocalhostConnections { false };
};
}
#endif // USE(LIBWEBRTC)