2015-10-16 14:35:07 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/audio_send_stream.h"
|
2015-10-16 14:35:07 -07:00
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
#include <memory>
|
2015-10-16 14:35:07 -07:00
|
|
|
#include <string>
|
2017-04-27 02:08:52 -07:00
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
2015-10-16 14:35:07 -07:00
|
|
|
|
2024-04-19 15:07:08 +00:00
|
|
|
#include "api/audio/audio_processing.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "api/audio_codecs/audio_encoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
|
|
|
|
#include "api/audio_codecs/audio_format.h"
|
|
|
|
|
#include "api/call/transport.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/frame_encryptor_interface.h"
|
2019-03-21 14:37:36 +01:00
|
|
|
#include "api/function_view.h"
|
2019-08-07 12:24:53 +02:00
|
|
|
#include "api/rtc_event_log/rtc_event_log.h"
|
2022-10-10 12:53:41 +02:00
|
|
|
#include "api/task_queue/task_queue_base.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/audio_state.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "audio/channel_send.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/conversion.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "call/rtp_config.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/rtp_transport_controller_send_interface.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "common_audio/vad/include/vad.h"
|
2018-10-30 16:11:02 +01:00
|
|
|
#include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h"
|
|
|
|
|
#include "logging/rtc_event_log/rtc_stream_config.h"
|
2022-10-18 17:05:16 +02:00
|
|
|
#include "media/base/media_channel.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
2020-06-24 12:52:42 +02:00
|
|
|
#include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
|
2020-01-14 17:55:19 +01:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
2018-04-03 13:40:05 +02:00
|
|
|
#include "rtc_base/strings/audio_format_to_string.h"
|
2022-09-27 15:22:34 +02:00
|
|
|
#include "rtc_base/trace_event.h"
|
2015-10-16 14:35:07 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2018-01-11 13:52:30 +01:00
|
|
|
namespace {
|
2017-03-23 11:04:48 -07:00
|
|
|
|
2024-05-28 18:16:53 +02:00
|
|
|
void UpdateEventLogStreamConfig(RtcEventLog& event_log,
|
2018-10-30 16:11:02 +01:00
|
|
|
const AudioSendStream::Config& config,
|
|
|
|
|
const AudioSendStream::Config* old_config) {
|
|
|
|
|
using SendCodecSpec = AudioSendStream::Config::SendCodecSpec;
|
|
|
|
|
// Only update if any of the things we log have changed.
|
2024-08-29 13:00:40 +00:00
|
|
|
auto payload_types_equal = [](const std::optional<SendCodecSpec>& a,
|
|
|
|
|
const std::optional<SendCodecSpec>& b) {
|
2018-10-30 16:11:02 +01:00
|
|
|
if (a.has_value() && b.has_value()) {
|
|
|
|
|
return a->format.name == b->format.name &&
|
|
|
|
|
a->payload_type == b->payload_type;
|
|
|
|
|
}
|
|
|
|
|
return !a.has_value() && !b.has_value();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (old_config && config.rtp.ssrc == old_config->rtp.ssrc &&
|
|
|
|
|
config.rtp.extensions == old_config->rtp.extensions &&
|
|
|
|
|
payload_types_equal(config.send_codec_spec,
|
|
|
|
|
old_config->send_codec_spec)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
auto rtclog_config = std::make_unique<rtclog::StreamConfig>();
|
2018-10-30 16:11:02 +01:00
|
|
|
rtclog_config->local_ssrc = config.rtp.ssrc;
|
|
|
|
|
rtclog_config->rtp_extensions = config.rtp.extensions;
|
|
|
|
|
if (config.send_codec_spec) {
|
|
|
|
|
rtclog_config->codecs.emplace_back(config.send_codec_spec->format.name,
|
|
|
|
|
config.send_codec_spec->payload_type, 0);
|
|
|
|
|
}
|
2024-05-28 18:16:53 +02:00
|
|
|
event_log.Log(std::make_unique<RtcEventAudioSendStreamConfig>(
|
2018-10-30 16:11:02 +01:00
|
|
|
std::move(rtclog_config)));
|
|
|
|
|
}
|
2022-10-10 12:53:41 +02:00
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
} // namespace
|
|
|
|
|
|
2019-10-03 10:03:55 +02:00
|
|
|
constexpr char AudioAllocationConfig::kKey[];
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<StructParametersParser> AudioAllocationConfig::Parser() {
|
|
|
|
|
return StructParametersParser::Create( //
|
|
|
|
|
"min", &min_bitrate, //
|
|
|
|
|
"max", &max_bitrate, //
|
|
|
|
|
"prio_rate", &priority_bitrate, //
|
|
|
|
|
"prio_rate_raw", &priority_bitrate_raw, //
|
|
|
|
|
"rate_prio", &bitrate_priority);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-16 13:50:58 +01:00
|
|
|
AudioAllocationConfig::AudioAllocationConfig(
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& field_trials) {
|
2022-03-16 13:50:58 +01:00
|
|
|
Parser()->Parse(field_trials.Lookup(kKey));
|
2019-10-03 10:03:55 +02:00
|
|
|
if (priority_bitrate_raw && !priority_bitrate.IsZero()) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "'priority_bitrate' and '_raw' are mutually "
|
|
|
|
|
"exclusive but both were configured.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace internal {
|
2015-11-06 15:34:49 -08:00
|
|
|
AudioSendStream::AudioSendStream(
|
2024-05-28 18:16:53 +02:00
|
|
|
const Environment& env,
|
2015-11-06 15:34:49 -08:00
|
|
|
const webrtc::AudioSendStream::Config& config,
|
2015-12-07 10:26:18 +01:00
|
|
|
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
2018-10-26 12:57:07 +02:00
|
|
|
RtpTransportControllerSendInterface* rtp_transport,
|
2018-10-22 13:00:40 +02:00
|
|
|
BitrateAllocatorInterface* bitrate_allocator,
|
2017-05-23 06:07:11 -07:00
|
|
|
RtcpRttStats* rtcp_rtt_stats,
|
2024-08-29 13:00:40 +00:00
|
|
|
const std::optional<RtpState>& suspended_rtp_state)
|
2024-05-28 18:16:53 +02:00
|
|
|
: AudioSendStream(env,
|
2023-05-16 13:26:33 +02:00
|
|
|
config,
|
|
|
|
|
audio_state,
|
|
|
|
|
rtp_transport,
|
|
|
|
|
bitrate_allocator,
|
|
|
|
|
suspended_rtp_state,
|
2024-05-28 18:16:53 +02:00
|
|
|
voe::CreateChannelSend(env,
|
2023-05-16 13:26:33 +02:00
|
|
|
config.send_transport,
|
|
|
|
|
rtcp_rtt_stats,
|
|
|
|
|
config.frame_encryptor.get(),
|
|
|
|
|
config.crypto_options,
|
|
|
|
|
config.rtp.extmap_allow_mixed,
|
|
|
|
|
config.rtcp_report_interval_ms,
|
|
|
|
|
config.rtp.ssrc,
|
|
|
|
|
config.frame_transformer,
|
2024-05-28 18:16:53 +02:00
|
|
|
rtp_transport)) {}
|
2018-01-11 13:52:30 +01:00
|
|
|
|
|
|
|
|
AudioSendStream::AudioSendStream(
|
2024-05-28 18:16:53 +02:00
|
|
|
const Environment& env,
|
2018-01-11 13:52:30 +01:00
|
|
|
const webrtc::AudioSendStream::Config& config,
|
|
|
|
|
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
2018-10-26 12:57:07 +02:00
|
|
|
RtpTransportControllerSendInterface* rtp_transport,
|
2018-10-22 13:00:40 +02:00
|
|
|
BitrateAllocatorInterface* bitrate_allocator,
|
2024-08-29 13:00:40 +00:00
|
|
|
const std::optional<RtpState>& suspended_rtp_state,
|
2024-05-28 18:16:53 +02:00
|
|
|
std::unique_ptr<voe::ChannelSendInterface> channel_send)
|
|
|
|
|
: env_(env),
|
2019-10-03 10:03:55 +02:00
|
|
|
allocate_audio_without_feedback_(
|
2024-05-28 18:16:53 +02:00
|
|
|
env_.field_trials().IsEnabled("WebRTC-Audio-ABWENoTWCC")),
|
2019-10-03 10:03:55 +02:00
|
|
|
enable_audio_alr_probing_(
|
2024-05-28 18:16:53 +02:00
|
|
|
!env_.field_trials().IsDisabled("WebRTC-Audio-AlrProbing")),
|
|
|
|
|
allocation_settings_(env_.field_trials()),
|
2019-11-26 09:19:40 -08:00
|
|
|
config_(Config(/*send_transport=*/nullptr)),
|
2016-07-26 04:44:06 -07:00
|
|
|
audio_state_(audio_state),
|
2018-11-19 10:27:07 +01:00
|
|
|
channel_send_(std::move(channel_send)),
|
2019-10-02 12:27:06 +02:00
|
|
|
use_legacy_overhead_calculation_(
|
2024-05-28 18:16:53 +02:00
|
|
|
env_.field_trials().IsEnabled("WebRTC-Audio-LegacyOverhead")),
|
2024-01-29 15:02:59 -08:00
|
|
|
enable_priority_bitrate_(
|
2024-05-28 18:16:53 +02:00
|
|
|
!env_.field_trials().IsDisabled("WebRTC-Audio-PriorityBitrate")),
|
2017-01-16 23:55:07 -08:00
|
|
|
bitrate_allocator_(bitrate_allocator),
|
2018-10-26 12:57:07 +02:00
|
|
|
rtp_transport_(rtp_transport),
|
2020-01-14 17:55:19 +01:00
|
|
|
rtp_rtcp_module_(channel_send_->GetRtpRtcp()),
|
2018-11-20 17:15:13 +01:00
|
|
|
suspended_rtp_state_(suspended_rtp_state) {
|
2018-01-25 10:14:29 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioSendStream: " << config.rtp.ssrc;
|
2018-01-11 13:52:30 +01:00
|
|
|
RTC_DCHECK(audio_state_);
|
2018-11-19 10:27:07 +01:00
|
|
|
RTC_DCHECK(channel_send_);
|
2018-01-11 13:52:30 +01:00
|
|
|
RTC_DCHECK(bitrate_allocator_);
|
2019-03-07 09:17:19 +01:00
|
|
|
RTC_DCHECK(rtp_transport);
|
|
|
|
|
|
2017-05-23 06:07:11 -07:00
|
|
|
RTC_DCHECK(rtp_rtcp_module_);
|
2016-04-29 00:57:13 -07:00
|
|
|
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2022-10-18 17:05:16 +02:00
|
|
|
ConfigureStream(config, true, nullptr);
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioSendStream::~AudioSendStream() {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2018-01-25 10:14:29 +01:00
|
|
|
RTC_LOG(LS_INFO) << "~AudioSendStream: " << config_.rtp.ssrc;
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
RTC_DCHECK(!sending_);
|
2019-10-04 09:31:08 +02:00
|
|
|
channel_send_->ResetSenderCongestionControlObjects();
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
|
|
|
|
|
2017-07-26 02:09:44 -07:00
|
|
|
const webrtc::AudioSendStream::Config& AudioSendStream::GetConfig() const {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2017-07-26 02:09:44 -07:00
|
|
|
return config_;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
void AudioSendStream::Reconfigure(
|
2022-10-18 17:05:16 +02:00
|
|
|
const webrtc::AudioSendStream::Config& new_config,
|
|
|
|
|
SetParametersCallback callback) {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2022-10-18 17:05:16 +02:00
|
|
|
ConfigureStream(new_config, false, std::move(callback));
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2017-12-07 20:54:55 +01:00
|
|
|
AudioSendStream::ExtensionIds AudioSendStream::FindExtensionIds(
|
|
|
|
|
const std::vector<RtpExtension>& extensions) {
|
|
|
|
|
ExtensionIds ids;
|
|
|
|
|
for (const auto& extension : extensions) {
|
|
|
|
|
if (extension.uri == RtpExtension::kAudioLevelUri) {
|
|
|
|
|
ids.audio_level = extension.id;
|
2019-08-14 11:31:02 +02:00
|
|
|
} else if (extension.uri == RtpExtension::kAbsSendTimeUri) {
|
|
|
|
|
ids.abs_send_time = extension.id;
|
2017-12-07 20:54:55 +01:00
|
|
|
} else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
|
|
|
|
|
ids.transport_sequence_number = extension.id;
|
2018-03-26 10:24:32 -07:00
|
|
|
} else if (extension.uri == RtpExtension::kMidUri) {
|
|
|
|
|
ids.mid = extension.id;
|
2018-12-21 09:23:38 -08:00
|
|
|
} else if (extension.uri == RtpExtension::kRidUri) {
|
|
|
|
|
ids.rid = extension.id;
|
|
|
|
|
} else if (extension.uri == RtpExtension::kRepairedRidUri) {
|
|
|
|
|
ids.repaired_rid = extension.id;
|
2020-03-05 11:33:13 +01:00
|
|
|
} else if (extension.uri == RtpExtension::kAbsoluteCaptureTimeUri) {
|
|
|
|
|
ids.abs_capture_time = extension.id;
|
2017-12-07 20:54:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 12:37:49 +01:00
|
|
|
int AudioSendStream::TransportSeqNumId(const AudioSendStream::Config& config) {
|
|
|
|
|
return FindExtensionIds(config.rtp.extensions).transport_sequence_number;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
void AudioSendStream::ConfigureStream(
|
|
|
|
|
const webrtc::AudioSendStream::Config& new_config,
|
2022-10-18 17:05:16 +02:00
|
|
|
bool first_time,
|
|
|
|
|
SetParametersCallback callback) {
|
2018-01-25 10:14:29 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioSendStream::ConfigureStream: "
|
|
|
|
|
<< new_config.ToString();
|
2024-05-28 18:16:53 +02:00
|
|
|
UpdateEventLogStreamConfig(env_.event_log(), new_config,
|
2019-10-04 09:30:32 +02:00
|
|
|
first_time ? nullptr : &config_);
|
2018-10-30 16:11:02 +01:00
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
const auto& old_config = config_;
|
2017-04-27 02:08:52 -07:00
|
|
|
|
2018-11-26 10:55:07 +01:00
|
|
|
// Configuration parameters which cannot be changed.
|
|
|
|
|
RTC_DCHECK(first_time ||
|
|
|
|
|
old_config.send_transport == new_config.send_transport);
|
2019-08-21 13:36:20 +02:00
|
|
|
RTC_DCHECK(first_time || old_config.rtp.ssrc == new_config.rtp.ssrc);
|
2019-10-04 09:30:32 +02:00
|
|
|
if (suspended_rtp_state_ && first_time) {
|
|
|
|
|
rtp_rtcp_module_->SetRtpState(*suspended_rtp_state_);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
if (first_time || old_config.rtp.c_name != new_config.rtp.c_name) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->SetRTCP_CNAME(new_config.rtp.c_name);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2018-10-04 14:22:34 -07:00
|
|
|
// Enable the frame encryptor if a new frame encryptor has been provided.
|
|
|
|
|
if (first_time || new_config.frame_encryptor != old_config.frame_encryptor) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->SetFrameEncryptor(new_config.frame_encryptor);
|
2018-10-04 14:22:34 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-31 11:29:56 +02:00
|
|
|
if (first_time ||
|
|
|
|
|
new_config.frame_transformer != old_config.frame_transformer) {
|
|
|
|
|
channel_send_->SetEncoderToPacketizerFrameTransformer(
|
|
|
|
|
new_config.frame_transformer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-29 11:22:05 +01:00
|
|
|
if (first_time ||
|
|
|
|
|
new_config.rtp.extmap_allow_mixed != old_config.rtp.extmap_allow_mixed) {
|
2020-01-14 17:55:19 +01:00
|
|
|
rtp_rtcp_module_->SetExtmapAllowMixed(new_config.rtp.extmap_allow_mixed);
|
2018-10-29 11:22:05 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-07 20:54:55 +01:00
|
|
|
const ExtensionIds old_ids = FindExtensionIds(old_config.rtp.extensions);
|
|
|
|
|
const ExtensionIds new_ids = FindExtensionIds(new_config.rtp.extensions);
|
2019-07-26 17:49:52 +02:00
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// Audio level indication
|
|
|
|
|
if (first_time || new_ids.audio_level != old_ids.audio_level) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->SetSendAudioLevelIndicationStatus(new_ids.audio_level != 0,
|
|
|
|
|
new_ids.audio_level);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
2019-08-14 11:31:02 +02:00
|
|
|
|
|
|
|
|
if (first_time || new_ids.abs_send_time != old_ids.abs_send_time) {
|
2021-10-07 19:12:32 +02:00
|
|
|
absl::string_view uri = AbsoluteSendTime::Uri();
|
|
|
|
|
rtp_rtcp_module_->DeregisterSendRtpHeaderExtension(uri);
|
2019-08-14 11:31:02 +02:00
|
|
|
if (new_ids.abs_send_time) {
|
2021-10-07 19:12:32 +02:00
|
|
|
rtp_rtcp_module_->RegisterRtpHeaderExtension(uri, new_ids.abs_send_time);
|
2019-08-14 11:31:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 17:22:16 +01:00
|
|
|
bool transport_seq_num_id_changed =
|
|
|
|
|
new_ids.transport_sequence_number != old_ids.transport_sequence_number;
|
2019-10-04 09:30:32 +02:00
|
|
|
if (first_time ||
|
|
|
|
|
(transport_seq_num_id_changed && !allocate_audio_without_feedback_)) {
|
2017-06-30 01:38:56 -07:00
|
|
|
if (!first_time) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->ResetSenderCongestionControlObjects();
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-23 15:05:44 +01:00
|
|
|
if (!allocate_audio_without_feedback_ &&
|
2019-10-03 10:03:55 +02:00
|
|
|
new_ids.transport_sequence_number != 0) {
|
2020-01-14 17:55:19 +01:00
|
|
|
rtp_rtcp_module_->RegisterRtpHeaderExtension(
|
2021-09-14 12:58:51 +02:00
|
|
|
TransportSequenceNumber::Uri(), new_ids.transport_sequence_number);
|
2017-11-15 17:22:16 +01:00
|
|
|
// Probing in application limited region is only used in combination with
|
|
|
|
|
// send side congestion control, wich depends on feedback packets which
|
|
|
|
|
// requires transport sequence numbers to be enabled.
|
2019-10-04 09:31:08 +02:00
|
|
|
// Optionally request ALR probing but do not override any existing
|
|
|
|
|
// request from other streams.
|
|
|
|
|
if (enable_audio_alr_probing_) {
|
|
|
|
|
rtp_transport_->EnablePeriodicAlrProbing(true);
|
2018-10-26 12:57:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-16 13:26:33 +02:00
|
|
|
channel_send_->RegisterSenderCongestionControlObjects(rtp_transport_);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
2018-03-26 10:24:32 -07:00
|
|
|
// MID RTP header extension.
|
2018-03-29 12:37:21 -07:00
|
|
|
if ((first_time || new_ids.mid != old_ids.mid ||
|
|
|
|
|
new_config.rtp.mid != old_config.rtp.mid) &&
|
|
|
|
|
new_ids.mid != 0 && !new_config.rtp.mid.empty()) {
|
2021-09-14 12:58:51 +02:00
|
|
|
rtp_rtcp_module_->RegisterRtpHeaderExtension(RtpMid::Uri(), new_ids.mid);
|
2020-01-14 17:55:19 +01:00
|
|
|
rtp_rtcp_module_->SetMid(new_config.rtp.mid);
|
2018-03-26 10:24:32 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-05 11:33:13 +01:00
|
|
|
if (first_time || new_ids.abs_capture_time != old_ids.abs_capture_time) {
|
2021-10-07 19:12:32 +02:00
|
|
|
absl::string_view uri = AbsoluteCaptureTimeExtension::Uri();
|
|
|
|
|
rtp_rtcp_module_->DeregisterSendRtpHeaderExtension(uri);
|
2020-03-05 11:33:13 +01:00
|
|
|
if (new_ids.abs_capture_time) {
|
2021-10-07 19:12:32 +02:00
|
|
|
rtp_rtcp_module_->RegisterRtpHeaderExtension(uri,
|
|
|
|
|
new_ids.abs_capture_time);
|
2020-03-05 11:33:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
if (!ReconfigureSendCodec(new_config)) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "Failed to set up send codec state.";
|
2022-10-18 17:05:16 +02:00
|
|
|
|
|
|
|
|
webrtc::InvokeSetParametersCallback(
|
|
|
|
|
callback, webrtc::RTCError(webrtc::RTCErrorType::INTERNAL_ERROR,
|
|
|
|
|
"Failed to set up send codec state."));
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2020-05-07 18:18:32 +02:00
|
|
|
// Set currently known overhead (used in ANA, opus only).
|
2024-01-22 14:49:15 +01:00
|
|
|
UpdateOverheadPerPacket();
|
2020-05-07 18:18:32 +02:00
|
|
|
|
2020-03-06 09:49:29 +01:00
|
|
|
channel_send_->CallEncoder([this](AudioEncoder* encoder) {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2020-03-06 09:49:29 +01:00
|
|
|
if (!encoder) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-03 13:33:28 +01:00
|
|
|
frame_length_range_ = encoder->GetFrameLengthRange();
|
2024-02-07 09:44:31 +01:00
|
|
|
bitrate_range_ = encoder->GetBitrateRange();
|
2020-03-06 09:49:29 +01:00
|
|
|
});
|
|
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
if (sending_) {
|
|
|
|
|
ReconfigureBitrateObserver(new_config);
|
2017-12-20 16:38:09 +01:00
|
|
|
}
|
2021-02-03 13:33:28 +01:00
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
config_ = new_config;
|
2022-10-18 17:05:16 +02:00
|
|
|
|
|
|
|
|
webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK());
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-16 07:34:50 -08:00
|
|
|
void AudioSendStream::Start() {
|
2019-03-01 15:57:55 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
if (sending_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-12-12 10:58:18 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioSendStream::Start: " << config_.rtp.ssrc;
|
2019-10-03 10:03:55 +02:00
|
|
|
if (!config_.has_dscp && config_.min_bitrate_bps != -1 &&
|
|
|
|
|
config_.max_bitrate_bps != -1 &&
|
2019-10-10 13:52:26 +02:00
|
|
|
(allocate_audio_without_feedback_ || TransportSeqNumId(config_) != 0)) {
|
2019-07-24 14:52:55 +02:00
|
|
|
rtp_transport_->AccountForAudioPacketsInPacedSender(true);
|
2022-11-30 19:41:22 +01:00
|
|
|
rtp_transport_->IncludeOverheadInPacedSender();
|
2018-10-10 10:23:13 +02:00
|
|
|
rtp_rtcp_module_->SetAsPartOfAllocation(true);
|
2021-02-03 13:33:28 +01:00
|
|
|
ConfigureBitrateObserver();
|
2018-10-10 10:23:13 +02:00
|
|
|
} else {
|
|
|
|
|
rtp_rtcp_module_->SetAsPartOfAllocation(false);
|
2016-07-26 04:44:06 -07:00
|
|
|
}
|
2018-11-19 10:27:07 +01:00
|
|
|
channel_send_->StartSend();
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
sending_ = true;
|
|
|
|
|
audio_state()->AddSendingStream(this, encoder_sample_rate_hz_,
|
|
|
|
|
encoder_num_channels_);
|
2015-11-16 07:34:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioSendStream::Stop() {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
if (!sending_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-12-12 10:58:18 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioSendStream::Stop: " << config_.rtp.ssrc;
|
2017-04-27 02:08:52 -07:00
|
|
|
RemoveBitrateObserver();
|
2018-11-19 10:27:07 +01:00
|
|
|
channel_send_->StopSend();
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
sending_ = false;
|
|
|
|
|
audio_state()->RemoveSendingStream(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioSendStream::SendAudioData(std::unique_ptr<AudioFrame> audio_frame) {
|
|
|
|
|
RTC_CHECK_RUNS_SERIALIZED(&audio_capture_race_checker_);
|
[getStats] Implement "media-source" audio levels, fixing Chrome bug.
Implements RTCAudioSourceStats members:
- audioLevel
- totalAudioEnergy
- totalSamplesDuration
In this CL description these are collectively referred to as the audio
levels.
The audio levels are removed from sending "track" stats (in Chrome,
these are now reported as undefined instead of 0).
Background:
For sending tracks, audio levels were always reported as 0 in Chrome
(https://crbug.com/736403), while audio levels were correctly reported
for receiving tracks. This problem affected the standard getStats() but
not the legacy getStats(), blocking some people from migrating. This
was likely not a problem in native third_party/webrtc code because the
delivery of audio frames from device to send-stream uses a different
code path outside of chromium.
A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the
send-side audio levels to the RTCAudioSourceStats, while keeping the
receive-side audio levels on the "track" stats. This allows an
implementation to report the audio levels even if samples are not sent
onto the network (such as if an ICE connection has not been established
yet), reflecting some of the current implementation.
Changes:
1. Audio levels are added to RTCAudioSourceStats. Send-side audio
"track" stats are left undefined. Receive-side audio "track" stats
are not changed in this CL and continue to work.
2. Audio level computation is moved from the AudioState and
AudioTransportImpl to the AudioSendStream. This is because a) the
AudioTransportImpl::RecordedDataIsAvailable() code path is not
exercised in chromium, and b) audio levels should, per-spec, not be
calculated on a per-call basis, for which the AudioState is defined.
3. The audio level computation is now performed in
AudioSendStream::SendAudioData(), a code path used by both native
and chromium code.
4. Comments are added to document behavior of existing code, such as
AudioLevel and AudioSendStream::SendAudioData().
Note:
In this CL, just like before this CL, audio level is only calculated
after an AudioSendStream has been created. This means that before an
O/A negotiation, audio levels are unavailable.
According to spec, if we have an audio source, we should have audio
levels. An immediate solution to this would have been to calculate the
audio level at pc/rtp_sender.cc. The problem is that the
LocalAudioSinkAdapter::OnData() code path, while exercised in chromium,
is not exercised in native code. The issue of calculating audio levels
on a per-source bases rather than on a per-send stream basis is left to
https://crbug.com/webrtc/10771, an existing "media-source" bug.
This CL can be verified manually in Chrome at:
https://codepen.io/anon/pen/vqRGyq
Bug: chromium:736403, webrtc:10771
Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
|
|
|
RTC_DCHECK_GT(audio_frame->sample_rate_hz_, 0);
|
2022-09-27 15:22:34 +02:00
|
|
|
TRACE_EVENT0("webrtc", "AudioSendStream::SendAudioData");
|
[getStats] Implement "media-source" audio levels, fixing Chrome bug.
Implements RTCAudioSourceStats members:
- audioLevel
- totalAudioEnergy
- totalSamplesDuration
In this CL description these are collectively referred to as the audio
levels.
The audio levels are removed from sending "track" stats (in Chrome,
these are now reported as undefined instead of 0).
Background:
For sending tracks, audio levels were always reported as 0 in Chrome
(https://crbug.com/736403), while audio levels were correctly reported
for receiving tracks. This problem affected the standard getStats() but
not the legacy getStats(), blocking some people from migrating. This
was likely not a problem in native third_party/webrtc code because the
delivery of audio frames from device to send-stream uses a different
code path outside of chromium.
A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the
send-side audio levels to the RTCAudioSourceStats, while keeping the
receive-side audio levels on the "track" stats. This allows an
implementation to report the audio levels even if samples are not sent
onto the network (such as if an ICE connection has not been established
yet), reflecting some of the current implementation.
Changes:
1. Audio levels are added to RTCAudioSourceStats. Send-side audio
"track" stats are left undefined. Receive-side audio "track" stats
are not changed in this CL and continue to work.
2. Audio level computation is moved from the AudioState and
AudioTransportImpl to the AudioSendStream. This is because a) the
AudioTransportImpl::RecordedDataIsAvailable() code path is not
exercised in chromium, and b) audio levels should, per-spec, not be
calculated on a per-call basis, for which the AudioState is defined.
3. The audio level computation is now performed in
AudioSendStream::SendAudioData(), a code path used by both native
and chromium code.
4. Comments are added to document behavior of existing code, such as
AudioLevel and AudioSendStream::SendAudioData().
Note:
In this CL, just like before this CL, audio level is only calculated
after an AudioSendStream has been created. This means that before an
O/A negotiation, audio levels are unavailable.
According to spec, if we have an audio source, we should have audio
levels. An immediate solution to this would have been to calculate the
audio level at pc/rtp_sender.cc. The problem is that the
LocalAudioSinkAdapter::OnData() code path, while exercised in chromium,
is not exercised in native code. The issue of calculating audio levels
on a per-source bases rather than on a per-send stream basis is left to
https://crbug.com/webrtc/10771, an existing "media-source" bug.
This CL can be verified manually in Chrome at:
https://codepen.io/anon/pen/vqRGyq
Bug: chromium:736403, webrtc:10771
Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
|
|
|
double duration = static_cast<double>(audio_frame->samples_per_channel_) /
|
|
|
|
|
audio_frame->sample_rate_hz_;
|
|
|
|
|
{
|
|
|
|
|
// Note: SendAudioData() passes the frame further down the pipeline and it
|
|
|
|
|
// may eventually get sent. But this method is invoked even if we are not
|
|
|
|
|
// connected, as long as we have an AudioSendStream (created as a result of
|
|
|
|
|
// an O/A exchange). This means that we are calculating audio levels whether
|
|
|
|
|
// or not we are sending samples.
|
|
|
|
|
// TODO(https://crbug.com/webrtc/10771): All "media-source" related stats
|
|
|
|
|
// should move from send-streams to the local audio sources or tracks; a
|
|
|
|
|
// send-stream should not be required to read the microphone audio levels.
|
2020-07-06 15:15:07 +02:00
|
|
|
MutexLock lock(&audio_level_lock_);
|
[getStats] Implement "media-source" audio levels, fixing Chrome bug.
Implements RTCAudioSourceStats members:
- audioLevel
- totalAudioEnergy
- totalSamplesDuration
In this CL description these are collectively referred to as the audio
levels.
The audio levels are removed from sending "track" stats (in Chrome,
these are now reported as undefined instead of 0).
Background:
For sending tracks, audio levels were always reported as 0 in Chrome
(https://crbug.com/736403), while audio levels were correctly reported
for receiving tracks. This problem affected the standard getStats() but
not the legacy getStats(), blocking some people from migrating. This
was likely not a problem in native third_party/webrtc code because the
delivery of audio frames from device to send-stream uses a different
code path outside of chromium.
A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the
send-side audio levels to the RTCAudioSourceStats, while keeping the
receive-side audio levels on the "track" stats. This allows an
implementation to report the audio levels even if samples are not sent
onto the network (such as if an ICE connection has not been established
yet), reflecting some of the current implementation.
Changes:
1. Audio levels are added to RTCAudioSourceStats. Send-side audio
"track" stats are left undefined. Receive-side audio "track" stats
are not changed in this CL and continue to work.
2. Audio level computation is moved from the AudioState and
AudioTransportImpl to the AudioSendStream. This is because a) the
AudioTransportImpl::RecordedDataIsAvailable() code path is not
exercised in chromium, and b) audio levels should, per-spec, not be
calculated on a per-call basis, for which the AudioState is defined.
3. The audio level computation is now performed in
AudioSendStream::SendAudioData(), a code path used by both native
and chromium code.
4. Comments are added to document behavior of existing code, such as
AudioLevel and AudioSendStream::SendAudioData().
Note:
In this CL, just like before this CL, audio level is only calculated
after an AudioSendStream has been created. This means that before an
O/A negotiation, audio levels are unavailable.
According to spec, if we have an audio source, we should have audio
levels. An immediate solution to this would have been to calculate the
audio level at pc/rtp_sender.cc. The problem is that the
LocalAudioSinkAdapter::OnData() code path, while exercised in chromium,
is not exercised in native code. The issue of calculating audio levels
on a per-source bases rather than on a per-send stream basis is left to
https://crbug.com/webrtc/10771, an existing "media-source" bug.
This CL can be verified manually in Chrome at:
https://codepen.io/anon/pen/vqRGyq
Bug: chromium:736403, webrtc:10771
Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
|
|
|
audio_level_.ComputeLevel(*audio_frame, duration);
|
|
|
|
|
}
|
2018-11-19 10:27:07 +01:00
|
|
|
channel_send_->ProcessAndEncodeAudio(std::move(audio_frame));
|
2015-11-16 07:34:50 -08:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
bool AudioSendStream::SendTelephoneEvent(int payload_type,
|
|
|
|
|
int payload_frequency,
|
|
|
|
|
int event,
|
2016-03-11 03:06:41 -08:00
|
|
|
int duration_ms) {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2019-03-05 14:29:42 +01:00
|
|
|
channel_send_->SetSendTelephoneEventPayloadType(payload_type,
|
|
|
|
|
payload_frequency);
|
|
|
|
|
return channel_send_->SendTelephoneEventOutband(event, duration_ms);
|
2015-12-04 15:22:19 +01:00
|
|
|
}
|
|
|
|
|
|
2016-06-16 10:53:22 -07:00
|
|
|
void AudioSendStream::SetMuted(bool muted) {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2018-11-19 10:27:07 +01:00
|
|
|
channel_send_->SetInputMute(muted);
|
2016-06-16 10:53:22 -07:00
|
|
|
}
|
|
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const {
|
2017-11-24 17:29:59 +01:00
|
|
|
return GetStats(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::AudioSendStream::Stats AudioSendStream::GetStats(
|
|
|
|
|
bool has_remote_tracks) const {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2015-10-27 03:35:21 -07:00
|
|
|
webrtc::AudioSendStream::Stats stats;
|
|
|
|
|
stats.local_ssrc = config_.rtp.ssrc;
|
2021-11-11 13:43:49 +01:00
|
|
|
stats.target_bitrate_bps = channel_send_->GetTargetBitrate();
|
2015-10-27 03:35:21 -07:00
|
|
|
|
2018-11-19 10:27:07 +01:00
|
|
|
webrtc::CallSendStatistics call_stats = channel_send_->GetRTCPStatistics();
|
2019-10-09 15:01:33 +02:00
|
|
|
stats.payload_bytes_sent = call_stats.payload_bytes_sent;
|
|
|
|
|
stats.header_and_padding_bytes_sent =
|
|
|
|
|
call_stats.header_and_padding_bytes_sent;
|
2019-04-17 13:51:53 +02:00
|
|
|
stats.retransmitted_bytes_sent = call_stats.retransmitted_bytes_sent;
|
2015-10-27 03:35:21 -07:00
|
|
|
stats.packets_sent = call_stats.packetsSent;
|
2022-10-26 16:53:03 +02:00
|
|
|
stats.total_packet_send_delay = call_stats.total_packet_send_delay;
|
2019-04-17 13:51:53 +02:00
|
|
|
stats.retransmitted_packets_sent = call_stats.retransmitted_packets_sent;
|
2015-11-16 09:48:04 -08:00
|
|
|
// RTT isn't known until a RTCP report is received. Until then, VoiceEngine
|
|
|
|
|
// returns 0 to indicate an error value.
|
|
|
|
|
if (call_stats.rttMs > 0) {
|
|
|
|
|
stats.rtt_ms = call_stats.rttMs;
|
|
|
|
|
}
|
2017-04-27 02:08:52 -07:00
|
|
|
if (config_.send_codec_spec) {
|
|
|
|
|
const auto& spec = *config_.send_codec_spec;
|
|
|
|
|
stats.codec_name = spec.format.name;
|
2017-11-16 10:57:35 +01:00
|
|
|
stats.codec_payload_type = spec.payload_type;
|
2015-10-27 03:35:21 -07:00
|
|
|
|
|
|
|
|
// Get data from the last remote RTCP report.
|
2023-05-03 13:20:11 +02:00
|
|
|
for (const ReportBlockData& block :
|
|
|
|
|
channel_send_->GetRemoteRTCPReportBlocks()) {
|
2015-11-16 09:48:04 -08:00
|
|
|
// Lookup report for send ssrc only.
|
2023-05-03 13:20:11 +02:00
|
|
|
if (block.source_ssrc() == stats.local_ssrc) {
|
|
|
|
|
stats.packets_lost = block.cumulative_lost();
|
|
|
|
|
stats.fraction_lost = block.fraction_lost();
|
|
|
|
|
if (spec.format.clockrate_hz > 0) {
|
|
|
|
|
stats.jitter_ms = block.jitter(spec.format.clockrate_hz).ms();
|
2015-10-27 03:35:21 -07:00
|
|
|
}
|
2015-11-16 09:48:04 -08:00
|
|
|
break;
|
2015-10-27 03:35:21 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
[getStats] Implement "media-source" audio levels, fixing Chrome bug.
Implements RTCAudioSourceStats members:
- audioLevel
- totalAudioEnergy
- totalSamplesDuration
In this CL description these are collectively referred to as the audio
levels.
The audio levels are removed from sending "track" stats (in Chrome,
these are now reported as undefined instead of 0).
Background:
For sending tracks, audio levels were always reported as 0 in Chrome
(https://crbug.com/736403), while audio levels were correctly reported
for receiving tracks. This problem affected the standard getStats() but
not the legacy getStats(), blocking some people from migrating. This
was likely not a problem in native third_party/webrtc code because the
delivery of audio frames from device to send-stream uses a different
code path outside of chromium.
A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the
send-side audio levels to the RTCAudioSourceStats, while keeping the
receive-side audio levels on the "track" stats. This allows an
implementation to report the audio levels even if samples are not sent
onto the network (such as if an ICE connection has not been established
yet), reflecting some of the current implementation.
Changes:
1. Audio levels are added to RTCAudioSourceStats. Send-side audio
"track" stats are left undefined. Receive-side audio "track" stats
are not changed in this CL and continue to work.
2. Audio level computation is moved from the AudioState and
AudioTransportImpl to the AudioSendStream. This is because a) the
AudioTransportImpl::RecordedDataIsAvailable() code path is not
exercised in chromium, and b) audio levels should, per-spec, not be
calculated on a per-call basis, for which the AudioState is defined.
3. The audio level computation is now performed in
AudioSendStream::SendAudioData(), a code path used by both native
and chromium code.
4. Comments are added to document behavior of existing code, such as
AudioLevel and AudioSendStream::SendAudioData().
Note:
In this CL, just like before this CL, audio level is only calculated
after an AudioSendStream has been created. This means that before an
O/A negotiation, audio levels are unavailable.
According to spec, if we have an audio source, we should have audio
levels. An immediate solution to this would have been to calculate the
audio level at pc/rtp_sender.cc. The problem is that the
LocalAudioSinkAdapter::OnData() code path, while exercised in chromium,
is not exercised in native code. The issue of calculating audio levels
on a per-source bases rather than on a per-send stream basis is left to
https://crbug.com/webrtc/10771, an existing "media-source" bug.
This CL can be verified manually in Chrome at:
https://codepen.io/anon/pen/vqRGyq
Bug: chromium:736403, webrtc:10771
Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
|
|
|
{
|
2020-07-06 15:15:07 +02:00
|
|
|
MutexLock lock(&audio_level_lock_);
|
[getStats] Implement "media-source" audio levels, fixing Chrome bug.
Implements RTCAudioSourceStats members:
- audioLevel
- totalAudioEnergy
- totalSamplesDuration
In this CL description these are collectively referred to as the audio
levels.
The audio levels are removed from sending "track" stats (in Chrome,
these are now reported as undefined instead of 0).
Background:
For sending tracks, audio levels were always reported as 0 in Chrome
(https://crbug.com/736403), while audio levels were correctly reported
for receiving tracks. This problem affected the standard getStats() but
not the legacy getStats(), blocking some people from migrating. This
was likely not a problem in native third_party/webrtc code because the
delivery of audio frames from device to send-stream uses a different
code path outside of chromium.
A recent PR (https://github.com/w3c/webrtc-stats/pull/451) moved the
send-side audio levels to the RTCAudioSourceStats, while keeping the
receive-side audio levels on the "track" stats. This allows an
implementation to report the audio levels even if samples are not sent
onto the network (such as if an ICE connection has not been established
yet), reflecting some of the current implementation.
Changes:
1. Audio levels are added to RTCAudioSourceStats. Send-side audio
"track" stats are left undefined. Receive-side audio "track" stats
are not changed in this CL and continue to work.
2. Audio level computation is moved from the AudioState and
AudioTransportImpl to the AudioSendStream. This is because a) the
AudioTransportImpl::RecordedDataIsAvailable() code path is not
exercised in chromium, and b) audio levels should, per-spec, not be
calculated on a per-call basis, for which the AudioState is defined.
3. The audio level computation is now performed in
AudioSendStream::SendAudioData(), a code path used by both native
and chromium code.
4. Comments are added to document behavior of existing code, such as
AudioLevel and AudioSendStream::SendAudioData().
Note:
In this CL, just like before this CL, audio level is only calculated
after an AudioSendStream has been created. This means that before an
O/A negotiation, audio levels are unavailable.
According to spec, if we have an audio source, we should have audio
levels. An immediate solution to this would have been to calculate the
audio level at pc/rtp_sender.cc. The problem is that the
LocalAudioSinkAdapter::OnData() code path, while exercised in chromium,
is not exercised in native code. The issue of calculating audio levels
on a per-source bases rather than on a per-send stream basis is left to
https://crbug.com/webrtc/10771, an existing "media-source" bug.
This CL can be verified manually in Chrome at:
https://codepen.io/anon/pen/vqRGyq
Bug: chromium:736403, webrtc:10771
Change-Id: I8036cd9984f3b187c3177470a8c0d6670a201a5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143789
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28480}
2019-07-03 17:11:10 +02:00
|
|
|
stats.audio_level = audio_level_.LevelFullRange();
|
|
|
|
|
stats.total_input_energy = audio_level_.TotalEnergy();
|
|
|
|
|
stats.total_input_duration = audio_level_.TotalDuration();
|
|
|
|
|
}
|
2017-07-14 12:17:49 -07:00
|
|
|
|
2018-11-19 10:27:07 +01:00
|
|
|
stats.ana_statistics = channel_send_->GetANAStatistics();
|
2020-04-26 23:56:17 +02:00
|
|
|
|
|
|
|
|
AudioProcessing* ap = audio_state_->audio_processing();
|
|
|
|
|
if (ap) {
|
|
|
|
|
stats.apm_statistics = ap->GetStatistics(has_remote_tracks);
|
|
|
|
|
}
|
2015-10-27 03:35:21 -07:00
|
|
|
|
2019-05-27 12:19:33 +02:00
|
|
|
stats.report_block_datas = std::move(call_stats.report_block_datas);
|
|
|
|
|
|
2023-04-21 19:32:42 +02:00
|
|
|
stats.nacks_received = call_stats.nacks_received;
|
2021-07-06 09:55:43 +02:00
|
|
|
|
2015-10-27 03:35:21 -07:00
|
|
|
return stats;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-05 14:29:42 +01:00
|
|
|
void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
|
2020-06-29 16:37:44 +02:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2019-03-05 14:29:42 +01:00
|
|
|
channel_send_->ReceivedRTCPPacket(packet, length);
|
2024-01-22 14:49:15 +01:00
|
|
|
// Poll if overhead has changed, which it can do if ack triggers us to stop
|
|
|
|
|
// sending mid/rid.
|
|
|
|
|
UpdateOverheadPerPacket();
|
2016-05-01 20:18:34 -07:00
|
|
|
}
|
|
|
|
|
|
2018-10-25 15:08:32 +02:00
|
|
|
uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) {
|
2023-04-12 11:40:01 +00:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2019-05-03 14:40:13 +02:00
|
|
|
// Pick a target bitrate between the constraints. Overrules the allocator if
|
|
|
|
|
// it 1) allocated a bitrate of zero to disable the stream or 2) allocated a
|
|
|
|
|
// higher than max to allow for e.g. extra FEC.
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<TargetAudioBitrateConstraints> constraints =
|
2024-01-22 14:49:15 +01:00
|
|
|
GetMinMaxBitrateConstraints();
|
|
|
|
|
if (constraints) {
|
|
|
|
|
update.target_bitrate.Clamp(constraints->min, constraints->max);
|
|
|
|
|
update.stable_target_bitrate.Clamp(constraints->min, constraints->max);
|
|
|
|
|
}
|
2018-11-21 19:19:00 +01:00
|
|
|
channel_send_->OnBitrateAllocation(update);
|
2016-07-26 04:44:06 -07:00
|
|
|
// The amount of audio protection is not exposed by the encoder, hence
|
|
|
|
|
// always returning 0.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<DataRate> AudioSendStream::GetUsedRate() const {
|
2024-08-05 20:53:31 +00:00
|
|
|
return channel_send_->GetUsedRate();
|
2024-07-30 17:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 15:16:06 -08:00
|
|
|
void AudioSendStream::SetTransportOverhead(
|
|
|
|
|
int transport_overhead_per_packet_bytes) {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2024-01-22 14:49:15 +01:00
|
|
|
transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes;
|
|
|
|
|
UpdateOverheadPerPacket();
|
2019-02-04 15:16:06 -08:00
|
|
|
}
|
|
|
|
|
|
2024-01-22 14:49:15 +01:00
|
|
|
void AudioSendStream::UpdateOverheadPerPacket() {
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2024-01-22 14:49:15 +01:00
|
|
|
size_t overhead_per_packet_bytes =
|
|
|
|
|
transport_overhead_per_packet_bytes_ +
|
|
|
|
|
rtp_rtcp_module_->ExpectedPerPacketOverhead();
|
2020-05-13 14:43:11 +02:00
|
|
|
if (overhead_per_packet_ == overhead_per_packet_bytes) {
|
|
|
|
|
return;
|
2019-04-26 15:41:05 -07:00
|
|
|
}
|
2020-05-13 14:43:11 +02:00
|
|
|
overhead_per_packet_ = overhead_per_packet_bytes;
|
2019-02-13 15:11:42 +01:00
|
|
|
channel_send_->CallEncoder([&](AudioEncoder* encoder) {
|
|
|
|
|
encoder->OnReceivedOverhead(overhead_per_packet_bytes);
|
2019-02-04 15:16:06 -08:00
|
|
|
});
|
2024-01-22 14:49:15 +01:00
|
|
|
if (registered_with_allocator_) {
|
|
|
|
|
ConfigureBitrateObserver();
|
2020-05-07 18:18:32 +02:00
|
|
|
}
|
2024-08-05 20:53:31 +00:00
|
|
|
channel_send_->RegisterPacketOverhead(overhead_per_packet_bytes);
|
2019-02-04 15:16:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t AudioSendStream::TestOnlyGetPerPacketOverheadBytes() const {
|
2024-01-22 14:49:15 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
|
|
|
|
return overhead_per_packet_;
|
2016-11-08 02:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
2017-05-23 06:07:11 -07:00
|
|
|
RtpState AudioSendStream::GetRtpState() const {
|
|
|
|
|
return rtp_rtcp_module_->GetRtpState();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-19 10:27:07 +01:00
|
|
|
const voe::ChannelSendInterface* AudioSendStream::GetChannel() const {
|
|
|
|
|
return channel_send_.get();
|
2018-01-11 13:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
internal::AudioState* AudioSendStream::audio_state() {
|
|
|
|
|
internal::AudioState* audio_state =
|
|
|
|
|
static_cast<internal::AudioState*>(audio_state_.get());
|
|
|
|
|
RTC_DCHECK(audio_state);
|
|
|
|
|
return audio_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const internal::AudioState* AudioSendStream::audio_state() const {
|
|
|
|
|
internal::AudioState* audio_state =
|
|
|
|
|
static_cast<internal::AudioState*>(audio_state_.get());
|
|
|
|
|
RTC_DCHECK(audio_state);
|
|
|
|
|
return audio_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioSendStream::StoreEncoderProperties(int sample_rate_hz,
|
|
|
|
|
size_t num_channels) {
|
|
|
|
|
encoder_sample_rate_hz_ = sample_rate_hz;
|
|
|
|
|
encoder_num_channels_ = num_channels;
|
|
|
|
|
if (sending_) {
|
|
|
|
|
// Update AudioState's information about the stream.
|
|
|
|
|
audio_state()->AddSendingStream(this, sample_rate_hz, num_channels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 03:27:12 -07:00
|
|
|
// Apply current codec settings to a single voe::Channel used for sending.
|
2019-10-04 09:30:32 +02:00
|
|
|
bool AudioSendStream::SetupSendCodec(const Config& new_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
RTC_DCHECK(new_config.send_codec_spec);
|
|
|
|
|
const auto& spec = *new_config.send_codec_spec;
|
2017-05-10 04:06:11 -07:00
|
|
|
|
|
|
|
|
RTC_DCHECK(new_config.encoder_factory);
|
2024-06-18 13:02:58 +02:00
|
|
|
std::unique_ptr<AudioEncoder> encoder = new_config.encoder_factory->Create(
|
|
|
|
|
env_, spec.format,
|
|
|
|
|
{.payload_type = spec.payload_type,
|
|
|
|
|
.codec_pair_id = new_config.codec_pair_id});
|
2017-04-27 02:08:52 -07:00
|
|
|
|
|
|
|
|
if (!encoder) {
|
2018-04-03 13:40:05 +02:00
|
|
|
RTC_DLOG(LS_ERROR) << "Unable to create encoder for "
|
|
|
|
|
<< rtc::ToString(spec.format);
|
2017-04-27 02:08:52 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-07-13 10:32:58 +02:00
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// If a bitrate has been specified for the codec, use it over the
|
|
|
|
|
// codec's default.
|
2019-03-06 09:51:08 +01:00
|
|
|
if (spec.target_bitrate_bps) {
|
2017-04-27 02:08:52 -07:00
|
|
|
encoder->OnReceivedTargetAudioBitrate(*spec.target_bitrate_bps);
|
2016-10-20 03:27:12 -07:00
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// Enable ANA if configured (currently only used by Opus).
|
2020-01-29 15:29:36 +00:00
|
|
|
if (new_config.audio_network_adaptor_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
if (encoder->EnableAudioNetworkAdaptor(
|
2024-05-28 18:16:53 +02:00
|
|
|
*new_config.audio_network_adaptor_config, &env_.event_log())) {
|
2020-08-11 14:05:07 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Audio network adaptor enabled on SSRC "
|
|
|
|
|
<< new_config.rtp.ssrc;
|
2017-04-27 02:08:52 -07:00
|
|
|
} else {
|
2020-08-11 14:05:07 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Failed to enable Audio network adaptor on SSRC "
|
|
|
|
|
<< new_config.rtp.ssrc;
|
2016-10-20 03:27:12 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-26 19:12:31 +02:00
|
|
|
// Wrap the encoder in an AudioEncoderCNG, if VAD is enabled.
|
2017-04-27 02:08:52 -07:00
|
|
|
if (spec.cng_payload_type) {
|
2018-11-01 11:13:44 +01:00
|
|
|
AudioEncoderCngConfig cng_config;
|
2017-04-27 02:08:52 -07:00
|
|
|
cng_config.num_channels = encoder->NumChannels();
|
|
|
|
|
cng_config.payload_type = *spec.cng_payload_type;
|
|
|
|
|
cng_config.speech_encoder = std::move(encoder);
|
|
|
|
|
cng_config.vad_mode = Vad::kVadNormal;
|
2018-11-01 11:13:44 +01:00
|
|
|
encoder = CreateComfortNoiseEncoder(std::move(cng_config));
|
2017-04-27 08:03:42 -07:00
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
RegisterCngPayloadType(*spec.cng_payload_type,
|
|
|
|
|
new_config.send_codec_spec->format.clockrate_hz);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
2016-10-20 03:27:12 -07:00
|
|
|
|
2020-06-24 12:52:42 +02:00
|
|
|
// Wrap the encoder in a RED encoder, if RED is enabled.
|
2023-11-01 19:18:32 +01:00
|
|
|
SdpAudioFormat format = spec.format;
|
2020-06-24 12:52:42 +02:00
|
|
|
if (spec.red_payload_type) {
|
|
|
|
|
AudioEncoderCopyRed::Config red_config;
|
|
|
|
|
red_config.payload_type = *spec.red_payload_type;
|
|
|
|
|
red_config.speech_encoder = std::move(encoder);
|
2022-03-16 13:50:58 +01:00
|
|
|
encoder = std::make_unique<AudioEncoderCopyRed>(std::move(red_config),
|
2024-05-28 18:16:53 +02:00
|
|
|
env_.field_trials());
|
2023-11-01 19:18:32 +01:00
|
|
|
format.name = cricket::kRedCodecName;
|
2020-06-24 12:52:42 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 15:16:06 -08:00
|
|
|
// Set currently known overhead (used in ANA, opus only).
|
2024-01-22 14:49:15 +01:00
|
|
|
// If overhead changes later, it will be updated in UpdateOverheadPerPacket.
|
|
|
|
|
if (overhead_per_packet_ > 0) {
|
|
|
|
|
encoder->OnReceivedOverhead(overhead_per_packet_);
|
2019-02-04 15:16:06 -08:00
|
|
|
}
|
|
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
StoreEncoderProperties(encoder->SampleRateHz(), encoder->NumChannels());
|
2023-11-01 19:18:32 +01:00
|
|
|
channel_send_->SetEncoder(new_config.send_codec_spec->payload_type, format,
|
2019-10-04 09:30:32 +02:00
|
|
|
std::move(encoder));
|
2019-02-04 15:16:06 -08:00
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-10-31 04:08:32 -07:00
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
bool AudioSendStream::ReconfigureSendCodec(const Config& new_config) {
|
|
|
|
|
const auto& old_config = config_;
|
2017-07-26 14:18:40 +02:00
|
|
|
|
|
|
|
|
if (!new_config.send_codec_spec) {
|
|
|
|
|
// We cannot de-configure a send codec. So we will do nothing.
|
|
|
|
|
// By design, the send codec should have not been configured.
|
|
|
|
|
RTC_DCHECK(!old_config.send_codec_spec);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_config.send_codec_spec == old_config.send_codec_spec &&
|
|
|
|
|
new_config.audio_network_adaptor_config ==
|
|
|
|
|
old_config.audio_network_adaptor_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
return true;
|
2016-10-20 03:27:12 -07:00
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// If we have no encoder, or the format or payload type's changed, create a
|
|
|
|
|
// new encoder.
|
|
|
|
|
if (!old_config.send_codec_spec ||
|
|
|
|
|
new_config.send_codec_spec->format !=
|
|
|
|
|
old_config.send_codec_spec->format ||
|
|
|
|
|
new_config.send_codec_spec->payload_type !=
|
2021-06-04 13:49:27 +02:00
|
|
|
old_config.send_codec_spec->payload_type ||
|
|
|
|
|
new_config.send_codec_spec->red_payload_type !=
|
|
|
|
|
old_config.send_codec_spec->red_payload_type) {
|
2019-10-04 09:30:32 +02:00
|
|
|
return SetupSendCodec(new_config);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
2016-10-20 03:27:12 -07:00
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
const std::optional<int>& new_target_bitrate_bps =
|
2017-04-27 02:08:52 -07:00
|
|
|
new_config.send_codec_spec->target_bitrate_bps;
|
|
|
|
|
// If a bitrate has been specified for the codec, use it over the
|
|
|
|
|
// codec's default.
|
2019-03-06 09:51:08 +01:00
|
|
|
if (new_target_bitrate_bps &&
|
2017-04-27 02:08:52 -07:00
|
|
|
new_target_bitrate_bps !=
|
|
|
|
|
old_config.send_codec_spec->target_bitrate_bps) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->CallEncoder([&](AudioEncoder* encoder) {
|
2017-04-27 02:08:52 -07:00
|
|
|
encoder->OnReceivedTargetAudioBitrate(*new_target_bitrate_bps);
|
|
|
|
|
});
|
2016-10-20 03:27:12 -07:00
|
|
|
}
|
2017-04-27 02:08:52 -07:00
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
ReconfigureANA(new_config);
|
|
|
|
|
ReconfigureCNG(new_config);
|
2017-04-27 02:08:52 -07:00
|
|
|
|
2016-10-20 03:27:12 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
void AudioSendStream::ReconfigureANA(const Config& new_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
if (new_config.audio_network_adaptor_config ==
|
2019-10-04 09:30:32 +02:00
|
|
|
config_.audio_network_adaptor_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2020-01-29 15:29:36 +00:00
|
|
|
if (new_config.audio_network_adaptor_config) {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->CallEncoder([&](AudioEncoder* encoder) {
|
2024-01-22 14:49:15 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2017-04-27 02:08:52 -07:00
|
|
|
if (encoder->EnableAudioNetworkAdaptor(
|
2024-05-28 18:16:53 +02:00
|
|
|
*new_config.audio_network_adaptor_config, &env_.event_log())) {
|
2020-08-11 14:05:07 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Audio network adaptor enabled on SSRC "
|
|
|
|
|
<< new_config.rtp.ssrc;
|
2024-01-22 14:49:15 +01:00
|
|
|
if (overhead_per_packet_ > 0) {
|
|
|
|
|
encoder->OnReceivedOverhead(overhead_per_packet_);
|
2020-08-20 16:48:49 +02:00
|
|
|
}
|
2017-04-27 02:08:52 -07:00
|
|
|
} else {
|
2020-08-11 14:05:07 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Failed to enable Audio network adaptor on SSRC "
|
|
|
|
|
<< new_config.rtp.ssrc;
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->CallEncoder(
|
2019-02-13 15:11:42 +01:00
|
|
|
[&](AudioEncoder* encoder) { encoder->DisableAudioNetworkAdaptor(); });
|
2020-08-11 14:05:07 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Audio network adaptor disabled on SSRC "
|
|
|
|
|
<< new_config.rtp.ssrc;
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 09:30:32 +02:00
|
|
|
void AudioSendStream::ReconfigureCNG(const Config& new_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
if (new_config.send_codec_spec->cng_payload_type ==
|
2019-10-04 09:30:32 +02:00
|
|
|
config_.send_codec_spec->cng_payload_type) {
|
2017-04-27 02:08:52 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 08:03:42 -07:00
|
|
|
// Register the CNG payload type if it's been added, don't do anything if CNG
|
|
|
|
|
// is removed. Payload types must not be redefined.
|
|
|
|
|
if (new_config.send_codec_spec->cng_payload_type) {
|
2019-10-04 09:30:32 +02:00
|
|
|
RegisterCngPayloadType(*new_config.send_codec_spec->cng_payload_type,
|
|
|
|
|
new_config.send_codec_spec->format.clockrate_hz);
|
2017-04-27 08:03:42 -07:00
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// Wrap or unwrap the encoder in an AudioEncoderCNG.
|
2019-10-04 09:30:32 +02:00
|
|
|
channel_send_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder_ptr) {
|
|
|
|
|
std::unique_ptr<AudioEncoder> old_encoder(std::move(*encoder_ptr));
|
|
|
|
|
auto sub_encoders = old_encoder->ReclaimContainedEncoders();
|
|
|
|
|
if (!sub_encoders.empty()) {
|
|
|
|
|
// Replace enc with its sub encoder. We need to put the sub
|
|
|
|
|
// encoder in a temporary first, since otherwise the old value
|
|
|
|
|
// of enc would be destroyed before the new value got assigned,
|
|
|
|
|
// which would be bad since the new value is a part of the old
|
|
|
|
|
// value.
|
|
|
|
|
auto tmp = std::move(sub_encoders[0]);
|
|
|
|
|
old_encoder = std::move(tmp);
|
|
|
|
|
}
|
|
|
|
|
if (new_config.send_codec_spec->cng_payload_type) {
|
|
|
|
|
AudioEncoderCngConfig config;
|
|
|
|
|
config.speech_encoder = std::move(old_encoder);
|
|
|
|
|
config.num_channels = config.speech_encoder->NumChannels();
|
|
|
|
|
config.payload_type = *new_config.send_codec_spec->cng_payload_type;
|
|
|
|
|
config.vad_mode = Vad::kVadNormal;
|
|
|
|
|
*encoder_ptr = CreateComfortNoiseEncoder(std::move(config));
|
|
|
|
|
} else {
|
|
|
|
|
*encoder_ptr = std::move(old_encoder);
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioSendStream::ReconfigureBitrateObserver(
|
|
|
|
|
const webrtc::AudioSendStream::Config& new_config) {
|
|
|
|
|
// Since the Config's default is for both of these to be -1, this test will
|
|
|
|
|
// allow us to configure the bitrate observer if the new config has bitrate
|
|
|
|
|
// limits set, but would only have us call RemoveBitrateObserver if we were
|
|
|
|
|
// previously configured with bitrate limits.
|
2019-10-04 09:30:32 +02:00
|
|
|
if (config_.min_bitrate_bps == new_config.min_bitrate_bps &&
|
|
|
|
|
config_.max_bitrate_bps == new_config.max_bitrate_bps &&
|
|
|
|
|
config_.bitrate_priority == new_config.bitrate_priority &&
|
2020-11-23 15:05:44 +01:00
|
|
|
TransportSeqNumId(config_) == TransportSeqNumId(new_config) &&
|
2020-03-06 09:49:29 +01:00
|
|
|
config_.audio_network_adaptor_config ==
|
|
|
|
|
new_config.audio_network_adaptor_config) {
|
2017-04-27 02:08:52 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-03 10:03:55 +02:00
|
|
|
if (!new_config.has_dscp && new_config.min_bitrate_bps != -1 &&
|
2019-10-10 13:52:26 +02:00
|
|
|
new_config.max_bitrate_bps != -1 && TransportSeqNumId(new_config) != 0) {
|
2019-10-04 09:30:32 +02:00
|
|
|
rtp_transport_->AccountForAudioPacketsInPacedSender(true);
|
2022-11-30 19:41:22 +01:00
|
|
|
rtp_transport_->IncludeOverheadInPacedSender();
|
2021-02-03 13:33:28 +01:00
|
|
|
// We may get a callback immediately as the observer is registered, so
|
|
|
|
|
// make sure the bitrate limits in config_ are up-to-date.
|
|
|
|
|
config_.min_bitrate_bps = new_config.min_bitrate_bps;
|
|
|
|
|
config_.max_bitrate_bps = new_config.max_bitrate_bps;
|
|
|
|
|
|
|
|
|
|
config_.bitrate_priority = new_config.bitrate_priority;
|
|
|
|
|
ConfigureBitrateObserver();
|
2019-10-04 09:30:32 +02:00
|
|
|
rtp_rtcp_module_->SetAsPartOfAllocation(true);
|
2017-04-27 02:08:52 -07:00
|
|
|
} else {
|
2019-10-04 09:30:32 +02:00
|
|
|
rtp_transport_->AccountForAudioPacketsInPacedSender(false);
|
|
|
|
|
RemoveBitrateObserver();
|
|
|
|
|
rtp_rtcp_module_->SetAsPartOfAllocation(false);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-01 15:57:55 +01:00
|
|
|
void AudioSendStream::ConfigureBitrateObserver() {
|
2023-04-12 11:40:01 +00:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2019-03-01 15:57:55 +01:00
|
|
|
// This either updates the current observer or adds a new observer.
|
|
|
|
|
// TODO(srte): Add overhead compensation here.
|
2019-05-03 14:40:13 +02:00
|
|
|
auto constraints = GetMinMaxBitrateConstraints();
|
2021-02-03 13:33:28 +01:00
|
|
|
RTC_DCHECK(constraints.has_value());
|
2019-05-03 14:40:13 +02:00
|
|
|
|
2019-10-03 18:32:45 +02:00
|
|
|
DataRate priority_bitrate = allocation_settings_.priority_bitrate;
|
2022-11-30 19:41:22 +01:00
|
|
|
if (use_legacy_overhead_calculation_) {
|
|
|
|
|
// OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12)
|
|
|
|
|
constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12;
|
|
|
|
|
const TimeDelta kMinPacketDuration = TimeDelta::Millis(20);
|
|
|
|
|
DataRate max_overhead =
|
|
|
|
|
DataSize::Bytes(kOverheadPerPacket) / kMinPacketDuration;
|
|
|
|
|
priority_bitrate += max_overhead;
|
|
|
|
|
} else {
|
|
|
|
|
RTC_DCHECK(frame_length_range_);
|
2024-01-22 14:49:15 +01:00
|
|
|
const DataSize overhead_per_packet = DataSize::Bytes(overhead_per_packet_);
|
2022-11-30 19:41:22 +01:00
|
|
|
DataRate min_overhead = overhead_per_packet / frame_length_range_->second;
|
|
|
|
|
priority_bitrate += min_overhead;
|
2019-10-03 10:03:55 +02:00
|
|
|
}
|
2022-11-30 19:41:22 +01:00
|
|
|
|
2023-04-12 11:40:01 +00:00
|
|
|
if (allocation_settings_.priority_bitrate_raw) {
|
2019-10-03 10:03:55 +02:00
|
|
|
priority_bitrate = *allocation_settings_.priority_bitrate_raw;
|
2023-04-12 11:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-29 15:02:59 -08:00
|
|
|
if (!enable_priority_bitrate_) {
|
|
|
|
|
priority_bitrate = DataRate::BitsPerSec(0);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 11:40:01 +00:00
|
|
|
bitrate_allocator_->AddObserver(
|
|
|
|
|
this,
|
|
|
|
|
MediaStreamAllocationConfig{
|
|
|
|
|
constraints->min.bps<uint32_t>(), constraints->max.bps<uint32_t>(), 0,
|
|
|
|
|
priority_bitrate.bps(), true,
|
|
|
|
|
allocation_settings_.bitrate_priority.value_or(
|
2024-07-30 17:01:12 +00:00
|
|
|
config_.bitrate_priority),
|
|
|
|
|
TrackRateElasticity::kCanContributeUnusedRate});
|
2019-10-03 10:03:55 +02:00
|
|
|
|
2020-03-06 09:49:29 +01:00
|
|
|
registered_with_allocator_ = true;
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioSendStream::RemoveBitrateObserver() {
|
2021-02-03 13:33:28 +01:00
|
|
|
registered_with_allocator_ = false;
|
2023-04-12 11:40:01 +00:00
|
|
|
bitrate_allocator_->RemoveObserver(this);
|
2017-04-27 02:08:52 -07:00
|
|
|
}
|
|
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<AudioSendStream::TargetAudioBitrateConstraints>
|
2019-05-03 14:40:13 +02:00
|
|
|
AudioSendStream::GetMinMaxBitrateConstraints() const {
|
2021-02-03 13:33:28 +01:00
|
|
|
if (config_.min_bitrate_bps < 0 || config_.max_bitrate_bps < 0) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "Config is invalid: min_bitrate_bps="
|
|
|
|
|
<< config_.min_bitrate_bps
|
|
|
|
|
<< "; max_bitrate_bps=" << config_.max_bitrate_bps
|
|
|
|
|
<< "; both expected greater or equal to 0";
|
2024-08-29 13:00:40 +00:00
|
|
|
return std::nullopt;
|
2021-02-03 13:33:28 +01:00
|
|
|
}
|
2019-05-03 14:40:13 +02:00
|
|
|
TargetAudioBitrateConstraints constraints{
|
2020-02-17 18:46:07 +01:00
|
|
|
DataRate::BitsPerSec(config_.min_bitrate_bps),
|
|
|
|
|
DataRate::BitsPerSec(config_.max_bitrate_bps)};
|
2019-05-03 14:40:13 +02:00
|
|
|
|
|
|
|
|
// If bitrates were explicitly overriden via field trial, use those values.
|
2019-10-03 10:03:55 +02:00
|
|
|
if (allocation_settings_.min_bitrate)
|
|
|
|
|
constraints.min = *allocation_settings_.min_bitrate;
|
|
|
|
|
if (allocation_settings_.max_bitrate)
|
|
|
|
|
constraints.max = *allocation_settings_.max_bitrate;
|
2019-05-03 14:40:13 +02:00
|
|
|
|
2024-02-07 09:44:31 +01:00
|
|
|
// Use encoder defined bitrate range if available.
|
|
|
|
|
if (bitrate_range_) {
|
|
|
|
|
constraints.min = bitrate_range_->first;
|
|
|
|
|
constraints.max = bitrate_range_->second;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-02 12:27:06 +02:00
|
|
|
RTC_DCHECK_GE(constraints.min, DataRate::Zero());
|
|
|
|
|
RTC_DCHECK_GE(constraints.max, DataRate::Zero());
|
2021-02-03 13:33:28 +01:00
|
|
|
if (constraints.max < constraints.min) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "TargetAudioBitrateConstraints::max is less than "
|
|
|
|
|
<< "TargetAudioBitrateConstraints::min";
|
2024-08-29 13:00:40 +00:00
|
|
|
return std::nullopt;
|
2021-02-03 13:33:28 +01:00
|
|
|
}
|
2022-11-30 19:41:22 +01:00
|
|
|
if (use_legacy_overhead_calculation_) {
|
|
|
|
|
// OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12)
|
|
|
|
|
const DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12);
|
|
|
|
|
const TimeDelta kMaxFrameLength =
|
|
|
|
|
TimeDelta::Millis(60); // Based on Opus spec
|
|
|
|
|
const DataRate kMinOverhead = kOverheadPerPacket / kMaxFrameLength;
|
|
|
|
|
constraints.min += kMinOverhead;
|
|
|
|
|
constraints.max += kMinOverhead;
|
|
|
|
|
} else {
|
|
|
|
|
if (!frame_length_range_.has_value()) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "frame_length_range_ is not set";
|
2024-08-29 13:00:40 +00:00
|
|
|
return std::nullopt;
|
2019-10-02 12:27:06 +02:00
|
|
|
}
|
2024-01-22 14:49:15 +01:00
|
|
|
const DataSize overhead_per_packet = DataSize::Bytes(overhead_per_packet_);
|
|
|
|
|
constraints.min += overhead_per_packet / frame_length_range_->second;
|
|
|
|
|
constraints.max += overhead_per_packet / frame_length_range_->first;
|
2019-05-03 14:40:13 +02:00
|
|
|
}
|
|
|
|
|
return constraints;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 08:03:42 -07:00
|
|
|
void AudioSendStream::RegisterCngPayloadType(int payload_type,
|
|
|
|
|
int clockrate_hz) {
|
2019-03-06 16:47:29 +01:00
|
|
|
channel_send_->RegisterCngPayloadType(payload_type, clockrate_hz);
|
2017-04-27 08:03:42 -07:00
|
|
|
}
|
2021-02-03 13:33:28 +01:00
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace webrtc
|