1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #include "api/test/create_time_controller.h" 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #include <memory> 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard Worker #include "call/call.h" 16*d9f75844SAndroid Build Coastguard Worker #include "call/rtp_transport_config.h" 17*d9f75844SAndroid Build Coastguard Worker #include "call/rtp_transport_controller_send_factory_interface.h" 18*d9f75844SAndroid Build Coastguard Worker #include "test/time_controller/external_time_controller.h" 19*d9f75844SAndroid Build Coastguard Worker #include "test/time_controller/simulated_time_controller.h" 20*d9f75844SAndroid Build Coastguard Worker 21*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 22*d9f75844SAndroid Build Coastguard Worker CreateTimeController(ControlledAlarmClock * alarm)23*d9f75844SAndroid Build Coastguard Workerstd::unique_ptr<TimeController> CreateTimeController( 24*d9f75844SAndroid Build Coastguard Worker ControlledAlarmClock* alarm) { 25*d9f75844SAndroid Build Coastguard Worker return std::make_unique<ExternalTimeController>(alarm); 26*d9f75844SAndroid Build Coastguard Worker } 27*d9f75844SAndroid Build Coastguard Worker CreateSimulatedTimeController()28*d9f75844SAndroid Build Coastguard Workerstd::unique_ptr<TimeController> CreateSimulatedTimeController() { 29*d9f75844SAndroid Build Coastguard Worker return std::make_unique<GlobalSimulatedTimeController>( 30*d9f75844SAndroid Build Coastguard Worker Timestamp::Seconds(10000)); 31*d9f75844SAndroid Build Coastguard Worker } 32*d9f75844SAndroid Build Coastguard Worker CreateTimeControllerBasedCallFactory(TimeController * time_controller)33*d9f75844SAndroid Build Coastguard Workerstd::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory( 34*d9f75844SAndroid Build Coastguard Worker TimeController* time_controller) { 35*d9f75844SAndroid Build Coastguard Worker class TimeControllerBasedCallFactory : public CallFactoryInterface { 36*d9f75844SAndroid Build Coastguard Worker public: 37*d9f75844SAndroid Build Coastguard Worker explicit TimeControllerBasedCallFactory(TimeController* time_controller) 38*d9f75844SAndroid Build Coastguard Worker : time_controller_(time_controller) {} 39*d9f75844SAndroid Build Coastguard Worker Call* CreateCall(const Call::Config& config) override { 40*d9f75844SAndroid Build Coastguard Worker RtpTransportConfig transportConfig = config.ExtractTransportConfig(); 41*d9f75844SAndroid Build Coastguard Worker 42*d9f75844SAndroid Build Coastguard Worker return Call::Create(config, time_controller_->GetClock(), 43*d9f75844SAndroid Build Coastguard Worker config.rtp_transport_controller_send_factory->Create( 44*d9f75844SAndroid Build Coastguard Worker transportConfig, time_controller_->GetClock())); 45*d9f75844SAndroid Build Coastguard Worker } 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker private: 48*d9f75844SAndroid Build Coastguard Worker TimeController* time_controller_; 49*d9f75844SAndroid Build Coastguard Worker }; 50*d9f75844SAndroid Build Coastguard Worker return std::make_unique<TimeControllerBasedCallFactory>(time_controller); 51*d9f75844SAndroid Build Coastguard Worker } 52*d9f75844SAndroid Build Coastguard Worker 53*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 54