OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_SPEECH_AUDIO_ENCODER_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ |
6 #define CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ | 6 #define CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Encodes each frame of raw audio in |samples| to the internal buffer. Use | 30 // Encodes each frame of raw audio in |samples| to the internal buffer. Use |
31 // |GetEncodedData| to read the result after this call or when recording | 31 // |GetEncodedData| to read the result after this call or when recording |
32 // completes. | 32 // completes. |
33 virtual void Encode(const short* samples, int num_samples) = 0; | 33 virtual void Encode(const short* samples, int num_samples) = 0; |
34 | 34 |
35 // Finish encoding and flush any pending encoded bits out. | 35 // Finish encoding and flush any pending encoded bits out. |
36 virtual void Flush() = 0; | 36 virtual void Flush() = 0; |
37 | 37 |
38 // Copies the encoded audio to the given string. Returns true if the output | 38 // Copies the encoded audio to the given string. Returns true if the output |
39 // is not empty. | 39 // is not empty. |
40 bool GetEncodedData(std::string* encoded_data); | 40 bool GetEncodedDataAndClear(std::string* encoded_data); |
41 | 41 |
42 const std::string& mime_type() { return mime_type_; } | 42 const std::string& mime_type() { return mime_type_; } |
43 | 43 |
44 protected: | 44 protected: |
45 AudioEncoder(const std::string& mime_type); | 45 AudioEncoder(const std::string& mime_type); |
46 | 46 |
47 void AppendToBuffer(std::string* item); | 47 void AppendToBuffer(std::string* item); |
48 | 48 |
49 private: | 49 private: |
50 // Buffer holding the recorded audio. Owns the strings inside the list. | 50 // Buffer holding the recorded audio. Owns the strings inside the list. |
51 typedef std::list<std::string*> AudioBufferQueue; | 51 typedef std::list<std::string*> AudioBufferQueue; |
52 AudioBufferQueue audio_buffers_; | 52 AudioBufferQueue audio_buffers_; |
53 std::string mime_type_; | 53 std::string mime_type_; |
54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); | 54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace speech_input | 57 } // namespace speech_input |
58 | 58 |
59 #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ | 59 #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ |
OLD | NEW |