Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager.h

Issue 8818012: Remove the AudioManager singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Set svn eol properties for a couple of files Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "content/browser/renderer_host/media/media_stream_provider.h" 18 #include "content/browser/renderer_host/media/media_stream_provider.h"
19 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "content/common/media/media_stream_options.h" 20 #include "content/common/media/media_stream_options.h"
21 #include "media/audio/audio_device_name.h" 21 #include "media/audio/audio_device_name.h"
22 22
23 class AudioManager;
24
23 namespace media_stream { 25 namespace media_stream {
24 26
25 class AudioInputDeviceManagerEventHandler; 27 class AudioInputDeviceManagerEventHandler;
26 28
27 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { 29 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
28 public: 30 public:
29 // Calling Start() with this kFakeOpenSessionId will open the default device, 31 // Calling Start() with this kFakeOpenSessionId will open the default device,
30 // even though Open() has not been called. This is used to be able to use the 32 // even though Open() has not been called. This is used to be able to use the
31 // AudioInputDeviceManager before MediaStream is implemented. 33 // AudioInputDeviceManager before MediaStream is implemented.
32 static const int kFakeOpenSessionId; 34 static const int kFakeOpenSessionId;
33 35
34 static const int kInvalidSessionId; 36 static const int kInvalidSessionId;
35 static const char kInvalidDeviceId[]; 37 static const char kInvalidDeviceId[];
36 38
37 AudioInputDeviceManager(); 39 explicit AudioInputDeviceManager(AudioManager* audio_manager);
38 virtual ~AudioInputDeviceManager(); 40 virtual ~AudioInputDeviceManager();
39 41
40 // MediaStreamProvider implementation, called on IO thread. 42 // MediaStreamProvider implementation, called on IO thread.
41 virtual void Register(MediaStreamProviderListener* listener) OVERRIDE; 43 virtual void Register(MediaStreamProviderListener* listener) OVERRIDE;
42 virtual void Unregister() OVERRIDE; 44 virtual void Unregister() OVERRIDE;
43 virtual void EnumerateDevices() OVERRIDE; 45 virtual void EnumerateDevices() OVERRIDE;
44 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; 46 virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
45 virtual void Close(int session_id) OVERRIDE; 47 virtual void Close(int session_id) OVERRIDE;
46 48
47 // Functions used by AudioInputRenderHost, called on IO thread. 49 // Functions used by AudioInputRenderHost, called on IO thread.
48 // Start the device referenced by the session id. 50 // Start the device referenced by the session id.
49 void Start(int session_id, 51 void Start(int session_id,
50 AudioInputDeviceManagerEventHandler* event_handler); 52 AudioInputDeviceManagerEventHandler* event_handler);
51 // Stop the device referenced by the session id. 53 // Stop the device referenced by the session id.
52 void Stop(int session_id); 54 void Stop(int session_id);
53 55
54 private: 56 private:
55 // Executed on IO thread to call Listener. 57 // Executed on IO thread to call Listener.
56 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); 58 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices);
57 void OpenedOnIOThread(int session_id); 59 void OpenedOnIOThread(int session_id);
58 void ClosedOnIOThread(int session_id); 60 void ClosedOnIOThread(int session_id);
59 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); 61 void ErrorOnIOThread(int session_id, MediaStreamProviderError error);
60 62
61 MediaStreamProviderListener* listener_; 63 MediaStreamProviderListener* listener_;
62 int next_capture_session_id_; 64 int next_capture_session_id_;
63 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; 65 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap;
64 EventHandlerMap event_handlers_; 66 EventHandlerMap event_handlers_;
65 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; 67 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap;
66 AudioInputDeviceMap devices_; 68 AudioInputDeviceMap devices_;
69 scoped_refptr<AudioManager> audio_manager_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 71 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
69 }; 72 };
70 73
71 } // namespace media_stream 74 } // namespace media_stream
72 75
73 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager); 76 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager);
74 77
75 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 78 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698