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