Injecting Clock into audio streams.
Bug: webrtc:10365 Change-Id: Ia47fd806b84d94fd90b734c87c5e338e36fb695a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125191 Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26969}
This commit is contained in:

committed by
Commit Bot

parent
f23f161950
commit
977b3351b9
@ -67,6 +67,7 @@ std::string AudioReceiveStream::Config::ToString() const {
|
||||
namespace internal {
|
||||
namespace {
|
||||
std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
|
||||
Clock* clock,
|
||||
webrtc::AudioState* audio_state,
|
||||
ProcessThread* module_process_thread,
|
||||
const webrtc::AudioReceiveStream::Config& config,
|
||||
@ -75,7 +76,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
|
||||
internal::AudioState* internal_audio_state =
|
||||
static_cast<internal::AudioState*>(audio_state);
|
||||
return voe::CreateChannelReceive(
|
||||
module_process_thread, internal_audio_state->audio_device_module(),
|
||||
clock, module_process_thread, internal_audio_state->audio_device_module(),
|
||||
config.media_transport, config.rtcp_send_transport, event_log,
|
||||
config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
|
||||
config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
|
||||
@ -85,23 +86,27 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
|
||||
} // namespace
|
||||
|
||||
AudioReceiveStream::AudioReceiveStream(
|
||||
Clock* clock,
|
||||
RtpStreamReceiverControllerInterface* receiver_controller,
|
||||
PacketRouter* packet_router,
|
||||
ProcessThread* module_process_thread,
|
||||
const webrtc::AudioReceiveStream::Config& config,
|
||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||
webrtc::RtcEventLog* event_log)
|
||||
: AudioReceiveStream(receiver_controller,
|
||||
: AudioReceiveStream(clock,
|
||||
receiver_controller,
|
||||
packet_router,
|
||||
config,
|
||||
audio_state,
|
||||
event_log,
|
||||
CreateChannelReceive(audio_state.get(),
|
||||
CreateChannelReceive(clock,
|
||||
audio_state.get(),
|
||||
module_process_thread,
|
||||
config,
|
||||
event_log)) {}
|
||||
|
||||
AudioReceiveStream::AudioReceiveStream(
|
||||
Clock* clock,
|
||||
RtpStreamReceiverControllerInterface* receiver_controller,
|
||||
PacketRouter* packet_router,
|
||||
const webrtc::AudioReceiveStream::Config& config,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "call/syncable.h"
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
class PacketRouter;
|
||||
@ -41,7 +42,8 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream,
|
||||
public AudioMixer::Source,
|
||||
public Syncable {
|
||||
public:
|
||||
AudioReceiveStream(RtpStreamReceiverControllerInterface* receiver_controller,
|
||||
AudioReceiveStream(Clock* clock,
|
||||
RtpStreamReceiverControllerInterface* receiver_controller,
|
||||
PacketRouter* packet_router,
|
||||
ProcessThread* module_process_thread,
|
||||
const webrtc::AudioReceiveStream::Config& config,
|
||||
@ -49,6 +51,7 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream,
|
||||
webrtc::RtcEventLog* event_log);
|
||||
// For unit tests, which need to supply a mock channel receive.
|
||||
AudioReceiveStream(
|
||||
Clock* clock,
|
||||
RtpStreamReceiverControllerInterface* receiver_controller,
|
||||
PacketRouter* packet_router,
|
||||
const webrtc::AudioReceiveStream::Config& config,
|
||||
|
@ -115,8 +115,8 @@ struct ConfigHelper {
|
||||
std::unique_ptr<internal::AudioReceiveStream> CreateAudioReceiveStream() {
|
||||
return std::unique_ptr<internal::AudioReceiveStream>(
|
||||
new internal::AudioReceiveStream(
|
||||
&rtp_stream_receiver_controller_, &packet_router_, stream_config_,
|
||||
audio_state_, &event_log_,
|
||||
Clock::GetRealTimeClock(), &rtp_stream_receiver_controller_,
|
||||
&packet_router_, stream_config_, audio_state_, &event_log_,
|
||||
std::unique_ptr<voe::ChannelReceiveInterface>(channel_receive_)));
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -83,6 +82,7 @@ void UpdateEventLogStreamConfig(RtcEventLog* event_log,
|
||||
} // namespace
|
||||
|
||||
AudioSendStream::AudioSendStream(
|
||||
Clock* clock,
|
||||
const webrtc::AudioSendStream::Config& config,
|
||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||
rtc::TaskQueue* worker_queue,
|
||||
@ -92,7 +92,8 @@ AudioSendStream::AudioSendStream(
|
||||
RtcEventLog* event_log,
|
||||
RtcpRttStats* rtcp_rtt_stats,
|
||||
const absl::optional<RtpState>& suspended_rtp_state)
|
||||
: AudioSendStream(config,
|
||||
: AudioSendStream(clock,
|
||||
config,
|
||||
audio_state,
|
||||
worker_queue,
|
||||
rtp_transport,
|
||||
@ -100,7 +101,8 @@ AudioSendStream::AudioSendStream(
|
||||
event_log,
|
||||
rtcp_rtt_stats,
|
||||
suspended_rtp_state,
|
||||
voe::CreateChannelSend(worker_queue,
|
||||
voe::CreateChannelSend(clock,
|
||||
worker_queue,
|
||||
module_process_thread,
|
||||
config.media_transport,
|
||||
/*overhead_observer=*/this,
|
||||
@ -113,6 +115,7 @@ AudioSendStream::AudioSendStream(
|
||||
config.rtcp_report_interval_ms)) {}
|
||||
|
||||
AudioSendStream::AudioSendStream(
|
||||
Clock* clock,
|
||||
const webrtc::AudioSendStream::Config& config,
|
||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||
rtc::TaskQueue* worker_queue,
|
||||
@ -122,7 +125,8 @@ AudioSendStream::AudioSendStream(
|
||||
RtcpRttStats* rtcp_rtt_stats,
|
||||
const absl::optional<RtpState>& suspended_rtp_state,
|
||||
std::unique_ptr<voe::ChannelSendInterface> channel_send)
|
||||
: worker_queue_(worker_queue),
|
||||
: clock_(clock),
|
||||
worker_queue_(worker_queue),
|
||||
config_(Config(/*send_transport=*/nullptr,
|
||||
/*media_transport=*/nullptr)),
|
||||
audio_state_(audio_state),
|
||||
@ -455,7 +459,7 @@ void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) {
|
||||
// TODO(eladalon): This function call could potentially reset the window,
|
||||
// setting both PLR and RPLR to unknown. Consider (during upcoming
|
||||
// refactoring) passing an indication of such an event.
|
||||
packet_loss_tracker_.OnPacketAdded(seq_num, rtc::TimeMillis());
|
||||
packet_loss_tracker_.OnPacketAdded(seq_num, clock_->TimeInMilliseconds());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,8 @@ class AudioSendStream final : public webrtc::AudioSendStream,
|
||||
public webrtc::PacketFeedbackObserver,
|
||||
public webrtc::OverheadObserver {
|
||||
public:
|
||||
AudioSendStream(const webrtc::AudioSendStream::Config& config,
|
||||
AudioSendStream(Clock* clock,
|
||||
const webrtc::AudioSendStream::Config& config,
|
||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||
rtc::TaskQueue* worker_queue,
|
||||
ProcessThread* module_process_thread,
|
||||
@ -49,7 +50,8 @@ class AudioSendStream final : public webrtc::AudioSendStream,
|
||||
RtcpRttStats* rtcp_rtt_stats,
|
||||
const absl::optional<RtpState>& suspended_rtp_state);
|
||||
// For unit tests, which need to supply a mock ChannelSend.
|
||||
AudioSendStream(const webrtc::AudioSendStream::Config& config,
|
||||
AudioSendStream(Clock* clock,
|
||||
const webrtc::AudioSendStream::Config& config,
|
||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||
rtc::TaskQueue* worker_queue,
|
||||
RtpTransportControllerSendInterface* rtp_transport,
|
||||
@ -135,6 +137,7 @@ class AudioSendStream final : public webrtc::AudioSendStream,
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_);
|
||||
|
||||
void RegisterCngPayloadType(int payload_type, int clockrate_hz);
|
||||
Clock* clock_;
|
||||
|
||||
rtc::ThreadChecker worker_thread_checker_;
|
||||
rtc::ThreadChecker pacer_thread_checker_;
|
||||
|
@ -163,8 +163,9 @@ struct ConfigHelper {
|
||||
std::unique_ptr<internal::AudioSendStream> CreateAudioSendStream() {
|
||||
return std::unique_ptr<internal::AudioSendStream>(
|
||||
new internal::AudioSendStream(
|
||||
stream_config_, audio_state_, &worker_queue_, &rtp_transport_,
|
||||
&bitrate_allocator_, &event_log_, &rtcp_rtt_stats_, absl::nullopt,
|
||||
Clock::GetRealTimeClock(), stream_config_, audio_state_,
|
||||
&worker_queue_, &rtp_transport_, &bitrate_allocator_, &event_log_,
|
||||
&rtcp_rtt_stats_, absl::nullopt,
|
||||
std::unique_ptr<voe::ChannelSendInterface>(channel_send_)));
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,8 @@ class ChannelReceive : public ChannelReceiveInterface,
|
||||
public MediaTransportAudioSinkInterface {
|
||||
public:
|
||||
// Used for receive streams.
|
||||
ChannelReceive(ProcessThread* module_process_thread,
|
||||
ChannelReceive(Clock* clock,
|
||||
ProcessThread* module_process_thread,
|
||||
AudioDeviceModule* audio_device_module,
|
||||
MediaTransportInterface* media_transport,
|
||||
Transport* rtcp_send_transport,
|
||||
@ -428,6 +429,7 @@ int ChannelReceive::PreferredSampleRate() const {
|
||||
}
|
||||
|
||||
ChannelReceive::ChannelReceive(
|
||||
Clock* clock,
|
||||
ProcessThread* module_process_thread,
|
||||
AudioDeviceModule* audio_device_module,
|
||||
MediaTransportInterface* media_transport,
|
||||
@ -443,11 +445,10 @@ ChannelReceive::ChannelReceive(
|
||||
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
|
||||
const webrtc::CryptoOptions& crypto_options)
|
||||
: event_log_(rtc_event_log),
|
||||
rtp_receive_statistics_(
|
||||
ReceiveStatistics::Create(Clock::GetRealTimeClock())),
|
||||
rtp_receive_statistics_(ReceiveStatistics::Create(clock)),
|
||||
remote_ssrc_(remote_ssrc),
|
||||
_outputAudioLevel(),
|
||||
ntp_estimator_(Clock::GetRealTimeClock()),
|
||||
ntp_estimator_(clock),
|
||||
playout_timestamp_rtp_(0),
|
||||
playout_delay_ms_(0),
|
||||
rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
|
||||
@ -480,6 +481,7 @@ ChannelReceive::ChannelReceive(
|
||||
|
||||
rtp_receive_statistics_->EnableRetransmitDetection(remote_ssrc_, true);
|
||||
RtpRtcp::Configuration configuration;
|
||||
configuration.clock = clock;
|
||||
configuration.audio = true;
|
||||
configuration.receiver_only = true;
|
||||
configuration.outgoing_transport = rtcp_send_transport;
|
||||
@ -959,6 +961,7 @@ int64_t ChannelReceive::GetRTT() const {
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
|
||||
Clock* clock,
|
||||
ProcessThread* module_process_thread,
|
||||
AudioDeviceModule* audio_device_module,
|
||||
MediaTransportInterface* media_transport,
|
||||
@ -974,7 +977,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
|
||||
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
|
||||
const webrtc::CryptoOptions& crypto_options) {
|
||||
return absl::make_unique<ChannelReceive>(
|
||||
module_process_thread, audio_device_module, media_transport,
|
||||
clock, module_process_thread, audio_device_module, media_transport,
|
||||
rtcp_send_transport, rtc_event_log, remote_ssrc,
|
||||
jitter_buffer_max_packets, jitter_buffer_fast_playout,
|
||||
jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling,
|
||||
|
@ -136,6 +136,7 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface {
|
||||
};
|
||||
|
||||
std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
|
||||
Clock* clock,
|
||||
ProcessThread* module_process_thread,
|
||||
AudioDeviceModule* audio_device_module,
|
||||
MediaTransportInterface* media_transport,
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
|
||||
@ -85,7 +86,8 @@ class ChannelSend
|
||||
// declaration.
|
||||
friend class VoERtcpObserver;
|
||||
|
||||
ChannelSend(rtc::TaskQueue* encoder_queue,
|
||||
ChannelSend(Clock* clock,
|
||||
rtc::TaskQueue* encoder_queue,
|
||||
ProcessThread* module_process_thread,
|
||||
MediaTransportInterface* media_transport,
|
||||
OverheadObserver* overhead_observer,
|
||||
@ -606,7 +608,8 @@ int32_t ChannelSend::SendMediaTransportAudio(
|
||||
return 0;
|
||||
}
|
||||
|
||||
ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue,
|
||||
ChannelSend::ChannelSend(Clock* clock,
|
||||
rtc::TaskQueue* encoder_queue,
|
||||
ProcessThread* module_process_thread,
|
||||
MediaTransportInterface* media_transport,
|
||||
OverheadObserver* overhead_observer,
|
||||
@ -628,8 +631,8 @@ ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue,
|
||||
feedback_observer_proxy_(new TransportFeedbackProxy()),
|
||||
seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
|
||||
rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
|
||||
retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
|
||||
kMaxRetransmissionWindowMs)),
|
||||
retransmission_rate_limiter_(
|
||||
new RateLimiter(clock, kMaxRetransmissionWindowMs)),
|
||||
use_twcc_plr_for_ana_(
|
||||
webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled"),
|
||||
encoder_queue_(encoder_queue),
|
||||
@ -659,6 +662,7 @@ ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue,
|
||||
configuration.transport_feedback_callback = feedback_observer_proxy_.get();
|
||||
}
|
||||
|
||||
configuration.clock = clock;
|
||||
configuration.audio = true;
|
||||
configuration.outgoing_transport = rtp_transport;
|
||||
|
||||
@ -1217,6 +1221,7 @@ void ChannelSend::OnReceivedRtt(int64_t rtt_ms) {
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<ChannelSendInterface> CreateChannelSend(
|
||||
Clock* clock,
|
||||
rtc::TaskQueue* encoder_queue,
|
||||
ProcessThread* module_process_thread,
|
||||
MediaTransportInterface* media_transport,
|
||||
@ -1229,9 +1234,10 @@ std::unique_ptr<ChannelSendInterface> CreateChannelSend(
|
||||
bool extmap_allow_mixed,
|
||||
int rtcp_report_interval_ms) {
|
||||
return absl::make_unique<ChannelSend>(
|
||||
encoder_queue, module_process_thread, media_transport, overhead_observer,
|
||||
rtp_transport, rtcp_rtt_stats, rtc_event_log, frame_encryptor,
|
||||
crypto_options, extmap_allow_mixed, rtcp_report_interval_ms);
|
||||
clock, encoder_queue, module_process_thread, media_transport,
|
||||
overhead_observer, rtp_transport, rtcp_rtt_stats, rtc_event_log,
|
||||
frame_encryptor, crypto_options, extmap_allow_mixed,
|
||||
rtcp_report_interval_ms);
|
||||
}
|
||||
|
||||
} // namespace voe
|
||||
|
@ -115,6 +115,7 @@ class ChannelSendInterface {
|
||||
};
|
||||
|
||||
std::unique_ptr<ChannelSendInterface> CreateChannelSend(
|
||||
Clock* clock,
|
||||
rtc::TaskQueue* encoder_queue,
|
||||
ProcessThread* module_process_thread,
|
||||
MediaTransportInterface* media_transport,
|
||||
|
@ -106,6 +106,7 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
|
||||
ProcessThread::Create("audio recv thread");
|
||||
|
||||
webrtc::internal::AudioReceiveStream receive_stream(
|
||||
Clock::GetRealTimeClock(),
|
||||
/*rtp_stream_receiver_controller=*/nullptr,
|
||||
/*packet_router=*/nullptr, receive_process_thread.get(), receive_config,
|
||||
audio_state, null_event_log.get());
|
||||
@ -120,7 +121,8 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
|
||||
std::unique_ptr<ProcessThread> send_process_thread =
|
||||
ProcessThread::Create("audio send thread");
|
||||
webrtc::internal::AudioSendStream send_stream(
|
||||
send_config, audio_state, &send_tq, send_process_thread.get(),
|
||||
Clock::GetRealTimeClock(), send_config, audio_state, &send_tq,
|
||||
send_process_thread.get(),
|
||||
/*transport=*/nullptr, &bitrate_allocator, null_event_log.get(),
|
||||
/*rtcp_rtt_stats=*/nullptr, absl::optional<RtpState>());
|
||||
|
||||
|
10
call/call.cc
10
call/call.cc
@ -670,10 +670,10 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream(
|
||||
// having it injected.
|
||||
|
||||
AudioSendStream* send_stream = new AudioSendStream(
|
||||
config, config_.audio_state, transport_send_ptr_->GetWorkerQueue(),
|
||||
module_process_thread_.get(), transport_send_ptr_,
|
||||
bitrate_allocator_.get(), event_log_, call_stats_.get(),
|
||||
suspended_rtp_state);
|
||||
clock_, config, config_.audio_state,
|
||||
transport_send_ptr_->GetWorkerQueue(), module_process_thread_.get(),
|
||||
transport_send_ptr_, bitrate_allocator_.get(), event_log_,
|
||||
call_stats_.get(), suspended_rtp_state);
|
||||
{
|
||||
WriteLockScoped write_lock(*send_crit_);
|
||||
RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
|
||||
@ -729,7 +729,7 @@ webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
|
||||
event_log_->Log(absl::make_unique<RtcEventAudioReceiveStreamConfig>(
|
||||
CreateRtcLogStreamConfig(config)));
|
||||
AudioReceiveStream* receive_stream = new AudioReceiveStream(
|
||||
&audio_receiver_controller_, transport_send_ptr_->packet_router(),
|
||||
clock_, &audio_receiver_controller_, transport_send_ptr_->packet_router(),
|
||||
module_process_thread_.get(), config, config_.audio_state, event_log_);
|
||||
{
|
||||
WriteLockScoped write_lock(*receive_crit_);
|
||||
|
Reference in New Issue
Block a user