| 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 |
| 11 | #include "audio/audio_send_stream.h" |
| 12 |
| 13 | #include <memory> |
| 14 | #include <string> |
| 15 | #include <utility> |
| 16 | #include <vector> |
| 17 |
| 18 | #include "api/audio_codecs/audio_encoder.h" |
| 19 | #include "api/audio_codecs/audio_encoder_factory.h" |
| 20 | #include "api/audio_codecs/audio_format.h" |
| 21 | #include "api/call/transport.h" |
| 22 | #include "api/crypto/frame_encryptor_interface.h" |
| 23 | #include "api/function_view.h" |
| 24 | #include "api/rtc_event_log/rtc_event_log.h" |
| 25 | #include "audio/audio_state.h" |
| 26 | #include "audio/channel_send.h" |
| 27 | #include "audio/conversion.h" |
| 28 | #include "call/rtp_config.h" |
| 29 | #include "call/rtp_transport_controller_send_interface.h" |
| 30 | #include "common_audio/vad/include/vad.h" |
| 31 | #include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h" |
| 32 | #include "logging/rtc_event_log/rtc_stream_config.h" |
| 33 | #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" |
| 34 | #include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h" |
| 35 | #include "modules/audio_processing/include/audio_processing.h" |
| 36 | #include "modules/rtp_rtcp/source/rtp_header_extensions.h" |
| 37 | #include "rtc_base/checks.h" |
| 38 | #include "rtc_base/event.h" |
| 39 | #include "rtc_base/logging.h" |
| 40 | #include "rtc_base/strings/audio_format_to_string.h" |
| 41 | #include "rtc_base/task_queue.h" |
| 42 | #include "system_wrappers/include/field_trial.h" |
| 43 |
| 44 | namespace webrtc { |
| 45 | namespace { |
| 46 |
| 47 | void UpdateEventLogStreamConfig(RtcEventLog* event_log, |
| 48 | const AudioSendStream::Config& config, |
| 49 | const AudioSendStream::Config* old_config) { |
| 50 | using SendCodecSpec = AudioSendStream::Config::SendCodecSpec; |
| 51 | // Only update if any of the things we log have changed. |
| 52 | auto payload_types_equal = [](const absl::optional<SendCodecSpec>& a, |
| 53 | const absl::optional<SendCodecSpec>& b) { |
| 54 | if (a.has_value() && b.has_value()) { |
| 55 | return a->format.name == b->format.name && |
| 56 | a->payload_type == b->payload_type; |
| 57 | } |
| 58 | return !a.has_value() && !b.has_value(); |
| 59 | }; |
| 60 |
| 61 | if (old_config && config.rtp.ssrc == old_config->rtp.ssrc && |
| 62 | config.rtp.extensions == old_config->rtp.extensions && |
| 63 | payload_types_equal(config.send_codec_spec, |
| 64 | old_config->send_codec_spec)) { |
| 65 | return; |
| 66 | } |
| 67 |
| 68 | auto rtclog_config = std::make_unique<rtclog::StreamConfig>(); |
| 69 | rtclog_config->local_ssrc = config.rtp.ssrc; |
| 70 | rtclog_config->rtp_extensions = config.rtp.extensions; |
| 71 | if (config.send_codec_spec) { |
| 72 | rtclog_config->codecs.emplace_back(config.send_codec_spec->format.name, |
| 73 | config.send_codec_spec->payload_type, 0); |
| 74 | } |
| 75 | event_log->Log(std::make_unique<RtcEventAudioSendStreamConfig>( |
| 76 | std::move(rtclog_config))); |
| 77 | } |
| 78 | } // namespace |
| 79 |
| 80 | constexpr char AudioAllocationConfig::kKey[]; |
| 81 |
| 82 | std::unique_ptr<StructParametersParser> AudioAllocationConfig::Parser() { |
| 83 | return StructParametersParser::Create( // |
| 84 | "min", &min_bitrate, // |
| 85 | "max", &max_bitrate, // |
| 86 | "prio_rate", &priority_bitrate, // |
| 87 | "prio_rate_raw", &priority_bitrate_raw, // |
| 88 | "rate_prio", &bitrate_priority); |
| 89 | } |
| 90 |
| 91 | AudioAllocationConfig::AudioAllocationConfig() { |
| 92 | Parser()->Parse(field_trial::FindFullName(kKey)); |
| 93 | if (priority_bitrate_raw && !priority_bitrate.IsZero()) { |
| 94 | RTC_LOG(LS_WARNING) << "'priority_bitrate' and '_raw' are mutually " |
| 95 | "exclusive but both were configured."; |
| 96 | } |
| 97 | } |
| 98 |
| 99 | namespace internal { |
| 100 | AudioSendStream::AudioSendStream( |
| 101 | Clock* clock, |
| 102 | const webrtc::AudioSendStream::Config& config, |
| 103 | const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 104 | TaskQueueFactory* task_queue_factory, |
| 105 | RtpTransportControllerSendInterface* rtp_transport, |
| 106 | BitrateAllocatorInterface* bitrate_allocator, |
| 107 | RtcEventLog* event_log, |
| 108 | RtcpRttStats* rtcp_rtt_stats, |
| 109 | const absl::optional<RtpState>& suspended_rtp_state) |
| 110 | : AudioSendStream(clock, |
| 111 | config, |
| 112 | audio_state, |
| 113 | task_queue_factory, |
| 114 | rtp_transport, |
| 115 | bitrate_allocator, |
| 116 | event_log, |
| 117 | suspended_rtp_state, |
| 118 | voe::CreateChannelSend( |
| 119 | clock, |
| 120 | task_queue_factory, |
| 121 | config.send_transport, |
| 122 | rtcp_rtt_stats, |
| 123 | event_log, |
| 124 | config.frame_encryptor, |
| 125 | config.crypto_options, |
| 126 | config.rtp.extmap_allow_mixed, |
| 127 | config.rtcp_report_interval_ms, |
| 128 | config.rtp.ssrc, |
| 129 | config.frame_transformer, |
| 130 | rtp_transport->transport_feedback_observer())) {} |
| 131 |
| 132 | AudioSendStream::AudioSendStream( |
| 133 | Clock* clock, |
| 134 | const webrtc::AudioSendStream::Config& config, |
| 135 | const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 136 | TaskQueueFactory* task_queue_factory, |
| 137 | RtpTransportControllerSendInterface* rtp_transport, |
| 138 | BitrateAllocatorInterface* bitrate_allocator, |
| 139 | RtcEventLog* event_log, |
| 140 | const absl::optional<RtpState>& suspended_rtp_state, |
| 141 | std::unique_ptr<voe::ChannelSendInterface> channel_send) |
| 142 | : clock_(clock), |
| 143 | rtp_transport_queue_(rtp_transport->GetWorkerQueue()), |
| 144 | allocate_audio_without_feedback_( |
| 145 | field_trial::IsEnabled("WebRTC-Audio-ABWENoTWCC")), |
| 146 | enable_audio_alr_probing_( |
| 147 | !field_trial::IsDisabled("WebRTC-Audio-AlrProbing")), |
| 148 | send_side_bwe_with_overhead_( |
| 149 | !field_trial::IsDisabled("WebRTC-SendSideBwe-WithOverhead")), |
| 150 | config_(Config(/*send_transport=*/nullptr)), |
| 151 | audio_state_(audio_state), |
| 152 | channel_send_(std::move(channel_send)), |
| 153 | event_log_(event_log), |
| 154 | use_legacy_overhead_calculation_( |
| 155 | field_trial::IsEnabled("WebRTC-Audio-LegacyOverhead")), |
| 156 | bitrate_allocator_(bitrate_allocator), |
| 157 | rtp_transport_(rtp_transport), |
| 158 | rtp_rtcp_module_(channel_send_->GetRtpRtcp()), |
| 159 | suspended_rtp_state_(suspended_rtp_state) { |
| 160 | RTC_LOG(LS_INFO) << "AudioSendStream: " << config.rtp.ssrc; |
| 161 | RTC_DCHECK(rtp_transport_queue_); |
| 162 | RTC_DCHECK(audio_state_); |
| 163 | RTC_DCHECK(channel_send_); |
| 164 | RTC_DCHECK(bitrate_allocator_); |
| 165 | RTC_DCHECK(rtp_transport); |
| 166 |
| 167 | RTC_DCHECK(rtp_rtcp_module_); |
| 168 |
| 169 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 170 | ConfigureStream(config, true); |
| 171 | UpdateCachedTargetAudioBitrateConstraints(); |
| 172 | pacer_thread_checker_.Detach(); |
| 173 | } |
| 174 |
| 175 | AudioSendStream::~AudioSendStream() { |
| 176 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 177 | RTC_LOG(LS_INFO) << "~AudioSendStream: " << config_.rtp.ssrc; |
| 178 | RTC_DCHECK(!sending_); |
| 179 | channel_send_->ResetSenderCongestionControlObjects(); |
| 180 | // Blocking call to synchronize state with worker queue to ensure that there |
| 181 | // are no pending tasks left that keeps references to audio. |
| 182 | rtc::Event thread_sync_event; |
| 183 | rtp_transport_queue_->PostTask([&] { thread_sync_event.Set(); }); |
| 184 | thread_sync_event.Wait(rtc::Event::kForever); |
| 185 | } |
| 186 |
| 187 | const webrtc::AudioSendStream::Config& AudioSendStream::GetConfig() const { |
| 188 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 189 | return config_; |
| 190 | } |
| 191 |
| 192 | void AudioSendStream::Reconfigure( |
| 193 | const webrtc::AudioSendStream::Config& new_config) { |
| 194 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 195 | ConfigureStream(new_config, false); |
| 196 | } |
| 197 |
| 198 | AudioSendStream::ExtensionIds AudioSendStream::FindExtensionIds( |
| 199 | const std::vector<RtpExtension>& extensions) { |
| 200 | ExtensionIds ids; |
| 201 | for (const auto& extension : extensions) { |
| 202 | if (extension.uri == RtpExtension::kAudioLevelUri) { |
| 203 | ids.audio_level = extension.id; |
| 204 | } else if (extension.uri == RtpExtension::kAbsSendTimeUri) { |
| 205 | ids.abs_send_time = extension.id; |
| 206 | } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { |
| 207 | ids.transport_sequence_number = extension.id; |
| 208 | } else if (extension.uri == RtpExtension::kMidUri) { |
| 209 | ids.mid = extension.id; |
| 210 | } else if (extension.uri == RtpExtension::kRidUri) { |
| 211 | ids.rid = extension.id; |
| 212 | } else if (extension.uri == RtpExtension::kRepairedRidUri) { |
| 213 | ids.repaired_rid = extension.id; |
| 214 | } else if (extension.uri == RtpExtension::kAbsoluteCaptureTimeUri) { |
| 215 | ids.abs_capture_time = extension.id; |
| 216 | } |
| 217 | } |
| 218 | return ids; |
| 219 | } |
| 220 |
| 221 | int AudioSendStream::TransportSeqNumId(const AudioSendStream::Config& config) { |
| 222 | return FindExtensionIds(config.rtp.extensions).transport_sequence_number; |
| 223 | } |
| 224 |
| 225 | void AudioSendStream::ConfigureStream( |
| 226 | const webrtc::AudioSendStream::Config& new_config, |
| 227 | bool first_time) { |
| 228 | RTC_LOG(LS_INFO) << "AudioSendStream::ConfigureStream: " |
| 229 | << new_config.ToString(); |
| 230 | UpdateEventLogStreamConfig(event_log_, new_config, |
| 231 | first_time ? nullptr : &config_); |
| 232 |
| 233 | const auto& old_config = config_; |
| 234 |
| 235 | // Configuration parameters which cannot be changed. |
| 236 | RTC_DCHECK(first_time || |
| 237 | old_config.send_transport == new_config.send_transport); |
| 238 | RTC_DCHECK(first_time || old_config.rtp.ssrc == new_config.rtp.ssrc); |
| 239 | if (suspended_rtp_state_ && first_time) { |
| 240 | rtp_rtcp_module_->SetRtpState(*suspended_rtp_state_); |
| 241 | } |
| 242 | if (first_time || old_config.rtp.c_name != new_config.rtp.c_name) { |
| 243 | channel_send_->SetRTCP_CNAME(new_config.rtp.c_name); |
| 244 | } |
| 245 |
| 246 | // Enable the frame encryptor if a new frame encryptor has been provided. |
| 247 | if (first_time || new_config.frame_encryptor != old_config.frame_encryptor) { |
| 248 | channel_send_->SetFrameEncryptor(new_config.frame_encryptor); |
| 249 | } |
| 250 |
| 251 | if (first_time || |
| 252 | new_config.frame_transformer != old_config.frame_transformer) { |
| 253 | channel_send_->SetEncoderToPacketizerFrameTransformer( |
| 254 | new_config.frame_transformer); |
| 255 | } |
| 256 |
| 257 | if (first_time || |
| 258 | new_config.rtp.extmap_allow_mixed != old_config.rtp.extmap_allow_mixed) { |
| 259 | rtp_rtcp_module_->SetExtmapAllowMixed(new_config.rtp.extmap_allow_mixed); |
| 260 | } |
| 261 |
| 262 | const ExtensionIds old_ids = FindExtensionIds(old_config.rtp.extensions); |
| 263 | const ExtensionIds new_ids = FindExtensionIds(new_config.rtp.extensions); |
| 264 |
| 265 | // Audio level indication |
| 266 | if (first_time || new_ids.audio_level != old_ids.audio_level) { |
| 267 | channel_send_->SetSendAudioLevelIndicationStatus(new_ids.audio_level != 0, |
| 268 | new_ids.audio_level); |
| 269 | } |
| 270 |
| 271 | if (first_time || new_ids.abs_send_time != old_ids.abs_send_time) { |
| 272 | absl::string_view uri = AbsoluteSendTime::Uri(); |
| 273 | rtp_rtcp_module_->DeregisterSendRtpHeaderExtension(uri); |
| 274 | if (new_ids.abs_send_time) { |
| 275 | rtp_rtcp_module_->RegisterRtpHeaderExtension(uri, new_ids.abs_send_time); |
| 276 | } |
| 277 | } |
| 278 |
| 279 | bool transport_seq_num_id_changed = |
| 280 | new_ids.transport_sequence_number != old_ids.transport_sequence_number; |
| 281 | if (first_time || |
| 282 | (transport_seq_num_id_changed && !allocate_audio_without_feedback_)) { |
| 283 | if (!first_time) { |
| 284 | channel_send_->ResetSenderCongestionControlObjects(); |
| 285 | } |
| 286 |
| 287 | RtcpBandwidthObserver* bandwidth_observer = nullptr; |
| 288 |
| 289 | if (!allocate_audio_without_feedback_ && |
| 290 | new_ids.transport_sequence_number != 0) { |
| 291 | rtp_rtcp_module_->RegisterRtpHeaderExtension( |
| 292 | TransportSequenceNumber::Uri(), new_ids.transport_sequence_number); |
| 293 | // Probing in application limited region is only used in combination with |
| 294 | // send side congestion control, wich depends on feedback packets which |
| 295 | // requires transport sequence numbers to be enabled. |
| 296 | // Optionally request ALR probing but do not override any existing |
| 297 | // request from other streams. |
| 298 | if (enable_audio_alr_probing_) { |
| 299 | rtp_transport_->EnablePeriodicAlrProbing(true); |
| 300 | } |
| 301 | bandwidth_observer = rtp_transport_->GetBandwidthObserver(); |
| 302 | } |
| 303 | channel_send_->RegisterSenderCongestionControlObjects(rtp_transport_, |
| 304 | bandwidth_observer); |
| 305 | } |
| 306 | // MID RTP header extension. |
| 307 | if ((first_time || new_ids.mid != old_ids.mid || |
| 308 | new_config.rtp.mid != old_config.rtp.mid) && |
| 309 | new_ids.mid != 0 && !new_config.rtp.mid.empty()) { |
| 310 | rtp_rtcp_module_->RegisterRtpHeaderExtension(RtpMid::Uri(), new_ids.mid); |
| 311 | rtp_rtcp_module_->SetMid(new_config.rtp.mid); |
| 312 | } |
| 313 |
| 314 | if (first_time || new_ids.abs_capture_time != old_ids.abs_capture_time) { |
| 315 | absl::string_view uri = AbsoluteCaptureTimeExtension::Uri(); |
| 316 | rtp_rtcp_module_->DeregisterSendRtpHeaderExtension(uri); |
| 317 | if (new_ids.abs_capture_time) { |
| 318 | rtp_rtcp_module_->RegisterRtpHeaderExtension(uri, |
| 319 | new_ids.abs_capture_time); |
| 320 | } |
| 321 | } |
| 322 |
| 323 | if (!ReconfigureSendCodec(new_config)) { |
| 324 | RTC_LOG(LS_ERROR) << "Failed to set up send codec state."; |
| 325 | } |
| 326 |
| 327 | // Set currently known overhead (used in ANA, opus only). |
| 328 | { |
| 329 | MutexLock lock(&overhead_per_packet_lock_); |
| 330 | UpdateOverheadForEncoder(); |
| 331 | } |
| 332 |
| 333 | channel_send_->CallEncoder([this](AudioEncoder* encoder) { |
| 334 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 335 | if (!encoder) { |
| 336 | return; |
| 337 | } |
| 338 | frame_length_range_ = encoder->GetFrameLengthRange(); |
| 339 | UpdateCachedTargetAudioBitrateConstraints(); |
| 340 | }); |
| 341 |
| 342 | if (sending_) { |
| 343 | ReconfigureBitrateObserver(new_config); |
| 344 | } |
| 345 |
| 346 | config_ = new_config; |
| 347 | if (!first_time) { |
| 348 | UpdateCachedTargetAudioBitrateConstraints(); |
| 349 | } |
| 350 | } |
| 351 |
| 352 | void AudioSendStream::Start() { |
| 353 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 354 | if (sending_) { |
| 355 | return; |
| 356 | } |
| 357 | if (!config_.has_dscp && config_.min_bitrate_bps != -1 && |
| 358 | config_.max_bitrate_bps != -1 && |
| 359 | (allocate_audio_without_feedback_ || TransportSeqNumId(config_) != 0)) { |
| 360 | rtp_transport_->AccountForAudioPacketsInPacedSender(true); |
| 361 | if (send_side_bwe_with_overhead_) |
| 362 | rtp_transport_->IncludeOverheadInPacedSender(); |
| 363 | rtp_rtcp_module_->SetAsPartOfAllocation(true); |
| 364 | ConfigureBitrateObserver(); |
| 365 | } else { |
| 366 | rtp_rtcp_module_->SetAsPartOfAllocation(false); |
| 367 | } |
| 368 | channel_send_->StartSend(); |
| 369 | sending_ = true; |
| 370 | audio_state()->AddSendingStream(this, encoder_sample_rate_hz_, |
| 371 | encoder_num_channels_); |
| 372 | } |
| 373 |
| 374 | void AudioSendStream::Stop() { |
| 375 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 376 | if (!sending_) { |
| 377 | return; |
| 378 | } |
| 379 |
| 380 | RemoveBitrateObserver(); |
| 381 | channel_send_->StopSend(); |
| 382 | sending_ = false; |
| 383 | audio_state()->RemoveSendingStream(this); |
| 384 | } |
| 385 |
| 386 | void AudioSendStream::SendAudioData(std::unique_ptr<AudioFrame> audio_frame) { |
| 387 | RTC_CHECK_RUNS_SERIALIZED(&audio_capture_race_checker_); |
| 388 | RTC_DCHECK_GT(audio_frame->sample_rate_hz_, 0); |
| 389 | double duration = static_cast<double>(audio_frame->samples_per_channel_) / |
| 390 | audio_frame->sample_rate_hz_; |
| 391 | { |
| 392 | // Note: SendAudioData() passes the frame further down the pipeline and it |
| 393 | // may eventually get sent. But this method is invoked even if we are not |
| 394 | // connected, as long as we have an AudioSendStream (created as a result of |
| 395 | // an O/A exchange). This means that we are calculating audio levels whether |
| 396 | // or not we are sending samples. |
| 397 | // TODO(https://crbug.com/webrtc/10771): All "media-source" related stats |
| 398 | // should move from send-streams to the local audio sources or tracks; a |
| 399 | // send-stream should not be required to read the microphone audio levels. |
| 400 | MutexLock lock(&audio_level_lock_); |
| 401 | audio_level_.ComputeLevel(*audio_frame, duration); |
| 402 | } |
| 403 | channel_send_->ProcessAndEncodeAudio(std::move(audio_frame)); |
| 404 | } |
| 405 |
| 406 | bool AudioSendStream::SendTelephoneEvent(int payload_type, |
| 407 | int payload_frequency, |
| 408 | int event, |
| 409 | int duration_ms) { |
| 410 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 411 | channel_send_->SetSendTelephoneEventPayloadType(payload_type, |
| 412 | payload_frequency); |
| 413 | return channel_send_->SendTelephoneEventOutband(event, duration_ms); |
| 414 | } |
| 415 |
| 416 | void AudioSendStream::SetMuted(bool muted) { |
| 417 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 418 | channel_send_->SetInputMute(muted); |
| 419 | } |
| 420 |
| 421 | webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { |
| 422 | return GetStats(true); |
| 423 | } |
| 424 |
| 425 | webrtc::AudioSendStream::Stats AudioSendStream::GetStats( |
| 426 | bool has_remote_tracks) const { |
| 427 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 428 | webrtc::AudioSendStream::Stats stats; |
| 429 | stats.local_ssrc = config_.rtp.ssrc; |
| 430 | stats.target_bitrate_bps = channel_send_->GetTargetBitrate(); |
| 431 |
| 432 | webrtc::CallSendStatistics call_stats = channel_send_->GetRTCPStatistics(); |
| 433 | stats.payload_bytes_sent = call_stats.payload_bytes_sent; |
| 434 | stats.header_and_padding_bytes_sent = |
| 435 | call_stats.header_and_padding_bytes_sent; |
| 436 | stats.retransmitted_bytes_sent = call_stats.retransmitted_bytes_sent; |
| 437 | stats.packets_sent = call_stats.packetsSent; |
| 438 | stats.retransmitted_packets_sent = call_stats.retransmitted_packets_sent; |
| 439 | // RTT isn't known until a RTCP report is received. Until then, VoiceEngine |
| 440 | // returns 0 to indicate an error value. |
| 441 | if (call_stats.rttMs > 0) { |
| 442 | stats.rtt_ms = call_stats.rttMs; |
| 443 | } |
| 444 | if (config_.send_codec_spec) { |
| 445 | const auto& spec = *config_.send_codec_spec; |
| 446 | stats.codec_name = spec.format.name; |
| 447 | stats.codec_payload_type = spec.payload_type; |
| 448 |
| 449 | // Get data from the last remote RTCP report. |
| 450 | for (const auto& block : channel_send_->GetRemoteRTCPReportBlocks()) { |
| 451 | // Lookup report for send ssrc only. |
| 452 | if (block.source_SSRC == stats.local_ssrc) { |
| 453 | stats.packets_lost = block.cumulative_num_packets_lost; |
| 454 | stats.fraction_lost = Q8ToFloat(block.fraction_lost); |
| 455 | // Convert timestamps to milliseconds. |
| 456 | if (spec.format.clockrate_hz / 1000 > 0) { |
| 457 | stats.jitter_ms = |
| 458 | block.interarrival_jitter / (spec.format.clockrate_hz / 1000); |
| 459 | } |
| 460 | break; |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 |
| 465 | { |
| 466 | MutexLock lock(&audio_level_lock_); |
| 467 | stats.audio_level = audio_level_.LevelFullRange(); |
| 468 | stats.total_input_energy = audio_level_.TotalEnergy(); |
| 469 | stats.total_input_duration = audio_level_.TotalDuration(); |
| 470 | } |
| 471 |
| 472 | stats.typing_noise_detected = audio_state()->typing_noise_detected(); |
| 473 | stats.ana_statistics = channel_send_->GetANAStatistics(); |
| 474 |
| 475 | AudioProcessing* ap = audio_state_->audio_processing(); |
| 476 | if (ap) { |
| 477 | stats.apm_statistics = ap->GetStatistics(has_remote_tracks); |
| 478 | } |
| 479 |
| 480 | stats.report_block_datas = std::move(call_stats.report_block_datas); |
| 481 |
| 482 | stats.nacks_rcvd = call_stats.nacks_rcvd; |
| 483 |
| 484 | return stats; |
| 485 | } |
| 486 |
| 487 | void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 488 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 489 | channel_send_->ReceivedRTCPPacket(packet, length); |
| 490 |
| 491 | { |
| 492 | // Poll if overhead has changed, which it can do if ack triggers us to stop |
| 493 | // sending mid/rid. |
| 494 | MutexLock lock(&overhead_per_packet_lock_); |
| 495 | UpdateOverheadForEncoder(); |
| 496 | } |
| 497 | UpdateCachedTargetAudioBitrateConstraints(); |
| 498 | } |
| 499 |
| 500 | uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { |
| 501 | RTC_DCHECK_RUN_ON(rtp_transport_queue_); |
| 502 |
| 503 | // Pick a target bitrate between the constraints. Overrules the allocator if |
| 504 | // it 1) allocated a bitrate of zero to disable the stream or 2) allocated a |
| 505 | // higher than max to allow for e.g. extra FEC. |
| 506 | RTC_DCHECK(cached_constraints_.has_value()); |
| 507 | update.target_bitrate.Clamp(cached_constraints_->min, |
| 508 | cached_constraints_->max); |
| 509 | update.stable_target_bitrate.Clamp(cached_constraints_->min, |
| 510 | cached_constraints_->max); |
| 511 |
| 512 | channel_send_->OnBitrateAllocation(update); |
| 513 |
| 514 | // The amount of audio protection is not exposed by the encoder, hence |
| 515 | // always returning 0. |
| 516 | return 0; |
| 517 | } |
| 518 |
| 519 | void AudioSendStream::SetTransportOverhead( |
| 520 | int transport_overhead_per_packet_bytes) { |
| 521 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 522 | { |
| 523 | MutexLock lock(&overhead_per_packet_lock_); |
| 524 | transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes; |
| 525 | UpdateOverheadForEncoder(); |
| 526 | } |
| 527 | UpdateCachedTargetAudioBitrateConstraints(); |
| 528 | } |
| 529 |
| 530 | void AudioSendStream::UpdateOverheadForEncoder() { |
| 531 | RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 532 | size_t overhead_per_packet_bytes = GetPerPacketOverheadBytes(); |
| 533 | if (overhead_per_packet_ == overhead_per_packet_bytes) { |
| 534 | return; |
| 535 | } |
| 536 | overhead_per_packet_ = overhead_per_packet_bytes; |
| 537 |
| 538 | channel_send_->CallEncoder([&](AudioEncoder* encoder) { |
| 539 | encoder->OnReceivedOverhead(overhead_per_packet_bytes); |
| 540 | }); |
| 541 | if (total_packet_overhead_bytes_ != overhead_per_packet_bytes) { |
| 542 | total_packet_overhead_bytes_ = overhead_per_packet_bytes; |
| 543 | if (registered_with_allocator_) { |
| 544 | ConfigureBitrateObserver(); |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 |
| 549 | size_t AudioSendStream::TestOnlyGetPerPacketOverheadBytes() const { |
| 550 | MutexLock lock(&overhead_per_packet_lock_); |
| 551 | return GetPerPacketOverheadBytes(); |
| 552 | } |
| 553 |
| 554 | size_t AudioSendStream::GetPerPacketOverheadBytes() const { |
| 555 | return transport_overhead_per_packet_bytes_ + |
| 556 | rtp_rtcp_module_->ExpectedPerPacketOverhead(); |
| 557 | } |
| 558 |
| 559 | RtpState AudioSendStream::GetRtpState() const { |
| 560 | return rtp_rtcp_module_->GetRtpState(); |
| 561 | } |
| 562 |
| 563 | const voe::ChannelSendInterface* AudioSendStream::GetChannel() const { |
| 564 | return channel_send_.get(); |
| 565 | } |
| 566 |
| 567 | internal::AudioState* AudioSendStream::audio_state() { |
| 568 | internal::AudioState* audio_state = |
| 569 | static_cast<internal::AudioState*>(audio_state_.get()); |
| 570 | RTC_DCHECK(audio_state); |
| 571 | return audio_state; |
| 572 | } |
| 573 |
| 574 | const internal::AudioState* AudioSendStream::audio_state() const { |
| 575 | internal::AudioState* audio_state = |
| 576 | static_cast<internal::AudioState*>(audio_state_.get()); |
| 577 | RTC_DCHECK(audio_state); |
| 578 | return audio_state; |
| 579 | } |
| 580 |
| 581 | void AudioSendStream::StoreEncoderProperties(int sample_rate_hz, |
| 582 | size_t num_channels) { |
| 583 | encoder_sample_rate_hz_ = sample_rate_hz; |
| 584 | encoder_num_channels_ = num_channels; |
| 585 | if (sending_) { |
| 586 | // Update AudioState's information about the stream. |
| 587 | audio_state()->AddSendingStream(this, sample_rate_hz, num_channels); |
| 588 | } |
| 589 | } |
| 590 |
| 591 | // Apply current codec settings to a single voe::Channel used for sending. |
| 592 | bool AudioSendStream::SetupSendCodec(const Config& new_config) { |
| 593 | RTC_DCHECK(new_config.send_codec_spec); |
| 594 | const auto& spec = *new_config.send_codec_spec; |
| 595 |
| 596 | RTC_DCHECK(new_config.encoder_factory); |
| 597 | std::unique_ptr<AudioEncoder> encoder = |
| 598 | new_config.encoder_factory->MakeAudioEncoder( |
| 599 | spec.payload_type, spec.format, new_config.codec_pair_id); |
| 600 |
| 601 | if (!encoder) { |
| 602 | RTC_DLOG(LS_ERROR) << "Unable to create encoder for " |
| 603 | << rtc::ToString(spec.format); |
| 604 | return false; |
| 605 | } |
| 606 |
| 607 | // If a bitrate has been specified for the codec, use it over the |
| 608 | // codec's default. |
| 609 | if (spec.target_bitrate_bps) { |
| 610 | encoder->OnReceivedTargetAudioBitrate(*spec.target_bitrate_bps); |
| 611 | } |
| 612 |
| 613 | // Enable ANA if configured (currently only used by Opus). |
| 614 | if (new_config.audio_network_adaptor_config) { |
| 615 | if (encoder->EnableAudioNetworkAdaptor( |
| 616 | *new_config.audio_network_adaptor_config, event_log_)) { |
| 617 | RTC_LOG(LS_INFO) << "Audio network adaptor enabled on SSRC " |
| 618 | << new_config.rtp.ssrc; |
| 619 | } else { |
| 620 | RTC_LOG(LS_INFO) << "Failed to enable Audio network adaptor on SSRC " |
| 621 | << new_config.rtp.ssrc; |
| 622 | } |
| 623 | } |
| 624 |
| 625 | // Wrap the encoder in an AudioEncoderCNG, if VAD is enabled. |
| 626 | if (spec.cng_payload_type) { |
| 627 | AudioEncoderCngConfig cng_config; |
| 628 | cng_config.num_channels = encoder->NumChannels(); |
| 629 | cng_config.payload_type = *spec.cng_payload_type; |
| 630 | cng_config.speech_encoder = std::move(encoder); |
| 631 | cng_config.vad_mode = Vad::kVadNormal; |
| 632 | encoder = CreateComfortNoiseEncoder(std::move(cng_config)); |
| 633 |
| 634 | RegisterCngPayloadType(*spec.cng_payload_type, |
| 635 | new_config.send_codec_spec->format.clockrate_hz); |
| 636 | } |
| 637 |
| 638 | // Wrap the encoder in a RED encoder, if RED is enabled. |
| 639 | if (spec.red_payload_type) { |
| 640 | AudioEncoderCopyRed::Config red_config; |
| 641 | red_config.payload_type = *spec.red_payload_type; |
| 642 | red_config.speech_encoder = std::move(encoder); |
| 643 | encoder = std::make_unique<AudioEncoderCopyRed>(std::move(red_config)); |
| 644 | } |
| 645 |
| 646 | // Set currently known overhead (used in ANA, opus only). |
| 647 | // If overhead changes later, it will be updated in UpdateOverheadForEncoder. |
| 648 | { |
| 649 | MutexLock lock(&overhead_per_packet_lock_); |
| 650 | size_t overhead = GetPerPacketOverheadBytes(); |
| 651 | if (overhead > 0) { |
| 652 | encoder->OnReceivedOverhead(overhead); |
| 653 | } |
| 654 | } |
| 655 |
| 656 | StoreEncoderProperties(encoder->SampleRateHz(), encoder->NumChannels()); |
| 657 | channel_send_->SetEncoder(new_config.send_codec_spec->payload_type, |
| 658 | std::move(encoder)); |
| 659 |
| 660 | return true; |
| 661 | } |
| 662 |
| 663 | bool AudioSendStream::ReconfigureSendCodec(const Config& new_config) { |
| 664 | const auto& old_config = config_; |
| 665 |
| 666 | if (!new_config.send_codec_spec) { |
| 667 | // We cannot de-configure a send codec. So we will do nothing. |
| 668 | // By design, the send codec should have not been configured. |
| 669 | RTC_DCHECK(!old_config.send_codec_spec); |
| 670 | return true; |
| 671 | } |
| 672 |
| 673 | if (new_config.send_codec_spec == old_config.send_codec_spec && |
| 674 | new_config.audio_network_adaptor_config == |
| 675 | old_config.audio_network_adaptor_config) { |
| 676 | return true; |
| 677 | } |
| 678 |
| 679 | // If we have no encoder, or the format or payload type's changed, create a |
| 680 | // new encoder. |
| 681 | if (!old_config.send_codec_spec || |
| 682 | new_config.send_codec_spec->format != |
| 683 | old_config.send_codec_spec->format || |
| 684 | new_config.send_codec_spec->payload_type != |
| 685 | old_config.send_codec_spec->payload_type || |
| 686 | new_config.send_codec_spec->red_payload_type != |
| 687 | old_config.send_codec_spec->red_payload_type) { |
| 688 | return SetupSendCodec(new_config); |
| 689 | } |
| 690 |
| 691 | const absl::optional<int>& new_target_bitrate_bps = |
| 692 | new_config.send_codec_spec->target_bitrate_bps; |
| 693 | // If a bitrate has been specified for the codec, use it over the |
| 694 | // codec's default. |
| 695 | if (new_target_bitrate_bps && |
| 696 | new_target_bitrate_bps != |
| 697 | old_config.send_codec_spec->target_bitrate_bps) { |
| 698 | channel_send_->CallEncoder([&](AudioEncoder* encoder) { |
| 699 | encoder->OnReceivedTargetAudioBitrate(*new_target_bitrate_bps); |
| 700 | }); |
| 701 | } |
| 702 |
| 703 | ReconfigureANA(new_config); |
| 704 | ReconfigureCNG(new_config); |
| 705 |
| 706 | return true; |
| 707 | } |
| 708 |
| 709 | void AudioSendStream::ReconfigureANA(const Config& new_config) { |
| 710 | if (new_config.audio_network_adaptor_config == |
| 711 | config_.audio_network_adaptor_config) { |
| 712 | return; |
| 713 | } |
| 714 | if (new_config.audio_network_adaptor_config) { |
| 715 | // This lock needs to be acquired before CallEncoder, since it aquires |
| 716 | // another lock and we need to maintain the same order at all call sites to |
| 717 | // avoid deadlock. |
| 718 | MutexLock lock(&overhead_per_packet_lock_); |
| 719 | size_t overhead = GetPerPacketOverheadBytes(); |
| 720 | channel_send_->CallEncoder([&](AudioEncoder* encoder) { |
| 721 | if (encoder->EnableAudioNetworkAdaptor( |
| 722 | *new_config.audio_network_adaptor_config, event_log_)) { |
| 723 | RTC_LOG(LS_INFO) << "Audio network adaptor enabled on SSRC " |
| 724 | << new_config.rtp.ssrc; |
| 725 | if (overhead > 0) { |
| 726 | encoder->OnReceivedOverhead(overhead); |
| 727 | } |
| 728 | } else { |
| 729 | RTC_LOG(LS_INFO) << "Failed to enable Audio network adaptor on SSRC " |
| 730 | << new_config.rtp.ssrc; |
| 731 | } |
| 732 | }); |
| 733 | } else { |
| 734 | channel_send_->CallEncoder( |
| 735 | [&](AudioEncoder* encoder) { encoder->DisableAudioNetworkAdaptor(); }); |
| 736 | RTC_LOG(LS_INFO) << "Audio network adaptor disabled on SSRC " |
| 737 | << new_config.rtp.ssrc; |
| 738 | } |
| 739 | } |
| 740 |
| 741 | void AudioSendStream::ReconfigureCNG(const Config& new_config) { |
| 742 | if (new_config.send_codec_spec->cng_payload_type == |
| 743 | config_.send_codec_spec->cng_payload_type) { |
| 744 | return; |
| 745 | } |
| 746 |
| 747 | // Register the CNG payload type if it's been added, don't do anything if CNG |
| 748 | // is removed. Payload types must not be redefined. |
| 749 | if (new_config.send_codec_spec->cng_payload_type) { |
| 750 | RegisterCngPayloadType(*new_config.send_codec_spec->cng_payload_type, |
| 751 | new_config.send_codec_spec->format.clockrate_hz); |
| 752 | } |
| 753 |
| 754 | // Wrap or unwrap the encoder in an AudioEncoderCNG. |
| 755 | channel_send_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder_ptr) { |
| 756 | std::unique_ptr<AudioEncoder> old_encoder(std::move(*encoder_ptr)); |
| 757 | auto sub_encoders = old_encoder->ReclaimContainedEncoders(); |
| 758 | if (!sub_encoders.empty()) { |
| 759 | // Replace enc with its sub encoder. We need to put the sub |
| 760 | // encoder in a temporary first, since otherwise the old value |
| 761 | // of enc would be destroyed before the new value got assigned, |
| 762 | // which would be bad since the new value is a part of the old |
| 763 | // value. |
| 764 | auto tmp = std::move(sub_encoders[0]); |
| 765 | old_encoder = std::move(tmp); |
| 766 | } |
| 767 | if (new_config.send_codec_spec->cng_payload_type) { |
| 768 | AudioEncoderCngConfig config; |
| 769 | config.speech_encoder = std::move(old_encoder); |
| 770 | config.num_channels = config.speech_encoder->NumChannels(); |
| 771 | config.payload_type = *new_config.send_codec_spec->cng_payload_type; |
| 772 | config.vad_mode = Vad::kVadNormal; |
| 773 | *encoder_ptr = CreateComfortNoiseEncoder(std::move(config)); |
| 774 | } else { |
| 775 | *encoder_ptr = std::move(old_encoder); |
| 776 | } |
| 777 | }); |
| 778 | } |
| 779 |
| 780 | void AudioSendStream::ReconfigureBitrateObserver( |
| 781 | const webrtc::AudioSendStream::Config& new_config) { |
| 782 | // Since the Config's default is for both of these to be -1, this test will |
| 783 | // allow us to configure the bitrate observer if the new config has bitrate |
| 784 | // limits set, but would only have us call RemoveBitrateObserver if we were |
| 785 | // previously configured with bitrate limits. |
| 786 | if (config_.min_bitrate_bps == new_config.min_bitrate_bps && |
| 787 | config_.max_bitrate_bps == new_config.max_bitrate_bps && |
| 788 | config_.bitrate_priority == new_config.bitrate_priority && |
| 789 | TransportSeqNumId(config_) == TransportSeqNumId(new_config) && |
| 790 | config_.audio_network_adaptor_config == |
| 791 | new_config.audio_network_adaptor_config) { |
| 792 | return; |
| 793 | } |
| 794 |
| 795 | if (!new_config.has_dscp && new_config.min_bitrate_bps != -1 && |
| 796 | new_config.max_bitrate_bps != -1 && TransportSeqNumId(new_config) != 0) { |
| 797 | rtp_transport_->AccountForAudioPacketsInPacedSender(true); |
| 798 | if (send_side_bwe_with_overhead_) |
| 799 | rtp_transport_->IncludeOverheadInPacedSender(); |
| 800 | // We may get a callback immediately as the observer is registered, so |
| 801 | // make sure the bitrate limits in config_ are up-to-date. |
| 802 | config_.min_bitrate_bps = new_config.min_bitrate_bps; |
| 803 | config_.max_bitrate_bps = new_config.max_bitrate_bps; |
| 804 |
| 805 | config_.bitrate_priority = new_config.bitrate_priority; |
| 806 | ConfigureBitrateObserver(); |
| 807 | rtp_rtcp_module_->SetAsPartOfAllocation(true); |
| 808 | } else { |
| 809 | rtp_transport_->AccountForAudioPacketsInPacedSender(false); |
| 810 | RemoveBitrateObserver(); |
| 811 | rtp_rtcp_module_->SetAsPartOfAllocation(false); |
| 812 | } |
| 813 | } |
| 814 |
| 815 | void AudioSendStream::ConfigureBitrateObserver() { |
| 816 | // This either updates the current observer or adds a new observer. |
| 817 | // TODO(srte): Add overhead compensation here. |
| 818 | auto constraints = GetMinMaxBitrateConstraints(); |
| 819 | RTC_DCHECK(constraints.has_value()); |
| 820 |
| 821 | DataRate priority_bitrate = allocation_settings_.priority_bitrate; |
| 822 | if (send_side_bwe_with_overhead_) { |
| 823 | if (use_legacy_overhead_calculation_) { |
| 824 | // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) |
| 825 | constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; |
| 826 | const TimeDelta kMinPacketDuration = TimeDelta::Millis(20); |
| 827 | DataRate max_overhead = |
| 828 | DataSize::Bytes(kOverheadPerPacket) / kMinPacketDuration; |
| 829 | priority_bitrate += max_overhead; |
| 830 | } else { |
| 831 | RTC_DCHECK(frame_length_range_); |
| 832 | const DataSize overhead_per_packet = |
| 833 | DataSize::Bytes(total_packet_overhead_bytes_); |
| 834 | DataRate min_overhead = overhead_per_packet / frame_length_range_->second; |
| 835 | priority_bitrate += min_overhead; |
| 836 | } |
| 837 | } |
| 838 | if (allocation_settings_.priority_bitrate_raw) |
| 839 | priority_bitrate = *allocation_settings_.priority_bitrate_raw; |
| 840 |
| 841 | rtp_transport_queue_->PostTask([this, constraints, priority_bitrate, |
| 842 | config_bitrate_priority = |
| 843 | config_.bitrate_priority] { |
| 844 | RTC_DCHECK_RUN_ON(rtp_transport_queue_); |
| 845 | bitrate_allocator_->AddObserver( |
| 846 | this, |
| 847 | MediaStreamAllocationConfig{ |
| 848 | constraints->min.bps<uint32_t>(), constraints->max.bps<uint32_t>(), |
| 849 | 0, priority_bitrate.bps(), true, |
| 850 | allocation_settings_.bitrate_priority.value_or( |
| 851 | config_bitrate_priority)}); |
| 852 | }); |
| 853 | registered_with_allocator_ = true; |
| 854 | } |
| 855 |
| 856 | void AudioSendStream::RemoveBitrateObserver() { |
| 857 | registered_with_allocator_ = false; |
| 858 | rtc::Event thread_sync_event; |
| 859 | rtp_transport_queue_->PostTask([this, &thread_sync_event] { |
| 860 | RTC_DCHECK_RUN_ON(rtp_transport_queue_); |
| 861 | bitrate_allocator_->RemoveObserver(this); |
| 862 | thread_sync_event.Set(); |
| 863 | }); |
| 864 | thread_sync_event.Wait(rtc::Event::kForever); |
| 865 | } |
| 866 |
| 867 | absl::optional<AudioSendStream::TargetAudioBitrateConstraints> |
| 868 | AudioSendStream::GetMinMaxBitrateConstraints() const { |
| 869 | if (config_.min_bitrate_bps < 0 || config_.max_bitrate_bps < 0) { |
| 870 | RTC_LOG(LS_WARNING) << "Config is invalid: min_bitrate_bps=" |
| 871 | << config_.min_bitrate_bps |
| 872 | << "; max_bitrate_bps=" << config_.max_bitrate_bps |
| 873 | << "; both expected greater or equal to 0"; |
| 874 | return absl::nullopt; |
| 875 | } |
| 876 | TargetAudioBitrateConstraints constraints{ |
| 877 | DataRate::BitsPerSec(config_.min_bitrate_bps), |
| 878 | DataRate::BitsPerSec(config_.max_bitrate_bps)}; |
| 879 |
| 880 | // If bitrates were explicitly overriden via field trial, use those values. |
| 881 | if (allocation_settings_.min_bitrate) |
| 882 | constraints.min = *allocation_settings_.min_bitrate; |
| 883 | if (allocation_settings_.max_bitrate) |
| 884 | constraints.max = *allocation_settings_.max_bitrate; |
| 885 |
| 886 | RTC_DCHECK_GE(constraints.min, DataRate::Zero()); |
| 887 | RTC_DCHECK_GE(constraints.max, DataRate::Zero()); |
| 888 | if (constraints.max < constraints.min) { |
| 889 | RTC_LOG(LS_WARNING) << "TargetAudioBitrateConstraints::max is less than " |
| 890 | << "TargetAudioBitrateConstraints::min"; |
| 891 | return absl::nullopt; |
| 892 | } |
| 893 | if (send_side_bwe_with_overhead_) { |
| 894 | if (use_legacy_overhead_calculation_) { |
| 895 | // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) |
| 896 | const DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12); |
| 897 | const TimeDelta kMaxFrameLength = |
| 898 | TimeDelta::Millis(60); // Based on Opus spec |
| 899 | const DataRate kMinOverhead = kOverheadPerPacket / kMaxFrameLength; |
| 900 | constraints.min += kMinOverhead; |
| 901 | constraints.max += kMinOverhead; |
| 902 | } else { |
| 903 | if (!frame_length_range_.has_value()) { |
| 904 | RTC_LOG(LS_WARNING) << "frame_length_range_ is not set"; |
| 905 | return absl::nullopt; |
| 906 | } |
| 907 | const DataSize kOverheadPerPacket = |
| 908 | DataSize::Bytes(total_packet_overhead_bytes_); |
| 909 | constraints.min += kOverheadPerPacket / frame_length_range_->second; |
| 910 | constraints.max += kOverheadPerPacket / frame_length_range_->first; |
| 911 | } |
| 912 | } |
| 913 | return constraints; |
| 914 | } |
| 915 |
| 916 | void AudioSendStream::RegisterCngPayloadType(int payload_type, |
| 917 | int clockrate_hz) { |
| 918 | channel_send_->RegisterCngPayloadType(payload_type, clockrate_hz); |
| 919 | } |
| 920 |
| 921 | void AudioSendStream::UpdateCachedTargetAudioBitrateConstraints() { |
| 922 | absl::optional<AudioSendStream::TargetAudioBitrateConstraints> |
| 923 | new_constraints = GetMinMaxBitrateConstraints(); |
| 924 | if (!new_constraints.has_value()) { |
| 925 | return; |
| 926 | } |
| 927 | rtp_transport_queue_->PostTask([this, new_constraints]() { |
| 928 | RTC_DCHECK_RUN_ON(rtp_transport_queue_); |
| 929 | cached_constraints_ = new_constraints; |
| 930 | }); |
| 931 | } |
| 932 |
| 933 | } // namespace internal |
| 934 | } // namespace webrtc |
| 935 |