Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6390)

Unified Diff: chrome/browser/speech/audio_encoder.h

Issue 6111009: Add the option of compressing speech input audio using FLAC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/speech/audio_encoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e17a4136025c3860fbf70660784cf2681eb5ad1c
--- /dev/null
+++ b/chrome/browser/speech/audio_encoder.h
@@ -0,0 +1,59 @@
+// 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>
+
+#include "base/basictypes.h"
+
+namespace speech_input {
+
+// Provides a simple interface to encode raw audio using the various speech
+// codecs.
+class AudioEncoder {
+ public:
+ enum Codec {
+ CODEC_FLAC,
+ CODEC_SPEEX,
+ };
+
+ 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);
+
+ const std::string& mime_type() { return mime_type_; }
+
+ protected:
+ AudioEncoder(const std::string& mime_type);
+
+ void AppendToBuffer(std::string* item);
+
+ private:
+ // Buffer holding the recorded audio. Owns the strings inside the list.
+ typedef std::list<std::string*> AudioBufferQueue;
+ AudioBufferQueue audio_buffers_;
+ std::string mime_type_;
+ DISALLOW_COPY_AND_ASSIGN(AudioEncoder);
+};
+
+} // namespace speech_input
+
+#endif // CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_
« no previous file with comments | « no previous file | chrome/browser/speech/audio_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698