| 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" |
| 25 | 26 |
| 26 namespace media { | 27 namespace media { |
| 27 class AudioManager; | 28 class AudioManager; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 33 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { |
| 33 public: | 34 public: |
| 34 // Calling Start() with this kFakeOpenSessionId will open the default device, | 35 // Calling Start() with this kFakeOpenSessionId will open the default device, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 device_task_runner) OVERRIDE; | 50 device_task_runner) OVERRIDE; |
| 50 virtual void Unregister() OVERRIDE; | 51 virtual void Unregister() OVERRIDE; |
| 51 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; | 52 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; |
| 52 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 53 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
| 53 virtual void Close(int session_id) OVERRIDE; | 54 virtual void Close(int session_id) OVERRIDE; |
| 54 | 55 |
| 55 void UseFakeDevice(); | 56 void UseFakeDevice(); |
| 56 bool ShouldUseFakeDevice() const; | 57 bool ShouldUseFakeDevice() const; |
| 57 | 58 |
| 58 private: | 59 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 |
| 59 typedef std::vector<StreamDeviceInfo> StreamDeviceList; | 64 typedef std::vector<StreamDeviceInfo> StreamDeviceList; |
| 60 virtual ~AudioInputDeviceManager(); | 65 virtual ~AudioInputDeviceManager(); |
| 61 | 66 |
| 62 // Enumerates audio input devices on media stream device thread. | 67 // Enumerates audio input devices on media stream device thread. |
| 63 void EnumerateOnDeviceThread(MediaStreamType stream_type); | 68 void EnumerateOnDeviceThread(MediaStreamType stream_type); |
| 64 // Opens the device on media stream device thread. | 69 // Opens the device on media stream device thread. |
| 65 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); | 70 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); |
| 66 | 71 |
| 67 // Callback used by EnumerateOnDeviceThread(), called with a list of | 72 // Callback used by EnumerateOnDeviceThread(), called with a list of |
| 68 // enumerated devices on IO thread. | 73 // enumerated devices on IO thread. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 | 97 |
| 93 // The message loop of media stream device thread that this object runs on. | 98 // The message loop of media stream device thread that this object runs on. |
| 94 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | 99 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 95 | 100 |
| 96 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 101 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
| 97 }; | 102 }; |
| 98 | 103 |
| 99 } // namespace content | 104 } // namespace content |
| 100 | 105 |
| 101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 106 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| OLD | NEW |