OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 public: | 92 public: |
93 virtual void Capture(const std::vector<float*>& audio_data, | 93 virtual void Capture(const std::vector<float*>& audio_data, |
94 size_t number_of_frames, | 94 size_t number_of_frames, |
95 size_t audio_delay_milliseconds) = 0; | 95 size_t audio_delay_milliseconds) = 0; |
96 protected: | 96 protected: |
97 virtual ~CaptureCallback() {} | 97 virtual ~CaptureCallback() {} |
98 }; | 98 }; |
99 | 99 |
100 class CaptureEventHandler { | 100 class CaptureEventHandler { |
101 public: | 101 public: |
102 // Notification to the client that the device with the specific index has | 102 // Notification to the client that the device with the specific |index_id| |
103 // been started. This callback is triggered as a result of StartDevice(). | 103 // has been started. |
104 virtual void OnDeviceStarted(int device_index) = 0; | 104 // This callback is triggered as a result of StartDevice(). |
105 virtual void OnDeviceStarted(const std::string& device_uid) = 0; | |
105 | 106 |
106 // Notification to the client that the device has been stopped. | 107 // Notification to the client that the device has been stopped. |
107 virtual void OnDeviceStopped() = 0; | 108 virtual void OnDeviceStopped() = 0; |
108 | 109 |
109 protected: | 110 protected: |
110 virtual ~CaptureEventHandler() {} | 111 virtual ~CaptureEventHandler() {} |
111 }; | 112 }; |
112 | 113 |
113 // Methods called on main render thread ------------------------------------- | 114 // Methods called on main render thread ------------------------------------- |
114 AudioInputDevice(size_t buffer_size, | 115 AudioInputDevice(size_t buffer_size, |
(...skipping 28 matching lines...) Expand all Loading... | |
143 double sample_rate() const { return audio_parameters_.sample_rate; } | 144 double sample_rate() const { return audio_parameters_.sample_rate; } |
144 size_t buffer_size() const { return audio_parameters_.samples_per_packet; } | 145 size_t buffer_size() const { return audio_parameters_.samples_per_packet; } |
145 | 146 |
146 // Methods called on IO thread ---------------------------------------------- | 147 // Methods called on IO thread ---------------------------------------------- |
147 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter | 148 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter |
148 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 149 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
149 base::SyncSocket::Handle socket_handle, | 150 base::SyncSocket::Handle socket_handle, |
150 uint32 length); | 151 uint32 length); |
151 virtual void OnVolume(double volume); | 152 virtual void OnVolume(double volume); |
152 virtual void OnStateChanged(AudioStreamState state); | 153 virtual void OnStateChanged(AudioStreamState state); |
153 virtual void OnDeviceReady(int index); | 154 virtual void OnDeviceReady(const std::string& device_uid); |
tommi (sloooow) - chröme
2011/11/15 10:29:07
also change foo_uid to foo_id. ID is what we use
no longer working on chromium
2011/11/16 17:47:21
Done.
| |
154 | 155 |
155 private: | 156 private: |
156 // Methods called on IO thread ---------------------------------------------- | 157 // Methods called on IO thread ---------------------------------------------- |
157 // The following methods are tasks posted on the IO thread that needs to | 158 // The following methods are tasks posted on the IO thread that needs to |
158 // be executed on that thread. They interact with AudioInputMessageFilter and | 159 // be executed on that thread. They interact with AudioInputMessageFilter and |
159 // sends IPC messages on that thread. | 160 // sends IPC messages on that thread. |
160 void InitializeOnIOThread(); | 161 void InitializeOnIOThread(); |
161 void SetSessionIdOnIOThread(int session_id); | 162 void SetSessionIdOnIOThread(int session_id); |
162 void StartOnIOThread(); | 163 void StartOnIOThread(); |
163 void ShutDownOnIOThread(base::WaitableEvent* completion); | 164 void ShutDownOnIOThread(base::WaitableEvent* completion); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 // callback. Only modified on the IO thread. | 212 // callback. Only modified on the IO thread. |
212 bool pending_device_ready_; | 213 bool pending_device_ready_; |
213 | 214 |
214 scoped_ptr<base::SharedMemory> shared_memory_; | 215 scoped_ptr<base::SharedMemory> shared_memory_; |
215 scoped_ptr<base::SyncSocket> socket_; | 216 scoped_ptr<base::SyncSocket> socket_; |
216 | 217 |
217 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 218 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
218 }; | 219 }; |
219 | 220 |
220 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 221 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
OLD | NEW |