Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | #include "test/scenario/call_client.h" |
| 11 | |
| 12 | #include <utility> |
| 13 | |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 14 | #include <memory> |
Danil Chapovalov | b32f2c7 | 2019-05-22 13:39:25 +0200 | [diff] [blame] | 15 | #include "api/rtc_event_log/rtc_event_log.h" |
| 16 | #include "api/rtc_event_log/rtc_event_log_factory.h" |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 17 | #include "modules/audio_mixer/audio_mixer_impl.h" |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | namespace test { |
| 21 | namespace { |
Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 22 | static constexpr size_t kNumSsrcs = 6; |
| 23 | const uint32_t kSendRtxSsrcs[kNumSsrcs] = {0xBADCAFD, 0xBADCAFE, 0xBADCAFF, |
| 24 | 0xBADCB00, 0xBADCB01, 0xBADCB02}; |
| 25 | const uint32_t kVideoSendSsrcs[kNumSsrcs] = {0xC0FFED, 0xC0FFEE, 0xC0FFEF, |
| 26 | 0xC0FFF0, 0xC0FFF1, 0xC0FFF2}; |
| 27 | const uint32_t kVideoRecvLocalSsrcs[kNumSsrcs] = {0xDAB001, 0xDAB002, 0xDAB003, |
| 28 | 0xDAB004, 0xDAB005, 0xDAB006}; |
| 29 | const uint32_t kAudioSendSsrc = 0xDEADBEEF; |
| 30 | const uint32_t kReceiverLocalAudioSsrc = 0x1234567; |
| 31 | |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 32 | constexpr int kEventLogOutputIntervalMs = 5000; |
| 33 | |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 34 | CallClientFakeAudio InitAudio(TimeController* time_controller) { |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 35 | CallClientFakeAudio setup; |
| 36 | auto capturer = TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000); |
| 37 | auto renderer = TestAudioDeviceModule::CreateDiscardRenderer(48000); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 38 | setup.fake_audio_device = TestAudioDeviceModule::Create( |
| 39 | time_controller->GetTaskQueueFactory(), std::move(capturer), |
| 40 | std::move(renderer), 1.f); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 41 | setup.apm = AudioProcessingBuilder().Create(); |
| 42 | setup.fake_audio_device->Init(); |
| 43 | AudioState::Config audio_state_config; |
| 44 | audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
| 45 | audio_state_config.audio_processing = setup.apm; |
| 46 | audio_state_config.audio_device_module = setup.fake_audio_device; |
| 47 | setup.audio_state = AudioState::Create(audio_state_config); |
| 48 | setup.fake_audio_device->RegisterAudioCallback( |
| 49 | setup.audio_state->audio_transport()); |
| 50 | return setup; |
| 51 | } |
| 52 | |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 53 | Call* CreateCall(TimeController* time_controller, |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 54 | RtcEventLog* event_log, |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 55 | CallClientConfig config, |
| 56 | LoggingNetworkControllerFactory* network_controller_factory, |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 57 | rtc::scoped_refptr<AudioState> audio_state) { |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 58 | CallConfig call_config(event_log); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 59 | call_config.bitrate_config.max_bitrate_bps = |
| 60 | config.transport.rates.max_rate.bps_or(-1); |
| 61 | call_config.bitrate_config.min_bitrate_bps = |
| 62 | config.transport.rates.min_rate.bps(); |
| 63 | call_config.bitrate_config.start_bitrate_bps = |
| 64 | config.transport.rates.start_rate.bps(); |
Danil Chapovalov | 359fe33 | 2019-04-01 10:46:36 +0200 | [diff] [blame] | 65 | call_config.task_queue_factory = time_controller->GetTaskQueueFactory(); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 66 | call_config.network_controller_factory = network_controller_factory; |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 67 | call_config.audio_state = audio_state; |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 68 | return Call::Create(call_config, time_controller->GetClock(), |
| 69 | time_controller->CreateProcessThread("CallModules"), |
Danil Chapovalov | 359fe33 | 2019-04-01 10:46:36 +0200 | [diff] [blame] | 70 | time_controller->CreateProcessThread("Pacer")); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 71 | } |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 72 | |
| 73 | std::unique_ptr<RtcEventLog> CreateEventLog( |
| 74 | TaskQueueFactory* task_queue_factory, |
| 75 | LogWriterFactoryInterface* log_writer_factory) { |
| 76 | if (!log_writer_factory) { |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 77 | return std::make_unique<RtcEventLogNull>(); |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 78 | } |
Danil Chapovalov | b32f2c7 | 2019-05-22 13:39:25 +0200 | [diff] [blame] | 79 | auto event_log = RtcEventLogFactory(task_queue_factory) |
| 80 | .CreateRtcEventLog(RtcEventLog::EncodingType::NewFormat); |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 81 | bool success = event_log->StartLogging(log_writer_factory->Create(".rtc.dat"), |
| 82 | kEventLogOutputIntervalMs); |
| 83 | RTC_CHECK(success); |
| 84 | return event_log; |
| 85 | } |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 86 | } // namespace |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 87 | NetworkControleUpdateCache::NetworkControleUpdateCache( |
| 88 | std::unique_ptr<NetworkControllerInterface> controller) |
| 89 | : controller_(std::move(controller)) {} |
| 90 | NetworkControlUpdate NetworkControleUpdateCache::OnNetworkAvailability( |
| 91 | NetworkAvailability msg) { |
| 92 | return Update(controller_->OnNetworkAvailability(msg)); |
| 93 | } |
| 94 | NetworkControlUpdate NetworkControleUpdateCache::OnNetworkRouteChange( |
| 95 | NetworkRouteChange msg) { |
| 96 | return Update(controller_->OnNetworkRouteChange(msg)); |
| 97 | } |
| 98 | NetworkControlUpdate NetworkControleUpdateCache::OnProcessInterval( |
| 99 | ProcessInterval msg) { |
| 100 | return Update(controller_->OnProcessInterval(msg)); |
| 101 | } |
| 102 | NetworkControlUpdate NetworkControleUpdateCache::OnRemoteBitrateReport( |
| 103 | RemoteBitrateReport msg) { |
| 104 | return Update(controller_->OnRemoteBitrateReport(msg)); |
| 105 | } |
| 106 | NetworkControlUpdate NetworkControleUpdateCache::OnRoundTripTimeUpdate( |
| 107 | RoundTripTimeUpdate msg) { |
| 108 | return Update(controller_->OnRoundTripTimeUpdate(msg)); |
| 109 | } |
| 110 | NetworkControlUpdate NetworkControleUpdateCache::OnSentPacket(SentPacket msg) { |
| 111 | return Update(controller_->OnSentPacket(msg)); |
| 112 | } |
| 113 | NetworkControlUpdate NetworkControleUpdateCache::OnReceivedPacket( |
| 114 | ReceivedPacket msg) { |
| 115 | return Update(controller_->OnReceivedPacket(msg)); |
| 116 | } |
| 117 | NetworkControlUpdate NetworkControleUpdateCache::OnStreamsConfig( |
| 118 | StreamsConfig msg) { |
| 119 | return Update(controller_->OnStreamsConfig(msg)); |
| 120 | } |
| 121 | NetworkControlUpdate NetworkControleUpdateCache::OnTargetRateConstraints( |
| 122 | TargetRateConstraints msg) { |
| 123 | return Update(controller_->OnTargetRateConstraints(msg)); |
| 124 | } |
| 125 | NetworkControlUpdate NetworkControleUpdateCache::OnTransportLossReport( |
| 126 | TransportLossReport msg) { |
| 127 | return Update(controller_->OnTransportLossReport(msg)); |
| 128 | } |
| 129 | NetworkControlUpdate NetworkControleUpdateCache::OnTransportPacketsFeedback( |
| 130 | TransportPacketsFeedback msg) { |
| 131 | return Update(controller_->OnTransportPacketsFeedback(msg)); |
| 132 | } |
Sebastian Jansson | 49167de | 2019-06-27 15:59:03 +0200 | [diff] [blame] | 133 | NetworkControlUpdate NetworkControleUpdateCache::OnNetworkStateEstimate( |
| 134 | NetworkStateEstimate msg) { |
| 135 | return Update(controller_->OnNetworkStateEstimate(msg)); |
| 136 | } |
| 137 | |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 138 | NetworkControlUpdate NetworkControleUpdateCache::update_state() const { |
| 139 | return update_state_; |
| 140 | } |
| 141 | NetworkControlUpdate NetworkControleUpdateCache::Update( |
| 142 | NetworkControlUpdate update) { |
| 143 | if (update.target_rate) |
| 144 | update_state_.target_rate = update.target_rate; |
| 145 | if (update.pacer_config) |
| 146 | update_state_.pacer_config = update.pacer_config; |
| 147 | if (update.congestion_window) |
| 148 | update_state_.congestion_window = update.congestion_window; |
| 149 | if (!update.probe_cluster_configs.empty()) |
| 150 | update_state_.probe_cluster_configs = update.probe_cluster_configs; |
| 151 | return update; |
| 152 | } |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 153 | |
| 154 | LoggingNetworkControllerFactory::LoggingNetworkControllerFactory( |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 155 | LogWriterFactoryInterface* log_writer_factory, |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 156 | TransportControllerConfig config) { |
| 157 | if (config.cc_factory) { |
| 158 | cc_factory_ = config.cc_factory; |
| 159 | if (log_writer_factory) |
| 160 | RTC_LOG(LS_WARNING) |
| 161 | << "Can't log controller state for injected network controllers"; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 162 | } else { |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 163 | if (log_writer_factory) { |
Sebastian Jansson | 871ac42 | 2019-05-17 17:53:44 +0200 | [diff] [blame] | 164 | goog_cc_factory_.AttachWriter( |
| 165 | log_writer_factory->Create(".cc_state.txt")); |
| 166 | print_cc_state_ = true; |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 167 | } |
Sebastian Jansson | 871ac42 | 2019-05-17 17:53:44 +0200 | [diff] [blame] | 168 | cc_factory_ = &goog_cc_factory_; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 172 | LoggingNetworkControllerFactory::~LoggingNetworkControllerFactory() {} |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 173 | |
| 174 | void LoggingNetworkControllerFactory::LogCongestionControllerStats( |
| 175 | Timestamp at_time) { |
Sebastian Jansson | 871ac42 | 2019-05-17 17:53:44 +0200 | [diff] [blame] | 176 | if (print_cc_state_) |
| 177 | goog_cc_factory_.PrintState(at_time); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 178 | } |
| 179 | |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 180 | NetworkControlUpdate LoggingNetworkControllerFactory::GetUpdate() const { |
| 181 | if (last_controller_) |
| 182 | return last_controller_->update_state(); |
| 183 | return NetworkControlUpdate(); |
| 184 | } |
| 185 | |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 186 | std::unique_ptr<NetworkControllerInterface> |
| 187 | LoggingNetworkControllerFactory::Create(NetworkControllerConfig config) { |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 188 | auto controller = |
| 189 | std::make_unique<NetworkControleUpdateCache>(cc_factory_->Create(config)); |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 190 | last_controller_ = controller.get(); |
| 191 | return controller; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | TimeDelta LoggingNetworkControllerFactory::GetProcessInterval() const { |
| 195 | return cc_factory_->GetProcessInterval(); |
| 196 | } |
| 197 | |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 198 | CallClient::CallClient( |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 199 | TimeController* time_controller, |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 200 | std::unique_ptr<LogWriterFactoryInterface> log_writer_factory, |
| 201 | CallClientConfig config) |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 202 | : time_controller_(time_controller), |
| 203 | clock_(time_controller->GetClock()), |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 204 | log_writer_factory_(std::move(log_writer_factory)), |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 205 | network_controller_factory_(log_writer_factory_.get(), config.transport), |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame] | 206 | header_parser_(RtpHeaderParser::CreateForTest()), |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 207 | task_queue_(time_controller->GetTaskQueueFactory()->CreateTaskQueue( |
| 208 | "CallClient", |
| 209 | TaskQueueFactory::Priority::NORMAL)) { |
| 210 | SendTask([this, config] { |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 211 | event_log_ = CreateEventLog(time_controller_->GetTaskQueueFactory(), |
| 212 | log_writer_factory_.get()); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 213 | fake_audio_setup_ = InitAudio(time_controller_); |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 214 | call_.reset(CreateCall(time_controller_, event_log_.get(), config, |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 215 | &network_controller_factory_, |
| 216 | fake_audio_setup_.audio_state)); |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 217 | transport_ = std::make_unique<NetworkNodeTransport>(clock_, call_.get()); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 218 | }); |
| 219 | } |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 220 | |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 221 | CallClient::~CallClient() { |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 222 | SendTask([&] { |
| 223 | call_.reset(); |
| 224 | fake_audio_setup_ = {}; |
Sebastian Jansson | 58c71db | 2019-05-22 16:20:56 +0200 | [diff] [blame] | 225 | rtc::Event done; |
| 226 | event_log_->StopLogging([&done] { done.Set(); }); |
| 227 | done.Wait(rtc::Event::kForever); |
Sebastian Jansson | 7ccaf89 | 2019-04-24 15:13:26 +0200 | [diff] [blame] | 228 | event_log_.reset(); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 229 | }); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 230 | } |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 231 | |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 232 | ColumnPrinter CallClient::StatsPrinter() { |
| 233 | return ColumnPrinter::Lambda( |
| 234 | "pacer_delay call_send_bw", |
| 235 | [this](rtc::SimpleStringBuilder& sb) { |
| 236 | Call::Stats call_stats = call_->GetStats(); |
| 237 | sb.AppendFormat("%.3lf %.0lf", call_stats.pacer_delay_ms / 1000.0, |
| 238 | call_stats.send_bandwidth_bps / 8.0); |
| 239 | }, |
| 240 | 64); |
| 241 | } |
| 242 | |
| 243 | Call::Stats CallClient::GetStats() { |
Tommi | e6b7b66 | 2019-08-06 12:44:35 +0200 | [diff] [blame] | 244 | // This call needs to be made on the thread that |call_| was constructed on. |
| 245 | Call::Stats stats; |
| 246 | SendTask([this, &stats] { stats = call_->GetStats(); }); |
| 247 | return stats; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 248 | } |
| 249 | |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 250 | DataRate CallClient::target_rate() const { |
| 251 | return network_controller_factory_.GetUpdate().target_rate->target_rate; |
| 252 | } |
| 253 | |
Florent Castelli | 4e615d5 | 2019-08-22 16:09:06 +0200 | [diff] [blame] | 254 | DataRate CallClient::stable_target_rate() const { |
| 255 | return network_controller_factory_.GetUpdate() |
| 256 | .target_rate->stable_target_rate; |
| 257 | } |
| 258 | |
Sebastian Jansson | a7d70ab | 2019-06-11 10:21:32 +0200 | [diff] [blame] | 259 | DataRate CallClient::padding_rate() const { |
| 260 | return network_controller_factory_.GetUpdate().pacer_config->pad_rate(); |
| 261 | } |
| 262 | |
Artem Titov | 40f5115 | 2019-01-04 15:45:01 +0100 | [diff] [blame] | 263 | void CallClient::OnPacketReceived(EmulatedIpPacket packet) { |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 264 | // Removes added overhead before delivering packet to sender. |
Artem Titov | 4cd433e | 2019-04-01 11:01:16 +0200 | [diff] [blame] | 265 | size_t size = |
| 266 | packet.data.size() - route_overhead_.at(packet.to.ipaddr()).bytes(); |
| 267 | RTC_DCHECK_GE(size, 0); |
| 268 | packet.data.SetSize(size); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 269 | |
| 270 | MediaType media_type = MediaType::ANY; |
Artem Titov | 40f5115 | 2019-01-04 15:45:01 +0100 | [diff] [blame] | 271 | if (!RtpHeaderParser::IsRtcp(packet.cdata(), packet.data.size())) { |
Sebastian Jansson | 1e42761 | 2019-03-05 14:25:03 +0100 | [diff] [blame] | 272 | auto ssrc = RtpHeaderParser::GetSsrc(packet.cdata(), packet.data.size()); |
| 273 | RTC_CHECK(ssrc.has_value()); |
| 274 | media_type = ssrc_media_types_[*ssrc]; |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 275 | } |
Sebastian Jansson | ee5ec9a | 2019-09-17 20:34:03 +0200 | [diff] [blame] | 276 | task_queue_.PostTask( |
| 277 | [call = call_.get(), media_type, packet = std::move(packet)]() mutable { |
| 278 | call->Receiver()->DeliverPacket(media_type, packet.data, |
| 279 | packet.arrival_time.us()); |
| 280 | }); |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 281 | } |
| 282 | |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 283 | std::unique_ptr<RtcEventLogOutput> CallClient::GetLogWriter(std::string name) { |
| 284 | if (!log_writer_factory_ || name.empty()) |
| 285 | return nullptr; |
| 286 | return log_writer_factory_->Create(name); |
| 287 | } |
| 288 | |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 289 | uint32_t CallClient::GetNextVideoSsrc() { |
Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 290 | RTC_CHECK_LT(next_video_ssrc_index_, kNumSsrcs); |
| 291 | return kVideoSendSsrcs[next_video_ssrc_index_++]; |
| 292 | } |
| 293 | |
| 294 | uint32_t CallClient::GetNextVideoLocalSsrc() { |
| 295 | RTC_CHECK_LT(next_video_local_ssrc_index_, kNumSsrcs); |
| 296 | return kVideoRecvLocalSsrcs[next_video_local_ssrc_index_++]; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | uint32_t CallClient::GetNextAudioSsrc() { |
| 300 | RTC_CHECK_LT(next_audio_ssrc_index_, 1); |
| 301 | next_audio_ssrc_index_++; |
Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 302 | return kAudioSendSsrc; |
| 303 | } |
| 304 | |
| 305 | uint32_t CallClient::GetNextAudioLocalSsrc() { |
| 306 | RTC_CHECK_LT(next_audio_local_ssrc_index_, 1); |
| 307 | next_audio_local_ssrc_index_++; |
| 308 | return kReceiverLocalAudioSsrc; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | uint32_t CallClient::GetNextRtxSsrc() { |
Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 312 | RTC_CHECK_LT(next_rtx_ssrc_index_, kNumSsrcs); |
| 313 | return kSendRtxSsrcs[next_rtx_ssrc_index_++]; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 314 | } |
| 315 | |
Sebastian Jansson | fd20171 | 2018-11-12 16:44:16 +0100 | [diff] [blame] | 316 | void CallClient::AddExtensions(std::vector<RtpExtension> extensions) { |
| 317 | for (const auto& extension : extensions) |
| 318 | header_parser_->RegisterRtpHeaderExtension(extension); |
| 319 | } |
| 320 | |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 321 | void CallClient::SendTask(std::function<void()> task) { |
| 322 | time_controller_->InvokeWithControlledYield( |
Danil Chapovalov | eb90e6f | 2019-10-15 10:04:57 +0200 | [diff] [blame] | 323 | [&] { task_queue_.SendTask(std::move(task), RTC_FROM_HERE); }); |
Sebastian Jansson | 105a10a | 2019-04-01 09:18:14 +0200 | [diff] [blame] | 324 | } |
| 325 | |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 326 | CallClientPair::~CallClientPair() = default; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 327 | |
| 328 | } // namespace test |
| 329 | } // namespace webrtc |