Chromium Code Reviews| 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 enumerate/open/close from | 7 // browser IO thread, handles queries like enumerate/open/close from |
| 8 // MediaStreamManager and start/stop from AudioInputRendererHost. | 8 // MediaStreamManager and start/stop from AudioInputRendererHost. |
| 9 // The work for enumerate/open/close is handled asynchronously on Media Stream | 9 // The work for enumerate/open/close is handled asynchronously on Media Stream |
| 10 // device thread, while start/stop are synchronous on the IO thread. | 10 // device thread, while start/stop are synchronous on the IO thread. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "media/audio/audio_device_name.h" | 22 #include "media/audio/audio_device_name.h" |
| 23 | 23 |
| 24 namespace media { | 24 namespace media { |
| 25 class AudioManager; | 25 class AudioManager; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace media_stream { | 28 namespace media_stream { |
| 29 | 29 |
| 30 class AudioInputDeviceManagerEventHandler; | 30 class AudioInputDeviceManagerEventHandler; |
| 31 | 31 |
| 32 class CONTENT_EXPORT AudioInputDeviceManager | 32 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { |
| 33 : public base::RefCountedThreadSafe<AudioInputDeviceManager>, | |
| 34 public MediaStreamProvider { | |
| 35 public: | 33 public: |
| 36 // Calling Start() with this kFakeOpenSessionId will open the default device, | 34 // Calling Start() with this kFakeOpenSessionId will open the default device, |
| 37 // even though Open() has not been called. This is used to be able to use the | 35 // even though Open() has not been called. This is used to be able to use the |
| 38 // AudioInputDeviceManager before MediaStream is implemented. | 36 // AudioInputDeviceManager before MediaStream is implemented. |
| 39 static const int kFakeOpenSessionId; | 37 static const int kFakeOpenSessionId; |
| 40 | 38 |
| 41 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); | 39 AudioInputDeviceManager(media::AudioManager* audio_manager, |
| 40 media_stream::MediaStreamType device_type); | |
| 42 | 41 |
| 43 // MediaStreamProvider implementation, called on IO thread. | 42 // MediaStreamProvider implementation, called on IO thread. |
| 44 virtual void Register(MediaStreamProviderListener* listener, | 43 virtual void Register(MediaStreamProviderListener* listener, |
| 45 base::MessageLoopProxy* device_thread_loop) OVERRIDE; | 44 base::MessageLoopProxy* device_thread_loop) OVERRIDE; |
| 46 virtual void Unregister() OVERRIDE; | 45 virtual void Unregister() OVERRIDE; |
| 47 virtual void EnumerateDevices() OVERRIDE; | 46 virtual void EnumerateDevices() OVERRIDE; |
| 48 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 47 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
| 49 virtual void Close(int session_id) OVERRIDE; | 48 virtual void Close(int session_id) OVERRIDE; |
| 50 | 49 |
| 51 // Functions used by AudioInputRenderHost, called on IO thread. | 50 // Functions used by AudioInputRenderHost, called on IO thread. |
| 52 // Start the device referenced by the session id. | 51 // Start the device referenced by the session id. |
| 53 void Start(int session_id, | 52 void Start(int session_id, |
| 54 AudioInputDeviceManagerEventHandler* event_handler); | 53 AudioInputDeviceManagerEventHandler* event_handler); |
| 55 // Stop the device referenced by the session id. | 54 // Stop the device referenced by the session id. |
| 56 void Stop(int session_id); | 55 void Stop(int session_id); |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 friend class base::RefCountedThreadSafe<AudioInputDeviceManager>; | |
| 60 virtual ~AudioInputDeviceManager(); | 58 virtual ~AudioInputDeviceManager(); |
| 61 | 59 |
| 62 // Executed on media stream device thread. | 60 // Executed on media stream device thread. |
| 63 void EnumerateOnDeviceThread(); | 61 void EnumerateOnDeviceThread(); |
| 64 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device); | 62 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device); |
| 65 void CloseOnDeviceThread(int session_id); | 63 void CloseOnDeviceThread(int session_id); |
| 66 | 64 |
| 67 // Executed on IO thread to call Listener. | 65 // Executed on IO thread to call Listener. |
| 68 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); | 66 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); |
| 69 void OpenedOnIOThread(int session_id); | 67 void OpenedOnIOThread(int session_id); |
| 70 void ClosedOnIOThread(int session_id); | 68 void ClosedOnIOThread(int session_id); |
| 71 | 69 |
| 72 bool IsOnDeviceThread() const; | 70 bool IsOnDeviceThread() const; |
| 73 | 71 |
| 72 // The type of audio input devices managed by this instance (e.g., user | |
| 73 // audio capture, tab audio output). | |
| 74 const media_stream::MediaStreamType device_type_; | |
|
no longer working on chromium
2012/08/31 13:38:23
what about putting this member below audio_manager
miu
2012/09/01 01:32:00
Done.
| |
| 75 | |
| 74 // Only accessed on Browser::IO thread. | 76 // Only accessed on Browser::IO thread. |
| 75 MediaStreamProviderListener* listener_; | 77 MediaStreamProviderListener* listener_; |
| 76 int next_capture_session_id_; | 78 int next_capture_session_id_; |
| 77 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; | 79 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; |
| 78 EventHandlerMap event_handlers_; | 80 EventHandlerMap event_handlers_; |
| 79 | 81 |
| 80 // Only accessed from media stream device thread. | 82 // Only accessed from media stream device thread. |
| 81 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; | 83 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; |
| 82 AudioInputDeviceMap devices_; | 84 AudioInputDeviceMap devices_; |
| 83 media::AudioManager* audio_manager_; | 85 media::AudioManager* audio_manager_; |
| 84 | 86 |
| 85 // The message loop of media stream device thread that this object runs on. | 87 // The message loop of media stream device thread that this object runs on. |
| 86 scoped_refptr<base::MessageLoopProxy> device_loop_; | 88 scoped_refptr<base::MessageLoopProxy> device_loop_; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 90 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace media_stream | 93 } // namespace media_stream |
| 92 | 94 |
| 93 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 95 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| OLD | NEW |