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

Side by Side Diff: components/copresence/mediums/audio/audio_recorder.h

Issue 637223011: Redesign the copresence audio handlers. (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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_H_ 5 #ifndef COMPONENTS_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_H_
6 #define COMPONENTS_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_H_ 6 #define COMPONENTS_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_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"
(...skipping 10 matching lines...) Expand all
21 namespace media { 21 namespace media {
22 class AudioBus; 22 class AudioBus;
23 } 23 }
24 24
25 namespace copresence { 25 namespace copresence {
26 26
27 // The AudioRecorder class will record audio until told to stop. 27 // The AudioRecorder class will record audio until told to stop.
28 class AudioRecorder : public media::AudioInputStream::AudioInputCallback, 28 class AudioRecorder : public media::AudioInputStream::AudioInputCallback,
29 public media::AudioConverter::InputCallback { 29 public media::AudioConverter::InputCallback {
30 public: 30 public:
31 typedef base::Callback<void(const std::string&)> DecodeSamplesCallback; 31 typedef base::Callback<void(const std::string&)> RecordedSamplesCallback;
32 32
33 explicit AudioRecorder(const DecodeSamplesCallback& decode_callback); 33 AudioRecorder();
34 34
35 // Initializes the object. Do not use this object before calling this method. 35 // Initializes the object. Do not use this object before calling this method.
36 virtual void Initialize(); 36 virtual void Initialize(const RecordedSamplesCallback& decode_callback);
37 37
38 virtual void Record(); 38 virtual void Record();
39 virtual void Stop(); 39 virtual void Stop();
40 40
41 // Cleans up and deletes this object. Do not use object after this call. 41 // Cleans up and deletes this object. Do not use object after this call.
42 virtual void Finalize(); 42 virtual void Finalize();
43 43
44 bool IsRecording(); 44 bool IsRecording();
45 45
46 // Takes ownership of the stream. 46 // Takes ownership of the stream.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 virtual double ProvideInput(media::AudioBus* dest, 85 virtual double ProvideInput(media::AudioBus* dest,
86 base::TimeDelta buffer_delay) override; 86 base::TimeDelta buffer_delay) override;
87 87
88 // Flushes the audio loop, making sure that any queued operations are 88 // Flushes the audio loop, making sure that any queued operations are
89 // performed. 89 // performed.
90 void FlushAudioLoopForTesting(); 90 void FlushAudioLoopForTesting();
91 91
92 bool is_recording_; 92 bool is_recording_;
93 93
94 media::AudioInputStream* stream_; 94 media::AudioInputStream* stream_;
95 DecodeSamplesCallback decode_callback_; 95
96 RecordedSamplesCallback decode_callback_;
96 97
97 // ProvideInput will use this buffer as its source. 98 // ProvideInput will use this buffer as its source.
98 const media::AudioBus* temp_conversion_buffer_; 99 const media::AudioBus* temp_conversion_buffer_;
99 100
100 // Outside of the ctor/Initialize method, only access the next variables on 101 // Outside of the ctor/Initialize method, only access the next variables on
101 // the recording thread. 102 // the recording thread.
102 scoped_ptr<media::AudioBus> buffer_; 103 scoped_ptr<media::AudioBus> buffer_;
103 int total_buffer_frames_; 104 int total_buffer_frames_;
104 int buffer_frame_index_; 105 int buffer_frame_index_;
105 106
106 scoped_ptr<media::AudioConverter> converter_; 107 scoped_ptr<media::AudioConverter> converter_;
107 108
108 scoped_ptr<media::AudioInputStream> input_stream_for_testing_; 109 scoped_ptr<media::AudioInputStream> input_stream_for_testing_;
109 scoped_ptr<media::AudioParameters> params_for_testing_; 110 scoped_ptr<media::AudioParameters> params_for_testing_;
110 111
111 DISALLOW_COPY_AND_ASSIGN(AudioRecorder); 112 DISALLOW_COPY_AND_ASSIGN(AudioRecorder);
112 }; 113 };
113 114
114 } // namespace copresence 115 } // namespace copresence
115 116
116 #endif // COMPONENTS_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_H_ 117 #endif // COMPONENTS_COPRESENCE_MEDIUMS_AUDIO_AUDIO_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698