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

Side by Side Diff: content/browser/speech/audio_encoder.h

Issue 9861019: Speech refactoring: Turned AudioChunk into a refcounted class (CL1.4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
OLDNEW
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 #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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/browser/speech/audio_buffer.h" 13 #include "content/browser/speech/audio_buffer.h"
14 14
15 namespace speech { 15 namespace speech {
16 class AudioChunk; 16 class AudioChunk;
17 // Provides a simple interface to encode raw audio using the various speech 17 // Provides a simple interface to encode raw audio using the various speech
18 // codecs. 18 // codecs.
19 class AudioEncoder { 19 class AudioEncoder {
20 public: 20 public:
21 enum Codec { 21 enum Codec {
22 CODEC_FLAC, 22 CODEC_FLAC,
23 CODEC_SPEEX, 23 CODEC_SPEEX,
24 }; 24 };
25 25
26 static AudioEncoder* Create(Codec codec, 26 static AudioEncoder* Create(Codec codec,
27 int sampling_rate, 27 int sampling_rate,
28 int bits_per_sample); 28 int bits_per_sample);
29 29
30 virtual ~AudioEncoder(); 30 virtual ~AudioEncoder();
31 31
32 // Encodes |raw audio| to the internal buffer. Use 32 // Encodes |raw audio| to the internal buffer. Use
33 // |GetEncodedDataAndClear| to read the result after this call or when 33 // |GetEncodedDataAndClear| to read the result after this call or when
34 // audio capture completes. 34 // audio capture completes.
35 virtual void Encode(const AudioChunk& raw_audio) = 0; 35 virtual void Encode(const AudioChunk& raw_audio) = 0;
36 36
37 // Finish encoding and flush any pending encoded bits out. 37 // Finish encoding and flush any pending encoded bits out.
38 virtual void Flush() = 0; 38 virtual void Flush() = 0;
39 39
40 // Merges, retrieves and clears all the accumulated encoded audio chunks. 40 // Merges, retrieves and clears all the accumulated encoded audio chunks.
41 scoped_ptr<AudioChunk> GetEncodedDataAndClear(); 41 scoped_refptr<AudioChunk> GetEncodedDataAndClear();
42 42
43 const std::string& mime_type() { return mime_type_; } 43 const std::string& mime_type() { return mime_type_; }
44 int bits_per_sample() { return bits_per_sample_; } 44 int bits_per_sample() { return bits_per_sample_; }
45 45
46 protected: 46 protected:
47 AudioEncoder(const std::string& mime_type, int bits_per_sample); 47 AudioEncoder(const std::string& mime_type, int bits_per_sample);
48 AudioBuffer encoded_audio_buffer_; 48 AudioBuffer encoded_audio_buffer_;
49 49
50 private: 50 private:
51 std::string mime_type_; 51 std::string mime_type_;
52 int bits_per_sample_; 52 int bits_per_sample_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); 54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder);
55 }; 55 };
56 56
57 } // namespace speech 57 } // namespace speech
58 58
59 #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ 59 #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698