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

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

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify: Use only one AudioInputDeviceManager and VideoCaptureManager, like before. Created 8 years, 3 months 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) 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/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 "content/public/common/media_stream_request.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 explicit AudioInputDeviceManager(media::AudioManager* audio_manager);
42 40
43 // MediaStreamProvider implementation, called on IO thread. 41 // MediaStreamProvider implementation, called on IO thread.
44 virtual void Register(MediaStreamProviderListener* listener, 42 virtual void Register(MediaStreamProviderListener* listener,
45 base::MessageLoopProxy* device_thread_loop) OVERRIDE; 43 base::MessageLoopProxy* device_thread_loop) OVERRIDE;
46 virtual void Unregister() OVERRIDE; 44 virtual void Unregister() OVERRIDE;
47 virtual void EnumerateDevices() OVERRIDE; 45 virtual void EnumerateDevices() OVERRIDE;
48 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; 46 virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
49 virtual void Close(int session_id) OVERRIDE; 47 virtual void Close(int session_id) OVERRIDE;
50 48
51 // Functions used by AudioInputRenderHost, called on IO thread. 49 // Functions used by AudioInputRenderHost, called on IO thread.
52 // Start the device referenced by the session id. 50 // Start the device referenced by the session id.
53 void Start(int session_id, 51 void Start(int session_id,
54 AudioInputDeviceManagerEventHandler* event_handler); 52 AudioInputDeviceManagerEventHandler* event_handler);
55 // Stop the device referenced by the session id. 53 // Stop the device referenced by the session id.
56 void Stop(int session_id); 54 void Stop(int session_id);
57 55
58 private: 56 private:
59 friend class base::RefCountedThreadSafe<AudioInputDeviceManager>;
60 virtual ~AudioInputDeviceManager(); 57 virtual ~AudioInputDeviceManager();
61 58
62 // Executed on media stream device thread. 59 // Executed on media stream device thread.
63 void EnumerateOnDeviceThread(); 60 void EnumerateOnDeviceThread();
64 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device); 61 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device);
65 void CloseOnDeviceThread(int session_id); 62 void CloseOnDeviceThread(int session_id);
66 63
67 // Executed on IO thread to call Listener. 64 // Executed on IO thread to call Listener.
68 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices); 65 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices);
69 void OpenedOnIOThread(int session_id); 66 void OpenedOnIOThread(content::MediaStreamDeviceType type, int session_id);
70 void ClosedOnIOThread(int session_id); 67 void ClosedOnIOThread(content::MediaStreamDeviceType type, int session_id);
71 68
72 bool IsOnDeviceThread() const; 69 bool IsOnDeviceThread() const;
73 70
74 // Only accessed on Browser::IO thread. 71 // Only accessed on Browser::IO thread.
75 MediaStreamProviderListener* listener_; 72 MediaStreamProviderListener* listener_;
76 int next_capture_session_id_; 73 int next_capture_session_id_;
77 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; 74 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap;
78 EventHandlerMap event_handlers_; 75 EventHandlerMap event_handlers_;
79 76
80 // Only accessed from media stream device thread. 77 // Only accessed from media stream device thread.
81 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; 78 typedef std::map<int, StreamDeviceInfo> StreamDeviceMap;
82 AudioInputDeviceMap devices_; 79 StreamDeviceMap devices_;
83 media::AudioManager* audio_manager_; 80 media::AudioManager* const audio_manager_;
84 81
85 // The message loop of media stream device thread that this object runs on. 82 // The message loop of media stream device thread that this object runs on.
86 scoped_refptr<base::MessageLoopProxy> device_loop_; 83 scoped_refptr<base::MessageLoopProxy> device_loop_;
87 84
88 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 85 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
89 }; 86 };
90 87
91 } // namespace media_stream 88 } // namespace media_stream
92 89
93 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 90 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698