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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/speech/audio_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_
6 #define CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_
7
8 #include <list>
9 #include <string>
10
11 #include "base/basictypes.h"
12
13 namespace speech_input {
14
15 // Provides a simple interface to encode raw audio using the various speech
16 // codecs.
17 class AudioEncoder {
18 public:
19 enum Codec {
20 CODEC_FLAC,
21 CODEC_SPEEX,
22 };
23
24 static AudioEncoder* Create(Codec codec,
25 int sampling_rate,
26 int bits_per_sample);
27
28 virtual ~AudioEncoder();
29
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
32 // completes.
33 virtual void Encode(const short* samples, int num_samples) = 0;
34
35 // Finish encoding and flush any pending encoded bits out.
36 virtual void Flush() = 0;
37
38 // Copies the encoded audio to the given string. Returns true if the output
39 // is not empty.
40 bool GetEncodedData(std::string* encoded_data);
41
42 const std::string& mime_type() { return mime_type_; }
43
44 protected:
45 AudioEncoder(const std::string& mime_type);
46
47 void AppendToBuffer(std::string* item);
48
49 private:
50 // Buffer holding the recorded audio. Owns the strings inside the list.
51 typedef std::list<std::string*> AudioBufferQueue;
52 AudioBufferQueue audio_buffers_;
53 std::string mime_type_;
54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder);
55 };
56
57 } // namespace speech_input
58
59 #endif // CHROME_BROWSER_SPEECH_AUDIO_ENCODER_H_
OLDNEW
« 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