| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // OnCaptureStopped etc.) and ensure that we can deliver these notifications | 87 // OnCaptureStopped etc.) and ensure that we can deliver these notifications |
| 88 // to any clients using this class. | 88 // to any clients using this class. |
| 89 class CONTENT_EXPORT AudioInputDevice | 89 class CONTENT_EXPORT AudioInputDevice |
| 90 : public AudioInputMessageFilter::Delegate, | 90 : public AudioInputMessageFilter::Delegate, |
| 91 NON_EXPORTED_BASE(public ScopedLoopObserver), | 91 NON_EXPORTED_BASE(public ScopedLoopObserver), |
| 92 public base::RefCountedThreadSafe<AudioInputDevice> { | 92 public base::RefCountedThreadSafe<AudioInputDevice> { |
| 93 public: | 93 public: |
| 94 class CONTENT_EXPORT CaptureCallback { | 94 class CONTENT_EXPORT CaptureCallback { |
| 95 public: | 95 public: |
| 96 virtual void Capture(const std::vector<float*>& audio_data, | 96 virtual void Capture(const std::vector<float*>& audio_data, |
| 97 size_t number_of_frames, | 97 int number_of_frames, |
| 98 size_t audio_delay_milliseconds) = 0; | 98 int audio_delay_milliseconds) = 0; |
| 99 virtual void OnCaptureError() = 0; | 99 virtual void OnCaptureError() = 0; |
| 100 protected: | 100 protected: |
| 101 virtual ~CaptureCallback() {} | 101 virtual ~CaptureCallback() {} |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 class CONTENT_EXPORT CaptureEventHandler { | 104 class CONTENT_EXPORT CaptureEventHandler { |
| 105 public: | 105 public: |
| 106 // Notification to the client that the device with the specific |device_id| | 106 // Notification to the client that the device with the specific |device_id| |
| 107 // has been started. | 107 // has been started. |
| 108 // This callback is triggered as a result of StartDevice(). | 108 // This callback is triggered as a result of StartDevice(). |
| (...skipping 30 matching lines...) Expand all Loading... |
| 139 bool SetVolume(double volume); | 139 bool SetVolume(double volume); |
| 140 | 140 |
| 141 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. | 141 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. |
| 142 // Returns |true| on success. | 142 // Returns |true| on success. |
| 143 bool GetVolume(double* volume); | 143 bool GetVolume(double* volume); |
| 144 | 144 |
| 145 double sample_rate() const { | 145 double sample_rate() const { |
| 146 return audio_parameters_.sample_rate(); | 146 return audio_parameters_.sample_rate(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 size_t buffer_size() const { | 149 int buffer_size() const { |
| 150 return audio_parameters_.frames_per_buffer(); | 150 return audio_parameters_.frames_per_buffer(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Methods called on IO thread ---------------------------------------------- | 153 // Methods called on IO thread ---------------------------------------------- |
| 154 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter | 154 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter |
| 155 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 155 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 156 base::SyncSocket::Handle socket_handle, | 156 base::SyncSocket::Handle socket_handle, |
| 157 uint32 length) OVERRIDE; | 157 uint32 length) OVERRIDE; |
| 158 virtual void OnVolume(double volume) OVERRIDE; | 158 virtual void OnVolume(double volume) OVERRIDE; |
| 159 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | 159 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // In order to avoid a race between OnStreamCreated and Stop(), we use this | 205 // In order to avoid a race between OnStreamCreated and Stop(), we use this |
| 206 // guard to control stopping and starting the audio thread. | 206 // guard to control stopping and starting the audio thread. |
| 207 base::Lock audio_thread_lock_; | 207 base::Lock audio_thread_lock_; |
| 208 AudioDeviceThread audio_thread_; | 208 AudioDeviceThread audio_thread_; |
| 209 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; | 209 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; |
| 210 | 210 |
| 211 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 211 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 214 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
| OLD | NEW |