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