| OLD | NEW |
| 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" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 //-------------------------------- SpeexEncoder -------------------------------- | 103 //-------------------------------- SpeexEncoder -------------------------------- |
| 104 | 104 |
| 105 const char* const kContentTypeSpeex = "audio/x-speex-with-header-byte; rate="; | 105 const char* const kContentTypeSpeex = "audio/x-speex-with-header-byte; rate="; |
| 106 const int kSpeexEncodingQuality = 8; | 106 const int kSpeexEncodingQuality = 8; |
| 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 static_assert(kMaxSpeexFrameLength <= 0xFF, "invalid length"); |
| 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 ~SpeexEncoder() override; | 116 ~SpeexEncoder() override; |
| 117 void Encode(const AudioChunk& raw_audio) override; | 117 void Encode(const AudioChunk& raw_audio) override; |
| 118 void Flush() override {} | 118 void Flush() override {} |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 void* encoder_state_; | 121 void* encoder_state_; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |