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

Side by Side Diff: webrtc/modules/audio_mixer/default_output_rate_calculator.cc

Issue 2557713006: Injectable output rate calculater for AudioMixer. (Closed)
Patch Set: Include order, win compilation, comments. Created 4 years 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_mixer/default_output_rate_calculator.h"
12
13 #include <algorithm>
14
15 #include "webrtc/modules/audio_processing/include/audio_processing.h"
16
17 namespace webrtc {
18
19 int DefaultOutputRateCalculator::CalculateOutputRate(
20 const std::vector<int>& preferred_sample_rates) {
21 if (preferred_sample_rates.empty()) {
22 return DefaultOutputRateCalculator::kDefaultFrequency;
23 }
24 using NativeRate = AudioProcessing::NativeRate;
25 int maximal_frequency = 0;
ivoc 2016/12/08 10:09:47 How about this: int maximal_frequency = *std::max_
26 for (const int rate : preferred_sample_rates) {
27 RTC_DCHECK_LE(NativeRate::kSampleRate8kHz, rate);
28 RTC_DCHECK_GE(NativeRate::kSampleRate48kHz, rate);
29 maximal_frequency = std::max(maximal_frequency, rate);
30 }
31
32 static constexpr NativeRate native_rates[] = {
33 NativeRate::kSampleRate8kHz, NativeRate::kSampleRate16kHz,
34 NativeRate::kSampleRate32kHz, NativeRate::kSampleRate48kHz};
35 const auto rounded_up_index = std::lower_bound(
36 std::begin(native_rates), std::end(native_rates), maximal_frequency);
37 RTC_DCHECK(rounded_up_index != std::end(native_rates));
38 return *rounded_up_index;
39 }
40 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698