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

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

Issue 631083002: Replacing the OVERRIDE with override and FINAL with final in content/browser/speech (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | content/browser/speech/endpointer/endpointer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/speech/audio_encoder.h" 5 #include "content/browser/speech/audio_encoder.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "content/browser/speech/audio_buffer.h" 12 #include "content/browser/speech/audio_buffer.h"
13 #include "third_party/flac/include/FLAC/stream_encoder.h" 13 #include "third_party/flac/include/FLAC/stream_encoder.h"
14 #include "third_party/speex/include/speex/speex.h" 14 #include "third_party/speex/include/speex/speex.h"
15 15
16 namespace content { 16 namespace content {
17 namespace { 17 namespace {
18 18
19 //-------------------------------- FLACEncoder --------------------------------- 19 //-------------------------------- FLACEncoder ---------------------------------
20 20
21 const char* const kContentTypeFLAC = "audio/x-flac; rate="; 21 const char* const kContentTypeFLAC = "audio/x-flac; rate=";
22 const int kFLACCompressionLevel = 0; // 0 for speed 22 const int kFLACCompressionLevel = 0; // 0 for speed
23 23
24 class FLACEncoder : public AudioEncoder { 24 class FLACEncoder : public AudioEncoder {
25 public: 25 public:
26 FLACEncoder(int sampling_rate, int bits_per_sample); 26 FLACEncoder(int sampling_rate, int bits_per_sample);
27 virtual ~FLACEncoder(); 27 virtual ~FLACEncoder();
28 virtual void Encode(const AudioChunk& raw_audio) OVERRIDE; 28 virtual void Encode(const AudioChunk& raw_audio) override;
29 virtual void Flush() OVERRIDE; 29 virtual void Flush() override;
30 30
31 private: 31 private:
32 static FLAC__StreamEncoderWriteStatus WriteCallback( 32 static FLAC__StreamEncoderWriteStatus WriteCallback(
33 const FLAC__StreamEncoder* encoder, 33 const FLAC__StreamEncoder* encoder,
34 const FLAC__byte buffer[], 34 const FLAC__byte buffer[],
35 size_t bytes, 35 size_t bytes,
36 unsigned samples, 36 unsigned samples,
37 unsigned current_frame, 37 unsigned current_frame,
38 void* client_data); 38 void* client_data);
39 39
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const int kMaxSpeexFrameLength = 110; // (44kbps rate sampled at 32kHz). 107 const int kMaxSpeexFrameLength = 110; // (44kbps rate sampled at 32kHz).
108 108
109 // Since the frame length gets written out as a byte in the encoded packet, 109 // Since the frame length gets written out as a byte in the encoded packet,
110 // make sure it is within the byte range. 110 // make sure it is within the byte range.
111 COMPILE_ASSERT(kMaxSpeexFrameLength <= 0xFF, invalidLength); 111 COMPILE_ASSERT(kMaxSpeexFrameLength <= 0xFF, invalidLength);
112 112
113 class SpeexEncoder : public AudioEncoder { 113 class SpeexEncoder : public AudioEncoder {
114 public: 114 public:
115 explicit SpeexEncoder(int sampling_rate, int bits_per_sample); 115 explicit SpeexEncoder(int sampling_rate, int bits_per_sample);
116 virtual ~SpeexEncoder(); 116 virtual ~SpeexEncoder();
117 virtual void Encode(const AudioChunk& raw_audio) OVERRIDE; 117 virtual void Encode(const AudioChunk& raw_audio) override;
118 virtual void Flush() OVERRIDE {} 118 virtual void Flush() override {}
119 119
120 private: 120 private:
121 void* encoder_state_; 121 void* encoder_state_;
122 SpeexBits bits_; 122 SpeexBits bits_;
123 int samples_per_frame_; 123 int samples_per_frame_;
124 char encoded_frame_data_[kMaxSpeexFrameLength + 1]; // +1 for the frame size. 124 char encoded_frame_data_[kMaxSpeexFrameLength + 1]; // +1 for the frame size.
125 DISALLOW_COPY_AND_ASSIGN(SpeexEncoder); 125 DISALLOW_COPY_AND_ASSIGN(SpeexEncoder);
126 }; 126 };
127 127
128 SpeexEncoder::SpeexEncoder(int sampling_rate, int bits_per_sample) 128 SpeexEncoder::SpeexEncoder(int sampling_rate, int bits_per_sample)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 AudioEncoder::~AudioEncoder() { 187 AudioEncoder::~AudioEncoder() {
188 } 188 }
189 189
190 scoped_refptr<AudioChunk> AudioEncoder::GetEncodedDataAndClear() { 190 scoped_refptr<AudioChunk> AudioEncoder::GetEncodedDataAndClear() {
191 return encoded_audio_buffer_.DequeueAll(); 191 return encoded_audio_buffer_.DequeueAll();
192 } 192 }
193 193
194 } // namespace content 194 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/speech/endpointer/endpointer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698