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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h" 11 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <memory.h> // memset 14 #include <memory.h> // memset
15 15
16 #include <algorithm> 16 #include <algorithm>
17 17
18 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
19 #include "webrtc/base/safe_conversions.h" 20 #include "webrtc/base/safe_conversions.h"
20 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
21 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 22 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
22 #include "webrtc/modules/audio_coding/neteq/accelerate.h" 23 #include "webrtc/modules/audio_coding/neteq/accelerate.h"
23 #include "webrtc/modules/audio_coding/neteq/background_noise.h" 24 #include "webrtc/modules/audio_coding/neteq/background_noise.h"
24 #include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h" 25 #include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h"
25 #include "webrtc/modules/audio_coding/neteq/comfort_noise.h" 26 #include "webrtc/modules/audio_coding/neteq/comfort_noise.h"
26 #include "webrtc/modules/audio_coding/neteq/decision_logic.h" 27 #include "webrtc/modules/audio_coding/neteq/decision_logic.h"
27 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" 28 #include "webrtc/modules/audio_coding/neteq/decoder_database.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 276 }
276 277
277 int NetEqImpl::SetTargetDelay() { 278 int NetEqImpl::SetTargetDelay() {
278 return kNotImplemented; 279 return kNotImplemented;
279 } 280 }
280 281
281 int NetEqImpl::TargetDelay() { 282 int NetEqImpl::TargetDelay() {
282 return kNotImplemented; 283 return kNotImplemented;
283 } 284 }
284 285
285 int NetEqImpl::CurrentDelay() { 286 int NetEqImpl::CurrentDelayMs() const {
286 return kNotImplemented; 287 CriticalSectionScoped lock(crit_sect_.get());
288 if (fs_hz_ == 0)
289 return 0;
290 // Sum up the samples in the packet buffer with the future length of the sync
291 // buffer, and divide the sum by the sample rate.
292 const size_t delay_samples =
293 packet_buffer_->NumSamplesInBuffer(decoder_database_.get(),
294 decoder_frame_length_) +
295 sync_buffer_->FutureLength();
296 // The division below will truncate.
297 const int delay_ms =
298 static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
299 return delay_ms;
287 } 300 }
288 301
289 // Deprecated. 302 // Deprecated.
290 // TODO(henrik.lundin) Delete. 303 // TODO(henrik.lundin) Delete.
291 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) { 304 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
292 CriticalSectionScoped lock(crit_sect_.get()); 305 CriticalSectionScoped lock(crit_sect_.get());
293 if (mode != playout_mode_) { 306 if (mode != playout_mode_) {
294 playout_mode_ = mode; 307 playout_mode_ = mode;
295 CreateDecisionLogic(); 308 CreateDecisionLogic();
296 } 309 }
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 1983
1971 void NetEqImpl::CreateDecisionLogic() { 1984 void NetEqImpl::CreateDecisionLogic() {
1972 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, 1985 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
1973 playout_mode_, 1986 playout_mode_,
1974 decoder_database_.get(), 1987 decoder_database_.get(),
1975 *packet_buffer_.get(), 1988 *packet_buffer_.get(),
1976 delay_manager_.get(), 1989 delay_manager_.get(),
1977 buffer_level_filter_.get())); 1990 buffer_level_filter_.get()));
1978 } 1991 }
1979 } // namespace webrtc 1992 } // namespace webrtc
OLDNEW
« 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