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 // Low-latency audio capturing unit utilizing audio input stream provided | 5 // Low-latency audio capturing unit utilizing audio input stream provided |
6 // by browser process through IPC. | 6 // by browser process through IPC. |
7 // | 7 // |
8 // Relationship of classes: | 8 // Relationship of classes: |
9 // | 9 // |
10 // AudioInputController AudioInputDevice | 10 // AudioInputController AudioInputDevice |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // OnCaptureStopped etc.) and ensure that we can deliver these notifications | 88 // OnCaptureStopped etc.) and ensure that we can deliver these notifications |
89 // to any clients using this class. | 89 // to any clients using this class. |
90 class CONTENT_EXPORT AudioInputDevice | 90 class CONTENT_EXPORT AudioInputDevice |
91 : public AudioInputMessageFilter::Delegate, | 91 : public AudioInputMessageFilter::Delegate, |
92 NON_EXPORTED_BASE(public ScopedLoopObserver), | 92 NON_EXPORTED_BASE(public ScopedLoopObserver), |
93 public base::RefCountedThreadSafe<AudioInputDevice> { | 93 public base::RefCountedThreadSafe<AudioInputDevice> { |
94 public: | 94 public: |
95 class CONTENT_EXPORT CaptureCallback { | 95 class CONTENT_EXPORT CaptureCallback { |
96 public: | 96 public: |
97 virtual void Capture(const std::vector<float*>& audio_data, | 97 virtual void Capture(const std::vector<float*>& audio_data, |
98 size_t number_of_frames, | 98 int number_of_frames, |
99 size_t audio_delay_milliseconds, | 99 int audio_delay_milliseconds, |
100 double volume) = 0; | 100 double volume) = 0; |
101 virtual void OnCaptureError() = 0; | 101 virtual void OnCaptureError() = 0; |
102 protected: | 102 protected: |
103 virtual ~CaptureCallback() {} | 103 virtual ~CaptureCallback() {} |
104 }; | 104 }; |
105 | 105 |
106 class CONTENT_EXPORT CaptureEventHandler { | 106 class CONTENT_EXPORT CaptureEventHandler { |
107 public: | 107 public: |
108 // Notification to the client that the device with the specific |device_id| | 108 // Notification to the client that the device with the specific |device_id| |
109 // has been started. | 109 // has been started. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bool SetVolume(double volume); | 141 bool SetVolume(double volume); |
142 | 142 |
143 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. | 143 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. |
144 // Returns |true| on success. | 144 // Returns |true| on success. |
145 bool GetVolume(double* volume); | 145 bool GetVolume(double* volume); |
146 | 146 |
147 double sample_rate() const { | 147 double sample_rate() const { |
148 return audio_parameters_.sample_rate(); | 148 return audio_parameters_.sample_rate(); |
149 } | 149 } |
150 | 150 |
151 size_t buffer_size() const { | 151 int buffer_size() const { |
152 return audio_parameters_.frames_per_buffer(); | 152 return audio_parameters_.frames_per_buffer(); |
153 } | 153 } |
154 | 154 |
155 // Sets the Automatic Gain Control state to on or off. | 155 // Sets the Automatic Gain Control state to on or off. |
156 // This method must be called before Start(). It will not have any effect | 156 // This method must be called before Start(). It will not have any effect |
157 // if it is called while capturing has already started. | 157 // if it is called while capturing has already started. |
158 void SetAutomaticGainControl(bool enabled); | 158 void SetAutomaticGainControl(bool enabled); |
159 | 159 |
160 // Methods called on IO thread ---------------------------------------------- | 160 // Methods called on IO thread ---------------------------------------------- |
161 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter. | 161 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // In order to avoid a race between OnStreamCreated and Stop(), we use this | 217 // In order to avoid a race between OnStreamCreated and Stop(), we use this |
218 // guard to control stopping and starting the audio thread. | 218 // guard to control stopping and starting the audio thread. |
219 base::Lock audio_thread_lock_; | 219 base::Lock audio_thread_lock_; |
220 AudioDeviceThread audio_thread_; | 220 AudioDeviceThread audio_thread_; |
221 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; | 221 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; |
222 | 222 |
223 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 223 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
224 }; | 224 }; |
225 | 225 |
226 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 226 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
OLD | NEW |