webrtc/api/test/create_time_controller.cc
Sebastian Jansson 09a9f1ba72 Adds simulated time controller API.
Bug: webrtc:11255
Change-Id: I68289a45b9441b5e612433acd96dc3cb24e47ce4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168122
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30443}
2020-02-03 10:19:08 +00:00

49 lines
1.7 KiB
C++

/*
* Copyright 2019 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.
*/
#include "api/test/create_time_controller.h"
#include <memory>
#include "call/call.h"
#include "test/time_controller/external_time_controller.h"
#include "test/time_controller/simulated_time_controller.h"
namespace webrtc {
std::unique_ptr<TimeController> CreateTimeController(
ControlledAlarmClock* alarm) {
return std::make_unique<ExternalTimeController>(alarm);
}
std::unique_ptr<TimeController> CreateSimulatedTimeController() {
return std::make_unique<GlobalSimulatedTimeController>(
Timestamp::seconds(10000));
}
std::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory(
TimeController* time_controller) {
class TimeControllerBasedCallFactory : public CallFactoryInterface {
public:
explicit TimeControllerBasedCallFactory(TimeController* time_controller)
: time_controller_(time_controller) {}
Call* CreateCall(const Call::Config& config) override {
return Call::Create(config, time_controller_->GetClock(),
time_controller_->CreateProcessThread("CallModules"),
time_controller_->CreateProcessThread("Pacer"));
}
private:
TimeController* time_controller_;
};
return std::make_unique<TimeControllerBasedCallFactory>(time_controller);
}
} // namespace webrtc