OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/audio_modem/modem_impl.h" | 5 #include "components/audio_modem/modem_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
| 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/ptr_util.h" |
18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
21 #include "base/strings/sys_string_conversions.h" | 22 #include "base/strings/sys_string_conversions.h" |
22 #include "base/time/time.h" | 23 #include "base/time/time.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 #include "components/audio_modem/audio_modem_switches.h" | 25 #include "components/audio_modem/audio_modem_switches.h" |
25 #include "components/audio_modem/audio_player_impl.h" | 26 #include "components/audio_modem/audio_player_impl.h" |
26 #include "components/audio_modem/audio_recorder_impl.h" | 27 #include "components/audio_modem/audio_recorder_impl.h" |
27 #include "components/audio_modem/public/whispernet_client.h" | 28 #include "components/audio_modem/public/whispernet_client.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 221 |
221 void ModemImpl::SetTokenParams(AudioType type, const TokenParameters& params) { | 222 void ModemImpl::SetTokenParams(AudioType type, const TokenParameters& params) { |
222 DCHECK_GT(params.length, 0u); | 223 DCHECK_GT(params.length, 0u); |
223 token_params_[type] = params; | 224 token_params_[type] = params; |
224 | 225 |
225 // TODO(ckehoe): Make whispernet handle different token lengths | 226 // TODO(ckehoe): Make whispernet handle different token lengths |
226 // simultaneously without reinitializing the decoder over and over. | 227 // simultaneously without reinitializing the decoder over and over. |
227 } | 228 } |
228 | 229 |
229 // static | 230 // static |
230 scoped_ptr<Modem> Modem::Create() { | 231 std::unique_ptr<Modem> Modem::Create() { |
231 return make_scoped_ptr<Modem>(new ModemImpl); | 232 return base::WrapUnique<Modem>(new ModemImpl); |
232 } | 233 } |
233 | 234 |
234 // Private functions. | 235 // Private functions. |
235 | 236 |
236 void ModemImpl::OnTokenEncoded( | 237 void ModemImpl::OnTokenEncoded( |
237 AudioType type, | 238 AudioType type, |
238 const std::string& token, | 239 const std::string& token, |
239 const scoped_refptr<media::AudioBusRefCounted>& samples) { | 240 const scoped_refptr<media::AudioBusRefCounted>& samples) { |
240 samples_caches_[type]->Put(token, samples); | 241 samples_caches_[type]->Put(token, samples); |
241 DumpToken(type, token, samples.get()); | 242 DumpToken(type, token, samples.get()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 file_str = base::SysWideToNativeMB(file_path.value()); | 335 file_str = base::SysWideToNativeMB(file_path.value()); |
335 #else | 336 #else |
336 file_str = dump_tokens_dir_.Append(filename).value(); | 337 file_str = dump_tokens_dir_.Append(filename).value(); |
337 #endif | 338 #endif |
338 | 339 |
339 webrtc::WavWriter writer(file_str, kDefaultSampleRate, kMonoChannelCount); | 340 webrtc::WavWriter writer(file_str, kDefaultSampleRate, kMonoChannelCount); |
340 writer.WriteSamples(int_samples.data(), int_samples.size()); | 341 writer.WriteSamples(int_samples.data(), int_samples.size()); |
341 } | 342 } |
342 | 343 |
343 } // namespace audio_modem | 344 } // namespace audio_modem |
OLD | NEW |