webrtc_m130/audio/audio_receive_stream.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

482 lines
18 KiB
C++
Raw Normal View History

/*
* 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.
*/
#include "audio/audio_receive_stream.h"
#include <string>
#include <utility>
#include "absl/memory/memory.h"
#include "api/array_view.h"
#include "api/audio_codecs/audio_format.h"
#include "api/call/audio_sink.h"
#include "api/rtp_parameters.h"
#include "api/sequence_checker.h"
#include "audio/audio_send_stream.h"
#include "audio/audio_state.h"
#include "audio/channel_receive.h"
#include "audio/conversion.h"
#include "call/rtp_config.h"
#include "call/rtp_stream_receiver_controller_interface.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
Adding a new string utility class: SimpleStringBuilder. This is a fairly minimalistic string building class that can be used instead of stringstream, which is discouraged but tempting to use due to its convenient interface and familiarity for anyone using our logging macros. As a starter, I'm changing the string building code in ReceiveStatisticsProxy and SendStatisticsProxy from using stringstream and using SimpleStringBuilder instead. In the case of SimpleStringBuilder, there's a single allocation, it's done on the stack (fast), and minimal code is required for each concatenation. The developer is responsible for ensuring that the buffer size is adequate but the class won't overflow the buffer. In dcheck-enabled builds, a check will go off if we run out of buffer space. As part of using SimpleStringBuilder for a small part of rtc::LogMessage, a few more changes were made: - SimpleStringBuilder is used for formatting errors instead of ostringstream. - A new 'noop' state has been introduced for log messages that will be dropped. - Use a static (singleton) noop ostream object for noop logging messages instead of building up an actual ostringstream object that will be dropped. - Add a LogMessageForTest class for better state inspection/testing. - Fix benign bug in LogTest.Perf, change the test to not use File IO and always enable it. - Ensure that minimal work is done for noop messages. - Remove dependency on rtc::Thread. - Add tests for the extra_ field, correctly parsed paths and noop handling. Bug: webrtc:8529, webrtc:4364, webrtc:8933 Change-Id: Ifa258c135135945e4560d9e24315f7d96f784acb Reviewed-on: https://webrtc-review.googlesource.com/55520 Commit-Queue: Tommi <tommi@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22203}
2018-02-27 13:51:08 +01:00
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/time_utils.h"
namespace webrtc {
std::string AudioReceiveStream::Config::Rtp::ToString() const {
char ss_buf[1024];
rtc::SimpleStringBuilder ss(ss_buf);
ss << "{remote_ssrc: " << remote_ssrc;
ss << ", local_ssrc: " << local_ssrc;
ss << ", transport_cc: " << (transport_cc ? "on" : "off");
ss << ", nack: " << nack.ToString();
ss << ", extensions: [";
for (size_t i = 0; i < extensions.size(); ++i) {
ss << extensions[i].ToString();
if (i != extensions.size() - 1) {
ss << ", ";
}
}
ss << ']';
ss << '}';
return ss.str();
}
std::string AudioReceiveStream::Config::ToString() const {
char ss_buf[1024];
rtc::SimpleStringBuilder ss(ss_buf);
ss << "{rtp: " << rtp.ToString();
ss << ", rtcp_send_transport: "
<< (rtcp_send_transport ? "(Transport)" : "null");
if (!sync_group.empty()) {
ss << ", sync_group: " << sync_group;
}
ss << '}';
return ss.str();
}
namespace internal {
namespace {
std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
Clock* clock,
webrtc::AudioState* audio_state,
NetEqFactory* neteq_factory,
const webrtc::AudioReceiveStream::Config& config,
RtcEventLog* event_log) {
RTC_DCHECK(audio_state);
internal::AudioState* internal_audio_state =
static_cast<internal::AudioState*>(audio_state);
return voe::CreateChannelReceive(
clock, neteq_factory, internal_audio_state->audio_device_module(),
config.rtcp_send_transport, event_log, config.rtp.local_ssrc,
config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
config.jitter_buffer_enable_rtx_handling, config.decoder_factory,
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
config.codec_pair_id, std::move(config.frame_decryptor),
config.crypto_options, std::move(config.frame_transformer));
}
} // namespace
AudioReceiveStream::AudioReceiveStream(
Clock* clock,
PacketRouter* packet_router,
NetEqFactory* neteq_factory,
const webrtc::AudioReceiveStream::Config& config,
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
webrtc::RtcEventLog* event_log)
: AudioReceiveStream(clock,
packet_router,
config,
audio_state,
event_log,
CreateChannelReceive(clock,
audio_state.get(),
neteq_factory,
config,
event_log)) {}
AudioReceiveStream::AudioReceiveStream(
Clock* clock,
PacketRouter* packet_router,
const webrtc::AudioReceiveStream::Config& config,
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
webrtc::RtcEventLog* event_log,
std::unique_ptr<voe::ChannelReceiveInterface> channel_receive)
: config_(config),
audio_state_(audio_state),
source_tracker_(clock),
channel_receive_(std::move(channel_receive)) {
RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc;
RTC_DCHECK(config.decoder_factory);
RTC_DCHECK(config.rtcp_send_transport);
RTC_DCHECK(audio_state_);
RTC_DCHECK(channel_receive_);
packet_sequence_checker_.Detach();
RTC_DCHECK(packet_router);
// Configure bandwidth estimation.
channel_receive_->RegisterReceiverCongestionControlObjects(packet_router);
// When output is muted, ChannelReceive will directly notify the source
// tracker of "delivered" frames, so RtpReceiver information will continue to
// be updated.
channel_receive_->SetSourceTracker(&source_tracker_);
// Complete configuration.
// TODO(solenberg): Config NACK history window (which is a packet count),
// using the actual packet size for the configured codec.
channel_receive_->SetNACKStatus(config.rtp.nack.rtp_history_ms != 0,
config.rtp.nack.rtp_history_ms / 20);
channel_receive_->SetReceiveCodecs(config.decoder_map);
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
// `frame_transformer` and `frame_decryptor` have been given to
// `channel_receive_` already.
}
AudioReceiveStream::~AudioReceiveStream() {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc;
Stop();
channel_receive_->SetAssociatedSendChannel(nullptr);
channel_receive_->ResetReceiverCongestionControlObjects();
}
void AudioReceiveStream::RegisterWithTransport(
RtpStreamReceiverControllerInterface* receiver_controller) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
RTC_DCHECK(!rtp_stream_receiver_);
rtp_stream_receiver_ = receiver_controller->CreateReceiver(
config_.rtp.remote_ssrc, channel_receive_.get());
}
void AudioReceiveStream::UnregisterFromTransport() {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
rtp_stream_receiver_.reset();
}
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
void AudioReceiveStream::ReconfigureForTesting(
const webrtc::AudioReceiveStream::Config& config) {
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
// SSRC can't be changed mid-stream.
RTC_DCHECK_EQ(config_.rtp.remote_ssrc, config.rtp.remote_ssrc);
RTC_DCHECK_EQ(config_.rtp.local_ssrc, config.rtp.local_ssrc);
// Configuration parameters which cannot be changed.
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
RTC_DCHECK_EQ(config_.rtcp_send_transport, config.rtcp_send_transport);
// Decoder factory cannot be changed because it is configured at
// voe::Channel construction time.
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
RTC_DCHECK_EQ(config_.decoder_factory, config.decoder_factory);
// TODO(solenberg): Config NACK history window (which is a packet count),
// using the actual packet size for the configured codec.
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
RTC_DCHECK_EQ(config_.rtp.nack.rtp_history_ms, config.rtp.nack.rtp_history_ms)
<< "Use SetUseTransportCcAndNackHistory";
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
RTC_DCHECK(config_.decoder_map == config.decoder_map) << "Use SetDecoderMap";
RTC_DCHECK_EQ(config_.frame_transformer, config.frame_transformer)
<< "Use SetDepacketizerToDecoderFrameTransformer";
config_ = config;
}
void AudioReceiveStream::Start() {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Replace AudioConferenceMixer with AudioMixer. This CL re-routes audio through AudioMixer instead of AudioConferenceMixer. This is done without any modifications to VoiceEngine. Previously, output audio was polled by an AudioDevice through an AudioTransport pointer, which was an instance of VoEBaseImpl. VoiceEngineImpl sent the request for data on to OutputMixer and further to AudioConferenceMixer. This CL changes the audio flow to an AudioDevice. We reconfigure the AudioDevice to have another AudioTransport pointer, which points to an AudioTransportProxy. The AudioTransportProxy is responsible for feeding mixed data to the AudioProcessing component for echo cancellation, and to resample the audio data after AudioProcessing and before it is sent to the AudioDevice. The set up of the audio path was previously done during VoiceEngine initialization. Now it is changed in the AudioState constructor. This list shows where audio-path-related VoiceEngine functionality has been moved: OutputMixer --> AudioTransportProxy VoiceEngineImpl --> AudioState, AudioTransportProxy SharedData --> AudioState Channel --> AudioReceiveStream, ChannelProxy, Channel AudioState owns the new mixer and connects it to AudioTransport and AudioDevice on initialization. The audio input source is AudioReceiveStream, which registers itself with the mixer (which it gets from AudioState) on Start and Stop. # Since the AudioTransport interface contains non-const references. NOPRESUBMIT=True BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2436033002 Cr-Commit-Position: refs/heads/master@{#15193}
2016-11-22 06:42:53 -08:00
if (playing_) {
return;
}
channel_receive_->StartPlayout();
Replace AudioConferenceMixer with AudioMixer. This CL re-routes audio through AudioMixer instead of AudioConferenceMixer. This is done without any modifications to VoiceEngine. Previously, output audio was polled by an AudioDevice through an AudioTransport pointer, which was an instance of VoEBaseImpl. VoiceEngineImpl sent the request for data on to OutputMixer and further to AudioConferenceMixer. This CL changes the audio flow to an AudioDevice. We reconfigure the AudioDevice to have another AudioTransport pointer, which points to an AudioTransportProxy. The AudioTransportProxy is responsible for feeding mixed data to the AudioProcessing component for echo cancellation, and to resample the audio data after AudioProcessing and before it is sent to the AudioDevice. The set up of the audio path was previously done during VoiceEngine initialization. Now it is changed in the AudioState constructor. This list shows where audio-path-related VoiceEngine functionality has been moved: OutputMixer --> AudioTransportProxy VoiceEngineImpl --> AudioState, AudioTransportProxy SharedData --> AudioState Channel --> AudioReceiveStream, ChannelProxy, Channel AudioState owns the new mixer and connects it to AudioTransport and AudioDevice on initialization. The audio input source is AudioReceiveStream, which registers itself with the mixer (which it gets from AudioState) on Start and Stop. # Since the AudioTransport interface contains non-const references. NOPRESUBMIT=True BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2436033002 Cr-Commit-Position: refs/heads/master@{#15193}
2016-11-22 06:42:53 -08:00
playing_ = true;
audio_state()->AddReceivingStream(this);
}
void AudioReceiveStream::Stop() {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Replace AudioConferenceMixer with AudioMixer. This CL re-routes audio through AudioMixer instead of AudioConferenceMixer. This is done without any modifications to VoiceEngine. Previously, output audio was polled by an AudioDevice through an AudioTransport pointer, which was an instance of VoEBaseImpl. VoiceEngineImpl sent the request for data on to OutputMixer and further to AudioConferenceMixer. This CL changes the audio flow to an AudioDevice. We reconfigure the AudioDevice to have another AudioTransport pointer, which points to an AudioTransportProxy. The AudioTransportProxy is responsible for feeding mixed data to the AudioProcessing component for echo cancellation, and to resample the audio data after AudioProcessing and before it is sent to the AudioDevice. The set up of the audio path was previously done during VoiceEngine initialization. Now it is changed in the AudioState constructor. This list shows where audio-path-related VoiceEngine functionality has been moved: OutputMixer --> AudioTransportProxy VoiceEngineImpl --> AudioState, AudioTransportProxy SharedData --> AudioState Channel --> AudioReceiveStream, ChannelProxy, Channel AudioState owns the new mixer and connects it to AudioTransport and AudioDevice on initialization. The audio input source is AudioReceiveStream, which registers itself with the mixer (which it gets from AudioState) on Start and Stop. # Since the AudioTransport interface contains non-const references. NOPRESUBMIT=True BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2436033002 Cr-Commit-Position: refs/heads/master@{#15193}
2016-11-22 06:42:53 -08:00
if (!playing_) {
return;
}
channel_receive_->StopPlayout();
Replace AudioConferenceMixer with AudioMixer. This CL re-routes audio through AudioMixer instead of AudioConferenceMixer. This is done without any modifications to VoiceEngine. Previously, output audio was polled by an AudioDevice through an AudioTransport pointer, which was an instance of VoEBaseImpl. VoiceEngineImpl sent the request for data on to OutputMixer and further to AudioConferenceMixer. This CL changes the audio flow to an AudioDevice. We reconfigure the AudioDevice to have another AudioTransport pointer, which points to an AudioTransportProxy. The AudioTransportProxy is responsible for feeding mixed data to the AudioProcessing component for echo cancellation, and to resample the audio data after AudioProcessing and before it is sent to the AudioDevice. The set up of the audio path was previously done during VoiceEngine initialization. Now it is changed in the AudioState constructor. This list shows where audio-path-related VoiceEngine functionality has been moved: OutputMixer --> AudioTransportProxy VoiceEngineImpl --> AudioState, AudioTransportProxy SharedData --> AudioState Channel --> AudioReceiveStream, ChannelProxy, Channel AudioState owns the new mixer and connects it to AudioTransport and AudioDevice on initialization. The audio input source is AudioReceiveStream, which registers itself with the mixer (which it gets from AudioState) on Start and Stop. # Since the AudioTransport interface contains non-const references. NOPRESUBMIT=True BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2436033002 Cr-Commit-Position: refs/heads/master@{#15193}
2016-11-22 06:42:53 -08:00
playing_ = false;
audio_state()->RemoveReceivingStream(this);
}
bool AudioReceiveStream::IsRunning() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return playing_;
}
Reland "Remove AudioReceiveStream::Reconfigure() method." This reverts commit 8a18e5b3c954a3f9cc006c90356a3d850bcc352f. Reason for revert: Removing the problematic DCHECK. Original change's description: > Revert "Remove AudioReceiveStream::Reconfigure() method." > > This reverts commit e2561e17e29e62c02731f1d214d7ee5ffdaeb941. > > Reason for revert: Speculative revert: breaks an downstream project > > Original change's description: > > Remove AudioReceiveStream::Reconfigure() method. > > > > Instead, adding specific setters that are needed at runtime: > > * SetDepacketizerToDecoderFrameTransformer > > * SetDecoderMap > > * SetUseTransportCcAndNackHistory > > > > The whole config struct is big and much of the state it holds, needs to > > be considered const. For that reason the Reconfigure() method is too > > broad of an interface since it overwrites the whole config struct > > and doesn't actually handle all the potential config changes that might > > occur when the config changes. > > > > Bug: webrtc:11993 > > Change-Id: Ia5311978f56b2e136781467e44f0d18039f0bb2d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221363 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Commit-Queue: Tommi <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34252} > > TBR=saza@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I15ca2d8ee5fd612e13dc1f4b3bfb9c885c21dc66 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:11993 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221746 > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34253} # Not skipping CQ checks because this is a reland. Bug: webrtc:11993 Change-Id: I0d3bf9abdcdc8d3f9259d014e6074a5e6b6cc73c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221747 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34255}
2021-06-09 13:46:28 +02:00
void AudioReceiveStream::SetDepacketizerToDecoderFrameTransformer(
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_receive_->SetDepacketizerToDecoderFrameTransformer(
std::move(frame_transformer));
}
void AudioReceiveStream::SetDecoderMap(
std::map<int, SdpAudioFormat> decoder_map) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
config_.decoder_map = std::move(decoder_map);
channel_receive_->SetReceiveCodecs(config_.decoder_map);
}
void AudioReceiveStream::SetUseTransportCcAndNackHistory(bool use_transport_cc,
int history_ms) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
RTC_DCHECK_GE(history_ms, 0);
config_.rtp.transport_cc = use_transport_cc;
if (config_.rtp.nack.rtp_history_ms != history_ms) {
config_.rtp.nack.rtp_history_ms = history_ms;
// TODO(solenberg): Config NACK history window (which is a packet count),
// using the actual packet size for the configured codec.
channel_receive_->SetNACKStatus(history_ms != 0, history_ms / 20);
}
}
void AudioReceiveStream::SetFrameDecryptor(
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
// TODO(bugs.webrtc.org/11993): This is called via WebRtcAudioReceiveStream,
// expect to be called on the network thread.
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_receive_->SetFrameDecryptor(std::move(frame_decryptor));
}
void AudioReceiveStream::SetRtpExtensions(
std::vector<RtpExtension> extensions) {
// TODO(bugs.webrtc.org/11993): This is called via WebRtcAudioReceiveStream,
// expect to be called on the network thread.
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
config_.rtp.extensions = std::move(extensions);
}
webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats(
bool get_and_clear_legacy_stats) const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
webrtc::AudioReceiveStream::Stats stats;
stats.remote_ssrc = config_.rtp.remote_ssrc;
webrtc::CallReceiveStatistics call_stats =
channel_receive_->GetRTCPStatistics();
// TODO(solenberg): Don't return here if we can't get the codec - return the
// stats we *can* get.
auto receive_codec = channel_receive_->GetReceiveCodec();
if (!receive_codec) {
return stats;
}
stats.payload_bytes_rcvd = call_stats.payload_bytes_rcvd;
stats.header_and_padding_bytes_rcvd =
call_stats.header_and_padding_bytes_rcvd;
stats.packets_rcvd = call_stats.packetsReceived;
stats.packets_lost = call_stats.cumulativeLost;
stats.nacks_sent = call_stats.nacks_sent;
stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
stats.last_packet_received_timestamp_ms =
call_stats.last_packet_received_timestamp_ms;
stats.codec_name = receive_codec->second.name;
stats.codec_payload_type = receive_codec->first;
int clockrate_khz = receive_codec->second.clockrate_hz / 1000;
if (clockrate_khz > 0) {
stats.jitter_ms = call_stats.jitterSamples / clockrate_khz;
}
stats.delay_estimate_ms = channel_receive_->GetDelayEstimate();
stats.audio_level = channel_receive_->GetSpeechOutputLevelFullRange();
stats.total_output_energy = channel_receive_->GetTotalOutputEnergy();
stats.total_output_duration = channel_receive_->GetTotalOutputDuration();
stats.estimated_playout_ntp_timestamp_ms =
channel_receive_->GetCurrentEstimatedPlayoutNtpTimestampMs(
rtc::TimeMillis());
// Get jitter buffer and total delay (alg + jitter + playout) stats.
auto ns = channel_receive_->GetNetworkStatistics(get_and_clear_legacy_stats);
stats.packets_discarded = ns.packetsDiscarded;
stats.fec_packets_received = ns.fecPacketsReceived;
stats.fec_packets_discarded = ns.fecPacketsDiscarded;
stats.jitter_buffer_ms = ns.currentBufferSize;
stats.jitter_buffer_preferred_ms = ns.preferredBufferSize;
stats.total_samples_received = ns.totalSamplesReceived;
stats.concealed_samples = ns.concealedSamples;
stats.silent_concealed_samples = ns.silentConcealedSamples;
stats.concealment_events = ns.concealmentEvents;
stats.jitter_buffer_delay_seconds =
static_cast<double>(ns.jitterBufferDelayMs) /
static_cast<double>(rtc::kNumMillisecsPerSec);
stats.jitter_buffer_emitted_count = ns.jitterBufferEmittedCount;
stats.jitter_buffer_target_delay_seconds =
static_cast<double>(ns.jitterBufferTargetDelayMs) /
static_cast<double>(rtc::kNumMillisecsPerSec);
stats.inserted_samples_for_deceleration = ns.insertedSamplesForDeceleration;
stats.removed_samples_for_acceleration = ns.removedSamplesForAcceleration;
stats.expand_rate = Q14ToFloat(ns.currentExpandRate);
stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate);
stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate);
stats.secondary_discarded_rate = Q14ToFloat(ns.currentSecondaryDiscardedRate);
stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate);
stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate);
stats.jitter_buffer_flushes = ns.packetBufferFlushes;
stats.delayed_packet_outage_samples = ns.delayedPacketOutageSamples;
stats.relative_packet_arrival_delay_seconds =
static_cast<double>(ns.relativePacketArrivalDelayMs) /
static_cast<double>(rtc::kNumMillisecsPerSec);
stats.interruption_count = ns.interruptionCount;
stats.total_interruption_duration_ms = ns.totalInterruptionDurationMs;
auto ds = channel_receive_->GetDecodingCallStatistics();
stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator;
stats.decoding_calls_to_neteq = ds.calls_to_neteq;
stats.decoding_normal = ds.decoded_normal;
stats.decoding_plc = ds.decoded_neteq_plc;
stats.decoding_codec_plc = ds.decoded_codec_plc;
stats.decoding_cng = ds.decoded_cng;
stats.decoding_plc_cng = ds.decoded_plc_cng;
stats.decoding_muted_output = ds.decoded_muted_output;
stats.last_sender_report_timestamp_ms =
call_stats.last_sender_report_timestamp_ms;
stats.last_sender_report_remote_timestamp_ms =
call_stats.last_sender_report_remote_timestamp_ms;
stats.sender_reports_packets_sent = call_stats.sender_reports_packets_sent;
stats.sender_reports_bytes_sent = call_stats.sender_reports_bytes_sent;
stats.sender_reports_reports_count = call_stats.sender_reports_reports_count;
return stats;
}
void AudioReceiveStream::SetSink(AudioSinkInterface* sink) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_receive_->SetSink(sink);
}
void AudioReceiveStream::SetGain(float gain) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_receive_->SetChannelOutputVolumeScaling(gain);
}
bool AudioReceiveStream::SetBaseMinimumPlayoutDelayMs(int delay_ms) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->SetBaseMinimumPlayoutDelayMs(delay_ms);
}
int AudioReceiveStream::GetBaseMinimumPlayoutDelayMs() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetBaseMinimumPlayoutDelayMs();
}
Reland of Implemented the GetSources() in native code. (patchset #1 id:1 of https://codereview.webrtc.org/2809613002/ ) Reason for revert: Re-land, reverting did not fix bug. https://bugs.chromium.org/p/webrtc/issues/detail?id=7465 Original issue's description: > Revert of Implemented the GetSources() in native code. (patchset #11 id:510001 of https://codereview.webrtc.org/2770233003/ ) > > Reason for revert: > Suspected of WebRtcApprtcBrowserTest.MANUAL_WorksOnApprtc breakage, see > > https://bugs.chromium.org/p/webrtc/issues/detail?id=7465 > > Original issue's description: > > Added the GetSources() to the RtpReceiverInterface and implemented > > it for the AudioRtpReceiver. > > > > This method returns a vector of RtpSource(both CSRC source and SSRC > > source) which contains the ID of a source, the timestamp, the source > > type (SSRC or CSRC) and the audio level. > > > > The RtpSource objects are buffered and maintained by the > > RtpReceiver in webrtc/modules/rtp_rtcp/. When the method is called, > > the info of the contributing source will be pulled along the object > > chain: > > AudioRtpReceiver -> VoiceChannel -> WebRtcVoiceMediaChannel -> > > AudioReceiveStream -> voe::Channel -> RtpRtcp module > > > > Spec:https://w3c.github.io/webrtc-pc/archives/20151006/webrtc.html#widl-RTCRtpReceiver-getContributingSources-sequence-RTCRtpContributingSource > > > > BUG=chromium:703122 > > TBR=stefan@webrtc.org, danilchap@webrtc.org > > > > Review-Url: https://codereview.webrtc.org/2770233003 > > Cr-Commit-Position: refs/heads/master@{#17591} > > Committed: https://chromium.googlesource.com/external/webrtc/+/292084c3765d9f3ee406ca2ec86eae206b540053 > > TBR=deadbeef@webrtc.org,solenberg@webrtc.org,hbos@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=chromium:703122 > > Review-Url: https://codereview.webrtc.org/2809613002 > Cr-Commit-Position: refs/heads/master@{#17616} > Committed: https://chromium.googlesource.com/external/webrtc/+/fbcc5cb3869d1370008e40f24fc03ac8fb69c675 TBR=deadbeef@webrtc.org,solenberg@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org,olka@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:703122 Review-Url: https://codereview.webrtc.org/2810623003 Cr-Commit-Position: refs/heads/master@{#17621}
2017-04-10 07:39:05 -07:00
std::vector<RtpSource> AudioReceiveStream::GetSources() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Reland "Replace the implementation of `GetContributingSources()` on the audio side." This reverts commit 67008dfb366237469fe088a61b62c0cad852c024. Reason for revert: Tests in the Chromium repo have been changed to accomodate this CL: https://chromium-review.googlesource.com/c/chromium/src/+/1728565 Original change's description: > Revert "Replace the implementation of `GetContributingSources()` on the audio side." > > This reverts commit 8fa7151e4bbad40fec1f964fe0c003b8787bb78a. > > Reason for revert: Speculative revert to fix roll of webrtc into chrome. Right now tests related to RTCRtpReceiver failing and looks like it is main candidate, who can affect that behavior. > > Original change's description: > > Replace the implementation of `GetContributingSources()` on the audio side. > > > > This change replaces the `ContributingSources`-implementation of `GetContributingSources()` and `GetSynchronizationSources()` on the audio side with the spec-compliant `SourceTracker`-implementation. > > > > The most noticeable impact is that the per-frame dictionaries are now updated when frames are delivered to the RTCRtpReceiver's MediaStreamTrack rather than when RTP packets are received on the network. > > > > This change is almost identical to the previous video side change at: https://webrtc-review.googlesource.com/c/src/+/143177 > > > > Bug: webrtc:10545 > > Change-Id: Ife7f08ee8ca1346099b7466837a3756947085fc5 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144422 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Commit-Queue: Chen Xing <chxg@google.com> > > Cr-Commit-Position: refs/heads/master@{#28459} > > TBR=ossu@webrtc.org,chxg@google.com > > Change-Id: I5c631d4dcfb39601055ffce9b104f45eea871fd3 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10545 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144562 > Reviewed-by: Artem Titov <titovartem@webrtc.org> > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#28478} TBR=ossu@webrtc.org,titovartem@webrtc.org,chxg@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:10545 Change-Id: I609cca4f0ca4e1d31a156ba9eb44407518409f57 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147865 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Chen Xing <chxg@google.com> Commit-Queue: Chen Xing <chxg@google.com> Cr-Commit-Position: refs/heads/master@{#28746}
2019-08-02 10:29:26 +00:00
return source_tracker_.GetSources();
Reland of Implemented the GetSources() in native code. (patchset #1 id:1 of https://codereview.webrtc.org/2809613002/ ) Reason for revert: Re-land, reverting did not fix bug. https://bugs.chromium.org/p/webrtc/issues/detail?id=7465 Original issue's description: > Revert of Implemented the GetSources() in native code. (patchset #11 id:510001 of https://codereview.webrtc.org/2770233003/ ) > > Reason for revert: > Suspected of WebRtcApprtcBrowserTest.MANUAL_WorksOnApprtc breakage, see > > https://bugs.chromium.org/p/webrtc/issues/detail?id=7465 > > Original issue's description: > > Added the GetSources() to the RtpReceiverInterface and implemented > > it for the AudioRtpReceiver. > > > > This method returns a vector of RtpSource(both CSRC source and SSRC > > source) which contains the ID of a source, the timestamp, the source > > type (SSRC or CSRC) and the audio level. > > > > The RtpSource objects are buffered and maintained by the > > RtpReceiver in webrtc/modules/rtp_rtcp/. When the method is called, > > the info of the contributing source will be pulled along the object > > chain: > > AudioRtpReceiver -> VoiceChannel -> WebRtcVoiceMediaChannel -> > > AudioReceiveStream -> voe::Channel -> RtpRtcp module > > > > Spec:https://w3c.github.io/webrtc-pc/archives/20151006/webrtc.html#widl-RTCRtpReceiver-getContributingSources-sequence-RTCRtpContributingSource > > > > BUG=chromium:703122 > > TBR=stefan@webrtc.org, danilchap@webrtc.org > > > > Review-Url: https://codereview.webrtc.org/2770233003 > > Cr-Commit-Position: refs/heads/master@{#17591} > > Committed: https://chromium.googlesource.com/external/webrtc/+/292084c3765d9f3ee406ca2ec86eae206b540053 > > TBR=deadbeef@webrtc.org,solenberg@webrtc.org,hbos@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=chromium:703122 > > Review-Url: https://codereview.webrtc.org/2809613002 > Cr-Commit-Position: refs/heads/master@{#17616} > Committed: https://chromium.googlesource.com/external/webrtc/+/fbcc5cb3869d1370008e40f24fc03ac8fb69c675 TBR=deadbeef@webrtc.org,solenberg@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org,olka@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:703122 Review-Url: https://codereview.webrtc.org/2810623003 Cr-Commit-Position: refs/heads/master@{#17621}
2017-04-10 07:39:05 -07:00
}
AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
int sample_rate_hz,
AudioFrame* audio_frame) {
Reland "Replace the implementation of `GetContributingSources()` on the audio side." This reverts commit 67008dfb366237469fe088a61b62c0cad852c024. Reason for revert: Tests in the Chromium repo have been changed to accomodate this CL: https://chromium-review.googlesource.com/c/chromium/src/+/1728565 Original change's description: > Revert "Replace the implementation of `GetContributingSources()` on the audio side." > > This reverts commit 8fa7151e4bbad40fec1f964fe0c003b8787bb78a. > > Reason for revert: Speculative revert to fix roll of webrtc into chrome. Right now tests related to RTCRtpReceiver failing and looks like it is main candidate, who can affect that behavior. > > Original change's description: > > Replace the implementation of `GetContributingSources()` on the audio side. > > > > This change replaces the `ContributingSources`-implementation of `GetContributingSources()` and `GetSynchronizationSources()` on the audio side with the spec-compliant `SourceTracker`-implementation. > > > > The most noticeable impact is that the per-frame dictionaries are now updated when frames are delivered to the RTCRtpReceiver's MediaStreamTrack rather than when RTP packets are received on the network. > > > > This change is almost identical to the previous video side change at: https://webrtc-review.googlesource.com/c/src/+/143177 > > > > Bug: webrtc:10545 > > Change-Id: Ife7f08ee8ca1346099b7466837a3756947085fc5 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144422 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Commit-Queue: Chen Xing <chxg@google.com> > > Cr-Commit-Position: refs/heads/master@{#28459} > > TBR=ossu@webrtc.org,chxg@google.com > > Change-Id: I5c631d4dcfb39601055ffce9b104f45eea871fd3 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10545 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144562 > Reviewed-by: Artem Titov <titovartem@webrtc.org> > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#28478} TBR=ossu@webrtc.org,titovartem@webrtc.org,chxg@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:10545 Change-Id: I609cca4f0ca4e1d31a156ba9eb44407518409f57 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147865 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Chen Xing <chxg@google.com> Commit-Queue: Chen Xing <chxg@google.com> Cr-Commit-Position: refs/heads/master@{#28746}
2019-08-02 10:29:26 +00:00
AudioMixer::Source::AudioFrameInfo audio_frame_info =
channel_receive_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
if (audio_frame_info != AudioMixer::Source::AudioFrameInfo::kError) {
source_tracker_.OnFrameDelivered(audio_frame->packet_infos_);
}
return audio_frame_info;
}
int AudioReceiveStream::Ssrc() const {
return config_.rtp.remote_ssrc;
}
int AudioReceiveStream::PreferredSampleRate() const {
return channel_receive_->PreferredSampleRate();
}
uint32_t AudioReceiveStream::id() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return config_.rtp.remote_ssrc;
}
absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
// TODO(bugs.webrtc.org/11993): This is called via RtpStreamsSynchronizer,
// expect to be called on the network thread.
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetSyncInfo();
}
bool AudioReceiveStream::GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp,
int64_t* time_ms) const {
// Called on video capture thread.
return channel_receive_->GetPlayoutRtpTimestamp(rtp_timestamp, time_ms);
}
void AudioReceiveStream::SetEstimatedPlayoutNtpTimestampMs(
int64_t ntp_timestamp_ms,
int64_t time_ms) {
// Called on video capture thread.
channel_receive_->SetEstimatedPlayoutNtpTimestampMs(ntp_timestamp_ms,
time_ms);
}
bool AudioReceiveStream::SetMinimumPlayoutDelay(int delay_ms) {
// TODO(bugs.webrtc.org/11993): This is called via RtpStreamsSynchronizer,
// expect to be called on the network thread.
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->SetMinimumPlayoutDelay(delay_ms);
}
void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
channel_receive_->SetAssociatedSendChannel(
send_stream ? send_stream->GetChannel() : nullptr);
associated_send_stream_ = send_stream;
}
void AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
// TODO(solenberg): Tests call this function on a network thread, libjingle
// calls on the worker thread. We should move towards always using a network
// thread. Then this check can be enabled.
// RTC_DCHECK(!thread_checker_.IsCurrent());
channel_receive_->ReceivedRTCPPacket(packet, length);
}
void AudioReceiveStream::SetSyncGroup(const std::string& sync_group) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
config_.sync_group = sync_group;
}
void AudioReceiveStream::SetLocalSsrc(uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
// TODO(tommi): Consider storing local_ssrc in one place.
config_.rtp.local_ssrc = local_ssrc;
channel_receive_->OnLocalSsrcChange(local_ssrc);
}
uint32_t AudioReceiveStream::local_ssrc() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
RTC_DCHECK_EQ(config_.rtp.local_ssrc, channel_receive_->GetLocalSsrc());
return config_.rtp.local_ssrc;
}
const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return config_;
}
const AudioSendStream* AudioReceiveStream::GetAssociatedSendStreamForTesting()
const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
return associated_send_stream_;
}
Replace AudioConferenceMixer with AudioMixer. This CL re-routes audio through AudioMixer instead of AudioConferenceMixer. This is done without any modifications to VoiceEngine. Previously, output audio was polled by an AudioDevice through an AudioTransport pointer, which was an instance of VoEBaseImpl. VoiceEngineImpl sent the request for data on to OutputMixer and further to AudioConferenceMixer. This CL changes the audio flow to an AudioDevice. We reconfigure the AudioDevice to have another AudioTransport pointer, which points to an AudioTransportProxy. The AudioTransportProxy is responsible for feeding mixed data to the AudioProcessing component for echo cancellation, and to resample the audio data after AudioProcessing and before it is sent to the AudioDevice. The set up of the audio path was previously done during VoiceEngine initialization. Now it is changed in the AudioState constructor. This list shows where audio-path-related VoiceEngine functionality has been moved: OutputMixer --> AudioTransportProxy VoiceEngineImpl --> AudioState, AudioTransportProxy SharedData --> AudioState Channel --> AudioReceiveStream, ChannelProxy, Channel AudioState owns the new mixer and connects it to AudioTransport and AudioDevice on initialization. The audio input source is AudioReceiveStream, which registers itself with the mixer (which it gets from AudioState) on Start and Stop. # Since the AudioTransport interface contains non-const references. NOPRESUBMIT=True BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2436033002 Cr-Commit-Position: refs/heads/master@{#15193}
2016-11-22 06:42:53 -08:00
internal::AudioState* AudioReceiveStream::audio_state() const {
auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
RTC_DCHECK(audio_state);
return audio_state;
}
} // namespace internal
} // namespace webrtc