Skip to content

Instantly share code, notes, and snippets.

@yiding
yiding / gist:1bfe9bbf5187a6ff6f34
Created June 30, 2014 19:03
WebRTC native, forcing ports to be allocated in a certain range.
class PortAllocatorFactoryWrapper : public PortAllocatorFactory {
public:
PortAllocatorFactoryWrapper(talk_base::Thread* worker_thread, int minPort, int maxPort)
: PortAllocatorFactory(worker_thread), minPort_(minPort), maxPort_(maxPort) {}
virtual cricket::PortAllocator *CreatePortAllocator(
const std::vector<StunConfiguration> &stun,
const std::vector<TurnConfiguration> &turn) override {
auto allocator = PortAllocatorFactory::CreatePortAllocator(stun, turn);
allocator->SetPortRange(minPort_, maxPort_);