| 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 |
| 11 // device thread, while GetOpenedDeviceInfoById is synchronous on the IO thread. | 11 // device thread, while GetOpenedDeviceInfoById is synchronous on the IO thread. |
| 12 | 12 |
| 13 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 13 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| 14 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 14 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
| 21 #include "content/browser/renderer_host/media/media_stream_provider.h" | 21 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/common/media/media_stream_options.h" | 23 #include "content/common/media/media_stream_options.h" |
| 24 #include "content/public/common/media_stream_request.h" | 24 #include "content/public/common/media_stream_request.h" |
| 25 #include "media/audio/audio_device_name.h" | |
| 26 | 25 |
| 27 namespace media { | 26 namespace media { |
| 28 class AudioManager; | 27 class AudioManager; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace content { | 30 namespace content { |
| 32 | 31 |
| 33 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 32 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { |
| 34 public: | 33 public: |
| 35 // Calling Start() with this kFakeOpenSessionId will open the default device, | 34 // Calling Start() with this kFakeOpenSessionId will open the default device, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 device_task_runner) OVERRIDE; | 49 device_task_runner) OVERRIDE; |
| 51 virtual void Unregister() OVERRIDE; | 50 virtual void Unregister() OVERRIDE; |
| 52 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; | 51 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; |
| 53 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 52 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
| 54 virtual void Close(int session_id) OVERRIDE; | 53 virtual void Close(int session_id) OVERRIDE; |
| 55 | 54 |
| 56 void UseFakeDevice(); | 55 void UseFakeDevice(); |
| 57 bool ShouldUseFakeDevice() const; | 56 bool ShouldUseFakeDevice() const; |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 // Used by the unittests to get a list of fake devices. | |
| 61 friend class MediaStreamDispatcherHostTest; | |
| 62 void GetFakeDeviceNames(media::AudioDeviceNames* device_names); | |
| 63 | |
| 64 typedef std::vector<StreamDeviceInfo> StreamDeviceList; | 59 typedef std::vector<StreamDeviceInfo> StreamDeviceList; |
| 65 virtual ~AudioInputDeviceManager(); | 60 virtual ~AudioInputDeviceManager(); |
| 66 | 61 |
| 67 // Enumerates audio input devices on media stream device thread. | 62 // Enumerates audio input devices on media stream device thread. |
| 68 void EnumerateOnDeviceThread(MediaStreamType stream_type); | 63 void EnumerateOnDeviceThread(MediaStreamType stream_type); |
| 69 // Opens the device on media stream device thread. | 64 // Opens the device on media stream device thread. |
| 70 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); | 65 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); |
| 71 | 66 |
| 72 // Callback used by EnumerateOnDeviceThread(), called with a list of | 67 // Callback used by EnumerateOnDeviceThread(), called with a list of |
| 73 // enumerated devices on IO thread. | 68 // enumerated devices on IO thread. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 97 | 92 |
| 98 // The message loop of media stream device thread that this object runs on. | 93 // The message loop of media stream device thread that this object runs on. |
| 99 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | 94 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 100 | 95 |
| 101 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 96 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
| 102 }; | 97 }; |
| 103 | 98 |
| 104 } // namespace content | 99 } // namespace content |
| 105 | 100 |
| 106 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| OLD | NEW |