diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc index 826d4c4f0..17749fdbc 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc @@ -23,6 +23,7 @@ #include "webrtc/modules/audio_coding/main/acm2/nack.h" #include "webrtc/modules/audio_coding/neteq4/interface/audio_decoder.h" #include "webrtc/modules/audio_coding/neteq4/interface/neteq.h" +#include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" @@ -116,7 +117,7 @@ bool IsCng(int codec_id) { } // namespace -AcmReceiver::AcmReceiver() +AcmReceiver::AcmReceiver(Clock* clock) : id_(0), neteq_config_(), neteq_(NetEq::Create(neteq_config_)), @@ -128,6 +129,7 @@ AcmReceiver::AcmReceiver() current_sample_rate_hz_(neteq_config_.sample_rate_hz), nack_(), nack_enabled_(false), + clock_(clock), av_sync_(false), initial_delay_manager_(), missing_packets_sync_stream_(), @@ -817,7 +819,7 @@ uint32_t AcmReceiver::NowInTimestamp(int decoder_sampling_rate) const { // We masked 6 most significant bits of 32-bit so there is no overflow in // the conversion from milliseconds to timestamp. const uint32_t now_in_ms = static_cast( - TickTime::MillisecondTimestamp() & 0x03ffffff); + clock_->TimeInMilliseconds() & 0x03ffffff); return static_cast( (decoder_sampling_rate / 1000) * now_in_ms); } diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h index 33c55f7a7..fe44de2dc 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h @@ -27,6 +27,7 @@ namespace webrtc { +class Clock; struct CodecInst; class CriticalSectionWrapper; class RWLockWrapper; @@ -47,9 +48,7 @@ class AcmReceiver { }; // Constructor of the class - AcmReceiver(); - - explicit AcmReceiver(NetEq* neteq); + explicit AcmReceiver(Clock* clock); // Destructor of the class. ~AcmReceiver(); @@ -354,6 +353,7 @@ class AcmReceiver { int16_t audio_buffer_[AudioFrame::kMaxDataSizeSamples]; scoped_ptr nack_; bool nack_enabled_; + Clock* clock_; // Indicates if a non-zero initial delay is set, and the receiver is in // AV-sync mode. diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc index d39a1dc7e..815886054 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc @@ -17,6 +17,7 @@ #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h" #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" #include "webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h" +#include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" #include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" @@ -42,8 +43,8 @@ class AcmReceiverTest : public AudioPacketizationCallback, public ::testing::Test { protected: AcmReceiverTest() - : receiver_(new AcmReceiver), - acm_(new AudioCodingModuleImpl(0)), + : receiver_(new AcmReceiver(Clock::GetRealTimeClock())), + acm_(new AudioCodingModuleImpl(0, Clock::GetRealTimeClock())), timestamp_(0), packet_sent_(false), last_packet_send_timestamp_(timestamp_), diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc index 60ed69cb2..1fbeae2f6 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc @@ -24,11 +24,11 @@ const char kExperimentalAcmVersion[] = "acm2"; // Create module AudioCodingModule* AudioCodingModule::Create(int id) { - return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock()); + return new acm2::AudioCodingModuleImpl(id, Clock::GetRealTimeClock()); } AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) { - return new acm1::AudioCodingModuleImpl(id, clock); + return new acm2::AudioCodingModuleImpl(id, clock); } // Get number of supported codecs @@ -101,7 +101,7 @@ AudioCodingModule* AudioCodingModuleFactory::Create(int id) const { } AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const { - return new acm2::AudioCodingModuleImpl(id); + return new acm2::AudioCodingModuleImpl(id, Clock::GetRealTimeClock()); } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index 92a69cf8f..26a4d30b9 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -114,7 +114,7 @@ static int TimestampLessThan(uint32_t t1, uint32_t t2) { } // namespace -AudioCodingModuleImpl::AudioCodingModuleImpl(int id) +AudioCodingModuleImpl::AudioCodingModuleImpl(int id, Clock* clock) : packetization_callback_(NULL), id_(id), expected_codec_ts_(0xD87F3F9F), @@ -131,6 +131,7 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(int id) stereo_send_(false), current_send_codec_idx_(-1), send_codec_registered_(false), + receiver_(clock), acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), vad_callback_(NULL), is_first_red_(true), diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h index bc4ea0f7a..cdee3f9f0 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h @@ -22,6 +22,7 @@ namespace webrtc { +class Clock; class CriticalSectionWrapper; class RWLockWrapper; @@ -32,7 +33,7 @@ class ACMGenericCodec; class AudioCodingModuleImpl : public AudioCodingModule { public: - explicit AudioCodingModuleImpl(int id); + AudioCodingModuleImpl(int id, Clock* clock); ~AudioCodingModuleImpl(); virtual const char* Version() const;