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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_
6 #define CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/browser/speech/audio_buffer.h"
13 #include "third_party/flac/include/FLAC/stream_encoder.h"
18 // Provides a simple interface to encode raw audio using FLAC codec.
21 AudioEncoder(int sampling_rate
, int bits_per_sample
);
24 // Encodes |raw audio| to the internal buffer. Use
25 // |GetEncodedDataAndClear| to read the result after this call or when
26 // audio capture completes.
27 void Encode(const AudioChunk
& raw_audio
);
29 // Finish encoding and flush any pending encoded bits out.
32 // Merges, retrieves and clears all the accumulated encoded audio chunks.
33 scoped_refptr
<AudioChunk
> GetEncodedDataAndClear();
35 std::string
GetMimeType();
36 int GetBitsPerSample();
39 AudioBuffer encoded_audio_buffer_
;
41 FLAC__StreamEncoder
* encoder_
;
42 bool is_encoder_initialized_
;
44 DISALLOW_COPY_AND_ASSIGN(AudioEncoder
);
47 } // namespace content
49 #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_