Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1313873003: Reland: Implement NetEq's CurrentDelay function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing win64 build Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/neteq_impl.cc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 22e71f7f1d8af82f80d3f46c38cf465c84da7f4e..77e245db9d0598d3f7b357c8bd8fb0e809c9f084 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -15,6 +15,7 @@
#include <algorithm>
+#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/safe_conversions.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
@@ -282,8 +283,20 @@ int NetEqImpl::TargetDelay() {
return kNotImplemented;
}
-int NetEqImpl::CurrentDelay() {
- return kNotImplemented;
+int NetEqImpl::CurrentDelayMs() const {
+ CriticalSectionScoped lock(crit_sect_.get());
+ if (fs_hz_ == 0)
+ return 0;
+ // Sum up the samples in the packet buffer with the future length of the sync
+ // buffer, and divide the sum by the sample rate.
+ const size_t delay_samples =
+ packet_buffer_->NumSamplesInBuffer(decoder_database_.get(),
+ decoder_frame_length_) +
+ sync_buffer_->FutureLength();
+ // The division below will truncate.
+ const int delay_ms =
+ static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
+ return delay_ms;
}
// Deprecated.
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698