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. |
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/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "content/browser/renderer_host/media/media_stream_provider.h" | 20 #include "content/browser/renderer_host/media/media_stream_provider.h" |
21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
22 #include "content/common/media/media_stream_options.h" | 22 #include "content/common/media/media_stream_options.h" |
23 #include "content/public/common/media_stream_request.h" | 23 #include "content/public/common/media_stream_request.h" |
24 | 24 |
25 namespace media { | 25 namespace media { |
26 class AudioManager; | 26 class AudioManager; |
27 } | 27 } |
28 | 28 |
29 namespace media_stream { | 29 namespace content { |
30 | 30 |
31 class AudioInputDeviceManagerEventHandler; | 31 class AudioInputDeviceManagerEventHandler; |
32 | 32 |
33 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 33 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { |
34 public: | 34 public: |
35 // Calling Start() with this kFakeOpenSessionId will open the default device, | 35 // Calling Start() with this kFakeOpenSessionId will open the default device, |
36 // even though Open() has not been called. This is used to be able to use the | 36 // even though Open() has not been called. This is used to be able to use the |
37 // AudioInputDeviceManager before MediaStream is implemented. | 37 // AudioInputDeviceManager before MediaStream is implemented. |
38 static const int kFakeOpenSessionId; | 38 static const int kFakeOpenSessionId; |
39 | 39 |
(...skipping 23 matching lines...) Expand all Loading... |
63 // Opens the device on media stream device thread. | 63 // Opens the device on media stream device thread. |
64 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device); | 64 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device); |
65 // Closes the deivce on the media stream device thread. | 65 // Closes the deivce on the media stream device thread. |
66 void CloseOnDeviceThread(int session_id); | 66 void CloseOnDeviceThread(int session_id); |
67 | 67 |
68 // Callback used by EnumerateOnDeviceThread(), called with a list of | 68 // Callback used by EnumerateOnDeviceThread(), called with a list of |
69 // enumerated devices on IO thread. | 69 // enumerated devices on IO thread. |
70 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); | 70 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); |
71 // Callback used by OpenOnDeviceThread(), called with the session_id | 71 // Callback used by OpenOnDeviceThread(), called with the session_id |
72 // referencing the opened device on IO thread. | 72 // referencing the opened device on IO thread. |
73 void OpenedOnIOThread(content::MediaStreamDeviceType type, int session_id); | 73 void OpenedOnIOThread(MediaStreamDeviceType type, int session_id); |
74 // Callback used by CloseOnDeviceThread(), called with the session_id | 74 // Callback used by CloseOnDeviceThread(), called with the session_id |
75 // referencing the closed device on IO thread. | 75 // referencing the closed device on IO thread. |
76 void ClosedOnIOThread(content::MediaStreamDeviceType type, int session_id); | 76 void ClosedOnIOThread(MediaStreamDeviceType type, int session_id); |
77 | 77 |
78 // Verifies that the calling thread is media stream device thread. | 78 // Verifies that the calling thread is media stream device thread. |
79 bool IsOnDeviceThread() const; | 79 bool IsOnDeviceThread() const; |
80 | 80 |
81 // Only accessed on Browser::IO thread. | 81 // Only accessed on Browser::IO thread. |
82 MediaStreamProviderListener* listener_; | 82 MediaStreamProviderListener* listener_; |
83 int next_capture_session_id_; | 83 int next_capture_session_id_; |
84 EventHandlerMap event_handlers_; | 84 EventHandlerMap event_handlers_; |
85 | 85 |
86 // Only accessed from media stream device thread. | 86 // Only accessed from media stream device thread. |
87 StreamDeviceMap devices_; | 87 StreamDeviceMap devices_; |
88 media::AudioManager* const audio_manager_; | 88 media::AudioManager* const audio_manager_; |
89 | 89 |
90 // The message loop of media stream device thread that this object runs on. | 90 // The message loop of media stream device thread that this object runs on. |
91 scoped_refptr<base::MessageLoopProxy> device_loop_; | 91 scoped_refptr<base::MessageLoopProxy> device_loop_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 93 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace media_stream | 96 } // namespace content |
97 | 97 |
98 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 98 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
OLD | NEW |