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

Side by Side Diff: components/audio_modem/audio_recorder_impl.h

Issue 940123004: Convert audio samples in Whispernet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix. Created 5 years, 10 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
OLDNEW
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 #ifndef COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_ 5 #ifndef COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
6 #define COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_ 6 #define COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "components/audio_modem/audio_recorder.h" 13 #include "components/audio_modem/audio_recorder.h"
14 #include "media/audio/audio_io.h" 14 #include "media/audio/audio_io.h"
15 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
16 #include "media/base/audio_converter.h"
17 16
18 namespace base { 17 namespace base {
19 class MessageLoop; 18 class MessageLoop;
20 } 19 }
21 20
22 namespace media { 21 namespace media {
23 class AudioBus; 22 class AudioBus;
24 } 23 }
25 24
26 namespace audio_modem { 25 namespace audio_modem {
27 26
28 // The AudioRecorder class will record audio until told to stop. 27 // The AudioRecorder class will record audio until told to stop.
29 class AudioRecorderImpl final 28 class AudioRecorderImpl final
30 : public AudioRecorder, 29 : public AudioRecorder,
31 public media::AudioInputStream::AudioInputCallback, 30 public media::AudioInputStream::AudioInputCallback {
32 public media::AudioConverter::InputCallback {
33 public: 31 public:
34 using RecordedSamplesCallback = base::Callback<void(const std::string&)>; 32 using RecordedSamplesCallback = base::Callback<void(const std::string&)>;
35 33
36 AudioRecorderImpl(); 34 AudioRecorderImpl();
37 35
38 // AudioRecorder overrides: 36 // AudioRecorder overrides:
39 void Initialize(const RecordedSamplesCallback& decode_callback) override; 37 void Initialize(const RecordedSamplesCallback& decode_callback) override;
40 void Record() override; 38 void Record() override;
41 void Stop() override; 39 void Stop() override;
42 void Finalize() override; 40 void Finalize() override;
(...skipping 29 matching lines...) Expand all
72 // AudioInputStream::AudioInputCallback overrides: 70 // AudioInputStream::AudioInputCallback overrides:
73 // Called by the audio recorder when a full packet of audio data is 71 // Called by the audio recorder when a full packet of audio data is
74 // available. This is called from a special audio thread and the 72 // available. This is called from a special audio thread and the
75 // implementation should return as soon as possible. 73 // implementation should return as soon as possible.
76 void OnData(media::AudioInputStream* stream, 74 void OnData(media::AudioInputStream* stream,
77 const media::AudioBus* source, 75 const media::AudioBus* source,
78 uint32 hardware_delay_bytes, 76 uint32 hardware_delay_bytes,
79 double volume) override; 77 double volume) override;
80 void OnError(media::AudioInputStream* stream) override; 78 void OnError(media::AudioInputStream* stream) override;
81 79
82 // AudioConverter::InputCallback overrides:
83 double ProvideInput(media::AudioBus* dest,
84 base::TimeDelta buffer_delay) override;
85
86 // Flushes the audio loop, making sure that any queued operations are 80 // Flushes the audio loop, making sure that any queued operations are
87 // performed. 81 // performed.
88 void FlushAudioLoopForTesting(); 82 void FlushAudioLoopForTesting();
89 83
90 bool is_recording_; 84 bool is_recording_;
91 85
92 media::AudioInputStream* stream_; 86 media::AudioInputStream* stream_;
93 87
94 RecordedSamplesCallback decode_callback_; 88 RecordedSamplesCallback decode_callback_;
95 89
96 // ProvideInput will use this buffer as its source.
97 const media::AudioBus* temp_conversion_buffer_;
98
99 // Outside of the ctor/Initialize method, only access the next variables on 90 // Outside of the ctor/Initialize method, only access the next variables on
100 // the recording thread. 91 // the recording thread.
101 scoped_ptr<media::AudioBus> buffer_; 92 scoped_ptr<media::AudioBus> buffer_;
102 int total_buffer_frames_; 93 int total_buffer_frames_;
103 int buffer_frame_index_; 94 int buffer_frame_index_;
104 95
105 scoped_ptr<media::AudioConverter> converter_;
106
107 scoped_ptr<media::AudioInputStream> input_stream_for_testing_; 96 scoped_ptr<media::AudioInputStream> input_stream_for_testing_;
108 scoped_ptr<media::AudioParameters> params_for_testing_; 97 scoped_ptr<media::AudioParameters> params_for_testing_;
109 98
110 DISALLOW_COPY_AND_ASSIGN(AudioRecorderImpl); 99 DISALLOW_COPY_AND_ASSIGN(AudioRecorderImpl);
111 }; 100 };
112 101
113 } // namespace audio_modem 102 } // namespace audio_modem
114 103
115 #endif // COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_ 104 #endif // COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698