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

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

Issue 2131993002: Delete the audio modem and copresence private APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eol
Patch Set: Sync again Created 4 years, 5 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 | « components/audio_modem/audio_recorder.h ('k') | components/audio_modem/audio_recorder_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
6 #define COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <string>
12
13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h"
15 #include "components/audio_modem/audio_recorder.h"
16 #include "media/audio/audio_io.h"
17 #include "media/base/audio_parameters.h"
18
19 namespace base {
20 class MessageLoop;
21 }
22
23 namespace media {
24 class AudioBus;
25 }
26
27 namespace audio_modem {
28
29 // The AudioRecorder class will record audio until told to stop.
30 class AudioRecorderImpl final
31 : public AudioRecorder,
32 public media::AudioInputStream::AudioInputCallback {
33 public:
34 using RecordedSamplesCallback = base::Callback<void(const std::string&)>;
35
36 AudioRecorderImpl();
37
38 // AudioRecorder overrides:
39 void Initialize(const RecordedSamplesCallback& decode_callback) override;
40 void Record() override;
41 void Stop() override;
42 void Finalize() override;
43
44 // Takes ownership of the stream.
45 void set_input_stream_for_testing(
46 media::AudioInputStream* input_stream_for_testing) {
47 input_stream_for_testing_.reset(input_stream_for_testing);
48 }
49
50 // Takes ownership of the params.
51 void set_params_for_testing(media::AudioParameters* params_for_testing) {
52 params_for_testing_.reset(params_for_testing);
53 }
54
55 protected:
56 ~AudioRecorderImpl() override;
57 void set_is_recording(bool is_recording) { is_recording_ = is_recording; }
58
59 private:
60 friend class AudioRecorderTest;
61 FRIEND_TEST_ALL_PREFIXES(AudioRecorderTest, BasicRecordAndStop);
62 FRIEND_TEST_ALL_PREFIXES(AudioRecorderTest, OutOfOrderRecordAndStopMultiple);
63
64 // Methods to do our various operations; all of these need to be run on the
65 // audio thread.
66 void InitializeOnAudioThread();
67 void RecordOnAudioThread();
68 void StopOnAudioThread();
69 void StopAndCloseOnAudioThread();
70 void FinalizeOnAudioThread();
71
72 // AudioInputStream::AudioInputCallback overrides:
73 // 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
75 // implementation should return as soon as possible.
76 void OnData(media::AudioInputStream* stream,
77 const media::AudioBus* source,
78 uint32_t hardware_delay_bytes,
79 double volume) override;
80 void OnError(media::AudioInputStream* stream) override;
81
82 bool is_recording_;
83
84 media::AudioInputStream* stream_;
85
86 RecordedSamplesCallback decode_callback_;
87
88 // Outside of the ctor/Initialize method, only access the next variables on
89 // the recording thread.
90 std::unique_ptr<media::AudioBus> buffer_;
91 int total_buffer_frames_;
92 int buffer_frame_index_;
93
94 std::unique_ptr<media::AudioInputStream> input_stream_for_testing_;
95 std::unique_ptr<media::AudioParameters> params_for_testing_;
96
97 DISALLOW_COPY_AND_ASSIGN(AudioRecorderImpl);
98 };
99
100 } // namespace audio_modem
101
102 #endif // COMPONENTS_AUDIO_MODEM_AUDIO_RECORDER_IMPL_H_
OLDNEW
« no previous file with comments | « components/audio_modem/audio_recorder.h ('k') | components/audio_modem/audio_recorder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698