Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / media / cast / test / audio_utility.h
blobeea476badcb20dfb089ef86a785e24904ea6256f
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_TEST_AUDIO_UTILITY_H_
6 #define MEDIA_CAST_TEST_AUDIO_UTILITY_H_
8 #include "media/audio/simple_sources.h"
10 namespace base {
11 class TimeDelta;
14 namespace media {
15 class AudioBus;
18 namespace media {
19 namespace cast {
21 struct PcmAudioFrame;
23 // Produces AudioBuses of varying duration where each successive output contains
24 // the continuation of a single sine wave.
25 class TestAudioBusFactory {
26 public:
27 TestAudioBusFactory(int num_channels, int sample_rate,
28 float sine_wave_frequency, float volume);
29 ~TestAudioBusFactory();
31 // Creates a new AudioBus of the given |duration|, filled with the next batch
32 // of sine wave samples.
33 scoped_ptr<AudioBus> NextAudioBus(const base::TimeDelta& duration);
35 // A reasonable test tone.
36 static const int kMiddleANoteFreq = 440;
38 private:
39 const int num_channels_;
40 const int sample_rate_;
41 const float volume_;
42 SineWaveAudioSource source_;
44 DISALLOW_COPY_AND_ASSIGN(TestAudioBusFactory);
47 // Convenience function to convert an |audio_bus| to its equivalent
48 // PcmAudioFrame.
49 // TODO(miu): Remove this once all code has migrated to use AudioBus. See
50 // comment in media/cast/cast_config.h.
51 scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus,
52 int sample_rate);
54 // Assuming |samples| contains a single-frequency sine wave (and maybe some
55 // low-amplitude noise), count the number of times the sine wave crosses
56 // zero.
57 int CountZeroCrossings(const std::vector<int16>& samples);
59 } // namespace cast
60 } // namespace media
62 #endif // MEDIA_CAST_TEST_AUDIO_UTILITY_H_