| 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 // AudioInputDeviceManager manages the audio input devices. In particular it | 5 // AudioInputDeviceManager manages the audio input devices. In particular it |
| 6 // communicates with MediaStreamManager and AudioInputRendererHost on the | 6 // communicates with MediaStreamManager and AudioInputRendererHost on the |
| 7 // browser IO thread, handles queries like | 7 // browser IO thread, handles queries like |
| 8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and | 8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and |
| 9 // GetOpenedDeviceInfoById from AudioInputRendererHost. | 9 // GetOpenedDeviceInfoById from AudioInputRendererHost. |
| 10 // The work for enumerate/open/close is handled asynchronously on Media Stream | 10 // The work for enumerate/open/close is handled asynchronously on Media Stream |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // TODO(xians): Remove it when the webrtc unittest does not need it any more. | 38 // TODO(xians): Remove it when the webrtc unittest does not need it any more. |
| 39 static const int kFakeOpenSessionId; | 39 static const int kFakeOpenSessionId; |
| 40 | 40 |
| 41 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); | 41 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); |
| 42 | 42 |
| 43 // Gets the opened device info by |session_id|. Returns NULL if the device | 43 // Gets the opened device info by |session_id|. Returns NULL if the device |
| 44 // is not opened, otherwise the opened device. Called on IO thread. | 44 // is not opened, otherwise the opened device. Called on IO thread. |
| 45 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id); | 45 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id); |
| 46 | 46 |
| 47 // MediaStreamProvider implementation, called on IO thread. | 47 // MediaStreamProvider implementation, called on IO thread. |
| 48 virtual void Register(MediaStreamProviderListener* listener, | 48 void Register(MediaStreamProviderListener* listener, |
| 49 const scoped_refptr<base::SingleThreadTaskRunner>& | 49 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 50 device_task_runner) override; | 50 device_task_runner) override; |
| 51 virtual void Unregister() override; | 51 void Unregister() override; |
| 52 virtual void EnumerateDevices(MediaStreamType stream_type) override; | 52 void EnumerateDevices(MediaStreamType stream_type) override; |
| 53 virtual int Open(const StreamDeviceInfo& device) override; | 53 int Open(const StreamDeviceInfo& device) override; |
| 54 virtual void Close(int session_id) override; | 54 void Close(int session_id) override; |
| 55 | 55 |
| 56 void UseFakeDevice(); | 56 void UseFakeDevice(); |
| 57 bool ShouldUseFakeDevice() const; | 57 bool ShouldUseFakeDevice() const; |
| 58 | 58 |
| 59 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 60 // Registers and unregisters that a stream using keyboard mic has been opened | 60 // Registers and unregisters that a stream using keyboard mic has been opened |
| 61 // or closed. Keeps count of how many such streams are open and activates and | 61 // or closed. Keeps count of how many such streams are open and activates and |
| 62 // inactivates the keyboard mic accordingly. The (in)activation is done on the | 62 // inactivates the keyboard mic accordingly. The (in)activation is done on the |
| 63 // UI thread and for the register case a callback must therefor be provided | 63 // UI thread and for the register case a callback must therefor be provided |
| 64 // which is called when activated. | 64 // which is called when activated. |
| 65 // Called on the IO thread. | 65 // Called on the IO thread. |
| 66 void RegisterKeyboardMicStream(const base::Closure& callback); | 66 void RegisterKeyboardMicStream(const base::Closure& callback); |
| 67 void UnregisterKeyboardMicStream(); | 67 void UnregisterKeyboardMicStream(); |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // Used by the unittests to get a list of fake devices. | 71 // Used by the unittests to get a list of fake devices. |
| 72 friend class MediaStreamDispatcherHostTest; | 72 friend class MediaStreamDispatcherHostTest; |
| 73 void GetFakeDeviceNames(media::AudioDeviceNames* device_names); | 73 void GetFakeDeviceNames(media::AudioDeviceNames* device_names); |
| 74 | 74 |
| 75 typedef std::vector<StreamDeviceInfo> StreamDeviceList; | 75 typedef std::vector<StreamDeviceInfo> StreamDeviceList; |
| 76 virtual ~AudioInputDeviceManager(); | 76 ~AudioInputDeviceManager() override; |
| 77 | 77 |
| 78 // Enumerates audio input devices on media stream device thread. | 78 // Enumerates audio input devices on media stream device thread. |
| 79 void EnumerateOnDeviceThread(MediaStreamType stream_type); | 79 void EnumerateOnDeviceThread(MediaStreamType stream_type); |
| 80 // Opens the device on media stream device thread. | 80 // Opens the device on media stream device thread. |
| 81 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); | 81 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); |
| 82 | 82 |
| 83 // Callback used by EnumerateOnDeviceThread(), called with a list of | 83 // Callback used by EnumerateOnDeviceThread(), called with a list of |
| 84 // enumerated devices on IO thread. | 84 // enumerated devices on IO thread. |
| 85 void DevicesEnumeratedOnIOThread(MediaStreamType stream_type, | 85 void DevicesEnumeratedOnIOThread(MediaStreamType stream_type, |
| 86 scoped_ptr<StreamDeviceInfoArray> devices); | 86 scoped_ptr<StreamDeviceInfoArray> devices); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 // The message loop of media stream device thread that this object runs on. | 119 // The message loop of media stream device thread that this object runs on. |
| 120 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 121 | 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 122 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace content | 125 } // namespace content |
| 126 | 126 |
| 127 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 127 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| OLD | NEW |