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