OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/speech/audio_buffer.h" | 5 #include "content/browser/speech/audio_buffer.h" |
6 #include "content/browser/speech/endpointer/endpointer.h" | 6 #include "content/browser/speech/endpointer/endpointer.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 const int kFrameRate = 50; // 20 ms long frames for AMR encoding. | 10 const int kFrameRate = 50; // 20 ms long frames for AMR encoding. |
11 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding. | 11 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding. |
12 | 12 |
13 // At 8 sample per second a 20 ms frame is 160 samples, which corrsponds | 13 // At 8 sample per second a 20 ms frame is 160 samples, which corrsponds |
14 // to the AMR codec. | 14 // to the AMR codec. |
15 const int kFrameSize = kSampleRate / kFrameRate; // 160 samples. | 15 const int kFrameSize = kSampleRate / kFrameRate; // 160 samples. |
16 COMPILE_ASSERT(kFrameSize == 160, invalid_frame_size); | 16 static_assert(kFrameSize == 160, "invalid frame size"); |
17 } | 17 } |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 class FrameProcessor { | 21 class FrameProcessor { |
22 public: | 22 public: |
23 // Process a single frame of test audio samples. | 23 // Process a single frame of test audio samples. |
24 virtual EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) = 0; | 24 virtual EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) = 0; |
25 }; | 25 }; |
26 | 26 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 endpointer.set_speech_input_complete_silence_length(long_timeout); | 139 endpointer.set_speech_input_complete_silence_length(long_timeout); |
140 endpointer.StartSession(); | 140 endpointer.StartSession(); |
141 | 141 |
142 EndpointerFrameProcessor frame_processor(&endpointer); | 142 EndpointerFrameProcessor frame_processor(&endpointer); |
143 RunEndpointerEventsTest(&frame_processor); | 143 RunEndpointerEventsTest(&frame_processor); |
144 | 144 |
145 endpointer.EndSession(); | 145 endpointer.EndSession(); |
146 } | 146 } |
147 | 147 |
148 } // namespace content | 148 } // namespace content |
OLD | NEW |