Index: chrome/browser/speech/audio_encoder.h |
diff --git a/chrome/browser/speech/audio_encoder.h b/chrome/browser/speech/audio_encoder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51ec26f6f6288631a5ad6c10afd793754d91d0a6 |
--- /dev/null |
+++ b/chrome/browser/speech/audio_encoder.h |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_ |
+#define CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_ |
+ |
+#include <list> |
+#include <string> |
+ |
+namespace speech_input { |
bulach
2011/01/12 16:27:07
I think Brett sent an email a short time ago, you
Satish
2011/01/17 14:02:05
Yes will change to 'speech' in a subsequent CL
|
+ |
+// Provides a simple interface to encode raw audio using the various speech |
+// codecs. |
+class AudioEncoder { |
+ public: |
+ enum Codec { |
+ FLAC, |
+ SPEEX |
bulach
2011/01/12 16:27:07
add ","
afaict, normally enums values would also
|
+ }; |
+ |
+ static AudioEncoder* Create(Codec codec, |
+ int sampling_rate, |
+ int bits_per_sample); |
+ |
+ virtual ~AudioEncoder(); |
+ |
+ // Encodes each frame of raw audio in |samples| to the internal buffer. Use |
+ // |GetEncodedData| to read the result after this call or when recording |
+ // completes. |
+ virtual void Encode(const short* samples, int num_samples) = 0; |
+ |
+ // Finish encoding and flush any pending encoded bits out. |
+ virtual void Flush() = 0; |
+ |
+ // Copies the encoded audio to the given string. Returns true if the output |
+ // is not empty. |
+ bool GetEncodedData(std::string* encoded_data); |
+ |
+ protected: |
+ // Buffer holding the recorded audio. Owns the strings inside the list. |
+ typedef std::list<std::string*> AudioBufferQueue; |
+ AudioBufferQueue audio_buffers_; |
bulach
2011/01/12 16:27:07
I think all data members should be private, with p
|
+}; |
+ |
+} |
bulach
2011/01/12 16:27:07
// namespace speech_input
|
+ |
+#endif // CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_ |