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 | 9 |
10 // All the queries and work are handled on the IO thread. | 10 // All the queries and work are handled on the IO thread. |
11 | 11 |
12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
14 | 14 |
15 #include <map> | 15 #include <map> |
16 | 16 |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "content/browser/renderer_host/media/media_stream_provider.h" | 19 #include "content/browser/renderer_host/media/media_stream_provider.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 #include "content/common/media/media_stream_options.h" | 21 #include "content/common/media/media_stream_options.h" |
22 #include "media/audio/audio_device_name.h" | 22 #include "media/audio/audio_device_name.h" |
23 | 23 |
| 24 namespace media { |
24 class AudioManager; | 25 class AudioManager; |
| 26 } |
25 | 27 |
26 namespace media_stream { | 28 namespace media_stream { |
27 | 29 |
28 class AudioInputDeviceManagerEventHandler; | 30 class AudioInputDeviceManagerEventHandler; |
29 | 31 |
30 class CONTENT_EXPORT AudioInputDeviceManager | 32 class CONTENT_EXPORT AudioInputDeviceManager |
31 : public base::RefCountedThreadSafe<AudioInputDeviceManager>, | 33 : public base::RefCountedThreadSafe<AudioInputDeviceManager>, |
32 public MediaStreamProvider { | 34 public MediaStreamProvider { |
33 public: | 35 public: |
34 // Calling Start() with this kFakeOpenSessionId will open the default device, | 36 // Calling Start() with this kFakeOpenSessionId will open the default device, |
35 // even though Open() has not been called. This is used to be able to use the | 37 // even though Open() has not been called. This is used to be able to use the |
36 // AudioInputDeviceManager before MediaStream is implemented. | 38 // AudioInputDeviceManager before MediaStream is implemented. |
37 static const int kFakeOpenSessionId; | 39 static const int kFakeOpenSessionId; |
38 | 40 |
39 static const int kInvalidSessionId; | 41 static const int kInvalidSessionId; |
40 static const char kInvalidDeviceId[]; | 42 static const char kInvalidDeviceId[]; |
41 | 43 |
42 explicit AudioInputDeviceManager(AudioManager* audio_manager); | 44 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); |
43 | 45 |
44 // MediaStreamProvider implementation, called on IO thread. | 46 // MediaStreamProvider implementation, called on IO thread. |
45 virtual void Register(MediaStreamProviderListener* listener) OVERRIDE; | 47 virtual void Register(MediaStreamProviderListener* listener) OVERRIDE; |
46 virtual void Unregister() OVERRIDE; | 48 virtual void Unregister() OVERRIDE; |
47 virtual void EnumerateDevices() OVERRIDE; | 49 virtual void EnumerateDevices() OVERRIDE; |
48 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 50 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
49 virtual void Close(int session_id) OVERRIDE; | 51 virtual void Close(int session_id) OVERRIDE; |
50 | 52 |
51 // Functions used by AudioInputRenderHost, called on IO thread. | 53 // Functions used by AudioInputRenderHost, called on IO thread. |
52 // Start the device referenced by the session id. | 54 // Start the device referenced by the session id. |
(...skipping 12 matching lines...) Expand all Loading... |
65 void ClosedOnIOThread(int session_id); | 67 void ClosedOnIOThread(int session_id); |
66 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); | 68 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); |
67 | 69 |
68 MediaStreamProviderListener* listener_; | 70 MediaStreamProviderListener* listener_; |
69 int next_capture_session_id_; | 71 int next_capture_session_id_; |
70 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; | 72 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; |
71 EventHandlerMap event_handlers_; | 73 EventHandlerMap event_handlers_; |
72 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; | 74 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; |
73 AudioInputDeviceMap devices_; | 75 AudioInputDeviceMap devices_; |
74 // TODO(tommi): Is it necessary to store this as a member? | 76 // TODO(tommi): Is it necessary to store this as a member? |
75 AudioManager* audio_manager_; | 77 media::AudioManager* audio_manager_; |
76 | 78 |
77 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 79 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
78 }; | 80 }; |
79 | 81 |
80 } // namespace media_stream | 82 } // namespace media_stream |
81 | 83 |
82 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 84 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
OLD | NEW |