Pass Clock and TaskQueueFactory as Environment in voip audio channel
To make Environment available for creating AudioDecoders to use propagated field trials Bug: webrtc:356878416 Change-Id: Ic2371f038b75402bbd007c948f43c60cc6cca8a9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/358400 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42718}
This commit is contained in:
parent
b4462510c3
commit
943828b7ff
@ -63,6 +63,7 @@ rtc_library("audio_ingress") {
|
|||||||
"../../api:transport_api",
|
"../../api:transport_api",
|
||||||
"../../api/audio:audio_mixer_api",
|
"../../api/audio:audio_mixer_api",
|
||||||
"../../api/audio_codecs:audio_codecs_api",
|
"../../api/audio_codecs:audio_codecs_api",
|
||||||
|
"../../api/environment",
|
||||||
"../../api/voip:voip_api",
|
"../../api/voip:voip_api",
|
||||||
"../../modules/audio_coding",
|
"../../modules/audio_coding",
|
||||||
"../../modules/rtp_rtcp",
|
"../../modules/rtp_rtcp",
|
||||||
@ -87,6 +88,7 @@ rtc_library("audio_egress") {
|
|||||||
"..:audio",
|
"..:audio",
|
||||||
"../../api:sequence_checker",
|
"../../api:sequence_checker",
|
||||||
"../../api/audio_codecs:audio_codecs_api",
|
"../../api/audio_codecs:audio_codecs_api",
|
||||||
|
"../../api/environment",
|
||||||
"../../api/task_queue",
|
"../../api/task_queue",
|
||||||
"../../call:audio_sender_interface",
|
"../../call:audio_sender_interface",
|
||||||
"../../modules/audio_coding",
|
"../../modules/audio_coding",
|
||||||
|
|||||||
@ -28,20 +28,18 @@ constexpr int kRtcpReportIntervalMs = 5000;
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AudioChannel::AudioChannel(
|
AudioChannel::AudioChannel(
|
||||||
|
const Environment& env,
|
||||||
Transport* transport,
|
Transport* transport,
|
||||||
uint32_t local_ssrc,
|
uint32_t local_ssrc,
|
||||||
TaskQueueFactory* task_queue_factory,
|
|
||||||
AudioMixer* audio_mixer,
|
AudioMixer* audio_mixer,
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
||||||
: audio_mixer_(audio_mixer) {
|
: audio_mixer_(audio_mixer) {
|
||||||
RTC_DCHECK(task_queue_factory);
|
|
||||||
RTC_DCHECK(audio_mixer);
|
RTC_DCHECK(audio_mixer);
|
||||||
|
|
||||||
Clock* clock = Clock::GetRealTimeClock();
|
receive_statistics_ = ReceiveStatistics::Create(&env.clock());
|
||||||
receive_statistics_ = ReceiveStatistics::Create(clock);
|
|
||||||
|
|
||||||
RtpRtcpInterface::Configuration rtp_config;
|
RtpRtcpInterface::Configuration rtp_config;
|
||||||
rtp_config.clock = clock;
|
rtp_config.clock = &env.clock();
|
||||||
rtp_config.audio = true;
|
rtp_config.audio = true;
|
||||||
rtp_config.receive_statistics = receive_statistics_.get();
|
rtp_config.receive_statistics = receive_statistics_.get();
|
||||||
rtp_config.rtcp_report_interval_ms = kRtcpReportIntervalMs;
|
rtp_config.rtcp_report_interval_ms = kRtcpReportIntervalMs;
|
||||||
@ -53,11 +51,10 @@ AudioChannel::AudioChannel(
|
|||||||
rtp_rtcp_->SetSendingMediaStatus(false);
|
rtp_rtcp_->SetSendingMediaStatus(false);
|
||||||
rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound);
|
rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound);
|
||||||
|
|
||||||
ingress_ = std::make_unique<AudioIngress>(rtp_rtcp_.get(), clock,
|
ingress_ = std::make_unique<AudioIngress>(env, rtp_rtcp_.get(),
|
||||||
receive_statistics_.get(),
|
receive_statistics_.get(),
|
||||||
std::move(decoder_factory));
|
std::move(decoder_factory));
|
||||||
egress_ =
|
egress_ = std::make_unique<AudioEgress>(env, rtp_rtcp_.get());
|
||||||
std::make_unique<AudioEgress>(rtp_rtcp_.get(), clock, task_queue_factory);
|
|
||||||
|
|
||||||
// Set the instance of audio ingress to be part of audio mixer for ADM to
|
// Set the instance of audio ingress to be part of audio mixer for ADM to
|
||||||
// fetch audio samples to play.
|
// fetch audio samples to play.
|
||||||
|
|||||||
@ -31,9 +31,9 @@ namespace webrtc {
|
|||||||
// these two classes as it has both sending and receiving capabilities.
|
// these two classes as it has both sending and receiving capabilities.
|
||||||
class AudioChannel : public RefCountInterface {
|
class AudioChannel : public RefCountInterface {
|
||||||
public:
|
public:
|
||||||
AudioChannel(Transport* transport,
|
AudioChannel(const Environment& env,
|
||||||
|
Transport* transport,
|
||||||
uint32_t local_ssrc,
|
uint32_t local_ssrc,
|
||||||
TaskQueueFactory* task_queue_factory,
|
|
||||||
AudioMixer* audio_mixer,
|
AudioMixer* audio_mixer,
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
|
||||||
~AudioChannel() override;
|
~AudioChannel() override;
|
||||||
|
|||||||
@ -18,13 +18,11 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
AudioEgress::AudioEgress(RtpRtcpInterface* rtp_rtcp,
|
AudioEgress::AudioEgress(const Environment& env, RtpRtcpInterface* rtp_rtcp)
|
||||||
Clock* clock,
|
|
||||||
TaskQueueFactory* task_queue_factory)
|
|
||||||
: rtp_rtcp_(rtp_rtcp),
|
: rtp_rtcp_(rtp_rtcp),
|
||||||
rtp_sender_audio_(clock, rtp_rtcp_->RtpSender()),
|
rtp_sender_audio_(&env.clock(), rtp_rtcp_->RtpSender()),
|
||||||
audio_coding_(AudioCodingModule::Create()),
|
audio_coding_(AudioCodingModule::Create()),
|
||||||
encoder_queue_(task_queue_factory->CreateTaskQueue(
|
encoder_queue_(env.task_queue_factory().CreateTaskQueue(
|
||||||
"AudioEncoder",
|
"AudioEncoder",
|
||||||
TaskQueueFactory::Priority::NORMAL)),
|
TaskQueueFactory::Priority::NORMAL)),
|
||||||
encoder_queue_checker_(encoder_queue_.get()) {
|
encoder_queue_checker_(encoder_queue_.get()) {
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "api/audio_codecs/audio_format.h"
|
#include "api/audio_codecs/audio_format.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "api/task_queue/task_queue_factory.h"
|
#include "api/task_queue/task_queue_factory.h"
|
||||||
@ -46,9 +47,7 @@ namespace webrtc {
|
|||||||
// smaller footprint.
|
// smaller footprint.
|
||||||
class AudioEgress : public AudioSender, public AudioPacketizationCallback {
|
class AudioEgress : public AudioSender, public AudioPacketizationCallback {
|
||||||
public:
|
public:
|
||||||
AudioEgress(RtpRtcpInterface* rtp_rtcp,
|
AudioEgress(const Environment& env, RtpRtcpInterface* rtp_rtcp);
|
||||||
Clock* clock,
|
|
||||||
TaskQueueFactory* task_queue_factory);
|
|
||||||
~AudioEgress() override;
|
~AudioEgress() override;
|
||||||
|
|
||||||
// Set the encoder format and payload type for AudioCodingModule.
|
// Set the encoder format and payload type for AudioCodingModule.
|
||||||
|
|||||||
@ -41,18 +41,18 @@ acm2::AcmReceiver::Config CreateAcmConfig(
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AudioIngress::AudioIngress(
|
AudioIngress::AudioIngress(
|
||||||
|
const Environment& env,
|
||||||
RtpRtcpInterface* rtp_rtcp,
|
RtpRtcpInterface* rtp_rtcp,
|
||||||
Clock* clock,
|
|
||||||
ReceiveStatistics* receive_statistics,
|
ReceiveStatistics* receive_statistics,
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
||||||
: playing_(false),
|
: env_(env),
|
||||||
|
playing_(false),
|
||||||
remote_ssrc_(0),
|
remote_ssrc_(0),
|
||||||
first_rtp_timestamp_(-1),
|
first_rtp_timestamp_(-1),
|
||||||
rtp_receive_statistics_(receive_statistics),
|
rtp_receive_statistics_(receive_statistics),
|
||||||
rtp_rtcp_(rtp_rtcp),
|
rtp_rtcp_(rtp_rtcp),
|
||||||
acm_receiver_(CreateAcmConfig(decoder_factory)),
|
acm_receiver_(CreateAcmConfig(decoder_factory)),
|
||||||
ntp_estimator_(clock),
|
ntp_estimator_(&env_.clock()) {}
|
||||||
clock_(clock) {}
|
|
||||||
|
|
||||||
AudioIngress::~AudioIngress() = default;
|
AudioIngress::~AudioIngress() = default;
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ void AudioIngress::ReceivedRTPPacket(rtc::ArrayView<const uint8_t> rtp_packet) {
|
|||||||
auto data_view = rtc::ArrayView<const uint8_t>(payload, payload_data_length);
|
auto data_view = rtc::ArrayView<const uint8_t>(payload, payload_data_length);
|
||||||
|
|
||||||
// Push the incoming payload (parsed and ready for decoding) into the ACM.
|
// Push the incoming payload (parsed and ready for decoding) into the ACM.
|
||||||
if (acm_receiver_.InsertPacket(header, data_view, clock_->CurrentTime()) !=
|
if (acm_receiver_.InsertPacket(header, data_view,
|
||||||
0) {
|
env_.clock().CurrentTime()) != 0) {
|
||||||
RTC_DLOG(LS_ERROR) << "AudioIngress::ReceivedRTPPacket() unable to "
|
RTC_DLOG(LS_ERROR) << "AudioIngress::ReceivedRTPPacket() unable to "
|
||||||
"push data to the ACM";
|
"push data to the ACM";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/audio/audio_mixer.h"
|
#include "api/audio/audio_mixer.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/rtp_headers.h"
|
#include "api/rtp_headers.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/voip/voip_statistics.h"
|
#include "api/voip/voip_statistics.h"
|
||||||
@ -46,8 +47,8 @@ namespace webrtc {
|
|||||||
// smaller footprint.
|
// smaller footprint.
|
||||||
class AudioIngress : public AudioMixer::Source {
|
class AudioIngress : public AudioMixer::Source {
|
||||||
public:
|
public:
|
||||||
AudioIngress(RtpRtcpInterface* rtp_rtcp,
|
AudioIngress(const Environment& env,
|
||||||
Clock* clock,
|
RtpRtcpInterface* rtp_rtcp,
|
||||||
ReceiveStatistics* receive_statistics,
|
ReceiveStatistics* receive_statistics,
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
|
||||||
~AudioIngress() override;
|
~AudioIngress() override;
|
||||||
@ -105,6 +106,8 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const Environment env_;
|
||||||
|
|
||||||
// Indicates AudioIngress status as caller invokes Start/StopPlaying.
|
// Indicates AudioIngress status as caller invokes Start/StopPlaying.
|
||||||
// If not playing, incoming RTP data processing is skipped, thus
|
// If not playing, incoming RTP data processing is skipped, thus
|
||||||
// producing no data to output device.
|
// producing no data to output device.
|
||||||
@ -133,8 +136,6 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
|
|
||||||
RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(lock_);
|
RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(lock_);
|
||||||
|
|
||||||
Clock* clock_;
|
|
||||||
|
|
||||||
// For receiving RTP statistics, this tracks the sampling rate value
|
// For receiving RTP statistics, this tracks the sampling rate value
|
||||||
// per payload type set when caller set via SetReceiveCodecs.
|
// per payload type set when caller set via SetReceiveCodecs.
|
||||||
std::map<int, int> receive_codec_info_ RTC_GUARDED_BY(lock_);
|
std::map<int, int> receive_codec_info_ RTC_GUARDED_BY(lock_);
|
||||||
|
|||||||
@ -73,8 +73,7 @@ class AudioChannelTest : public ::testing::Test {
|
|||||||
// simplify network routing logic.
|
// simplify network routing logic.
|
||||||
rtc::scoped_refptr<AudioChannel> audio_channel =
|
rtc::scoped_refptr<AudioChannel> audio_channel =
|
||||||
rtc::make_ref_counted<AudioChannel>(
|
rtc::make_ref_counted<AudioChannel>(
|
||||||
&transport_, ssrc, &env_.task_queue_factory(), audio_mixer_.get(),
|
env_, &transport_, ssrc, audio_mixer_.get(), decoder_factory_);
|
||||||
decoder_factory_);
|
|
||||||
audio_channel->SetEncoder(
|
audio_channel->SetEncoder(
|
||||||
kPcmuPayload, kPcmuFormat,
|
kPcmuPayload, kPcmuFormat,
|
||||||
encoder_factory_->Create(env_, kPcmuFormat,
|
encoder_factory_->Create(env_, kPcmuFormat,
|
||||||
|
|||||||
@ -70,9 +70,7 @@ class AudioEgressTest : public ::testing::Test {
|
|||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
rtp_rtcp_ =
|
rtp_rtcp_ =
|
||||||
CreateRtpStack(time_controller_.GetClock(), &transport_, kRemoteSsrc);
|
CreateRtpStack(time_controller_.GetClock(), &transport_, kRemoteSsrc);
|
||||||
egress_ = std::make_unique<AudioEgress>(
|
egress_ = std::make_unique<AudioEgress>(env_, rtp_rtcp_.get());
|
||||||
rtp_rtcp_.get(), time_controller_.GetClock(),
|
|
||||||
time_controller_.GetTaskQueueFactory());
|
|
||||||
constexpr int kPcmuPayload = 0;
|
constexpr int kPcmuPayload = 0;
|
||||||
egress_->SetEncoder(kPcmuPayload, kPcmuFormat,
|
egress_->SetEncoder(kPcmuPayload, kPcmuFormat,
|
||||||
encoder_factory_->Create(
|
encoder_factory_->Create(
|
||||||
|
|||||||
@ -64,13 +64,10 @@ class AudioIngressTest : public ::testing::Test {
|
|||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
constexpr int kPcmuPayload = 0;
|
constexpr int kPcmuPayload = 0;
|
||||||
ingress_ = std::make_unique<AudioIngress>(
|
ingress_ = std::make_unique<AudioIngress>(
|
||||||
rtp_rtcp_.get(), time_controller_.GetClock(), receive_statistics_.get(),
|
env_, rtp_rtcp_.get(), receive_statistics_.get(), decoder_factory_);
|
||||||
decoder_factory_);
|
|
||||||
ingress_->SetReceiveCodecs({{kPcmuPayload, kPcmuFormat}});
|
ingress_->SetReceiveCodecs({{kPcmuPayload, kPcmuFormat}});
|
||||||
|
|
||||||
egress_ = std::make_unique<AudioEgress>(
|
egress_ = std::make_unique<AudioEgress>(env_, rtp_rtcp_.get());
|
||||||
rtp_rtcp_.get(), time_controller_.GetClock(),
|
|
||||||
time_controller_.GetTaskQueueFactory());
|
|
||||||
egress_->SetEncoder(kPcmuPayload, kPcmuFormat,
|
egress_->SetEncoder(kPcmuPayload, kPcmuFormat,
|
||||||
encoder_factory_->Create(
|
encoder_factory_->Create(
|
||||||
env_, kPcmuFormat, {.payload_type = kPcmuPayload}));
|
env_, kPcmuFormat, {.payload_type = kPcmuPayload}));
|
||||||
|
|||||||
@ -132,8 +132,7 @@ ChannelId VoipCore::CreateChannel(Transport* transport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rtc::scoped_refptr<AudioChannel> channel =
|
rtc::scoped_refptr<AudioChannel> channel =
|
||||||
rtc::make_ref_counted<AudioChannel>(transport, local_ssrc.value(),
|
rtc::make_ref_counted<AudioChannel>(env_, transport, local_ssrc.value(),
|
||||||
&env_.task_queue_factory(),
|
|
||||||
audio_mixer_.get(), decoder_factory_);
|
audio_mixer_.get(), decoder_factory_);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user