OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 // AudioRepetitionDetector detects bit-exact audio repetitions of registered | 20 // AudioRepetitionDetector detects bit-exact audio repetitions of registered |
21 // patterns. A repetition pattern is defined by a look back time. The detector | 21 // patterns. A repetition pattern is defined by a look back time. The detector |
22 // buffers the audio signal and checks equality of each input sample against the | 22 // buffers the audio signal and checks equality of each input sample against the |
23 // samples at the look back positions of all registered patterns, and counts the | 23 // samples at the look back positions of all registered patterns, and counts the |
24 // duration of any consecutive equality. | 24 // duration of any consecutive equality. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 bool Equal(const float* frame, int look_back_samples) const; | 107 bool Equal(const float* frame, int look_back_samples) const; |
108 | 108 |
109 // Check whether the state contains a valid repetition report. | 109 // Check whether the state contains a valid repetition report. |
110 bool HasValidReport(const State* state) const; | 110 bool HasValidReport(const State* state) const; |
111 | 111 |
112 // Used to DCHECK that we are called on the correct thread. Ctor/dtor | 112 // Used to DCHECK that we are called on the correct thread. Ctor/dtor |
113 // should be called on one thread. The rest can be called on another. | 113 // should be called on one thread. The rest can be called on another. |
114 base::ThreadChecker main_thread_checker_; | 114 base::ThreadChecker main_thread_checker_; |
115 base::ThreadChecker processing_thread_checker_; | 115 base::ThreadChecker processing_thread_checker_; |
116 | 116 |
117 ScopedVector<State> states_; | 117 std::vector<std::unique_ptr<State>> states_; |
118 | 118 |
119 // Ring buffer to store input audio. | 119 // Ring buffer to store input audio. |
120 std::vector<float> audio_buffer_; | 120 std::vector<float> audio_buffer_; |
121 | 121 |
122 // Maximum look back time of all registered repetitions. This defines the size | 122 // Maximum look back time of all registered repetitions. This defines the size |
123 // of |audio_buffer_| | 123 // of |audio_buffer_| |
124 int max_look_back_ms_; | 124 int max_look_back_ms_; |
125 | 125 |
126 // The shortest length for repetitions. | 126 // The shortest length for repetitions. |
127 const int min_length_ms_; | 127 const int min_length_ms_; |
(...skipping 16 matching lines...) Expand all Loading... |
144 // Action when a repetition is found. |look_back_ms| provides the look back | 144 // Action when a repetition is found. |look_back_ms| provides the look back |
145 // time of the detected repetition. | 145 // time of the detected repetition. |
146 RepetitionCallback repetition_callback_; | 146 RepetitionCallback repetition_callback_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(AudioRepetitionDetector); | 148 DISALLOW_COPY_AND_ASSIGN(AudioRepetitionDetector); |
149 }; | 149 }; |
150 | 150 |
151 } // namespace content | 151 } // namespace content |
152 | 152 |
153 #endif // CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ | 153 #endif // CONTENT_RENDERER_MEDIA_AUDIO_REPETITION_DETECTOR_H_ |
OLD | NEW |