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

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

Issue 2729783003: [Mojo Video Capture] Add content_browsertest for exercising video capture (Closed)
Patch Set: incorporated miu@'s suggestions Created 3 years, 9 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7 // browser IO thread, handles queries like
8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and 8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and
9 // GetOpenedDeviceInfoById from AudioInputRendererHost. 9 // GetOpenedDeviceInfoById from AudioInputRendererHost.
10 // The work for enumerate/open/close is handled asynchronously on Media Stream 10 // The work for enumerate/open/close is handled asynchronously on Media Stream
(...skipping 30 matching lines...) Expand all
41 static const int kFakeOpenSessionId; 41 static const int kFakeOpenSessionId;
42 42
43 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); 43 explicit AudioInputDeviceManager(media::AudioManager* audio_manager);
44 44
45 // Gets the opened device info by |session_id|. Returns NULL if the device 45 // Gets the opened device info by |session_id|. Returns NULL if the device
46 // is not opened, otherwise the opened device. Called on IO thread. 46 // is not opened, otherwise the opened device. Called on IO thread.
47 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id); 47 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id);
48 48
49 // MediaStreamProvider implementation. 49 // MediaStreamProvider implementation.
50 void RegisterListener(MediaStreamProviderListener* listener) override; 50 void RegisterListener(MediaStreamProviderListener* listener) override;
51 void UnregisterListener() override; 51 void UnregisterListener(MediaStreamProviderListener* listener) override;
52 int Open(const StreamDeviceInfo& device) override; 52 int Open(const MediaStreamDevice& device) override;
53 void Close(int session_id) override; 53 void Close(int session_id) override;
54 54
55 #if defined(OS_CHROMEOS) 55 #if defined(OS_CHROMEOS)
56 // Registers and unregisters that a stream using keyboard mic has been opened 56 // Registers and unregisters that a stream using keyboard mic has been opened
57 // or closed. Keeps count of how many such streams are open and activates and 57 // or closed. Keeps count of how many such streams are open and activates and
58 // inactivates the keyboard mic accordingly. The (in)activation is done on the 58 // inactivates the keyboard mic accordingly. The (in)activation is done on the
59 // UI thread and for the register case a callback must therefor be provided 59 // UI thread and for the register case a callback must therefor be provided
60 // which is called when activated. 60 // which is called when activated.
61 void RegisterKeyboardMicStream(const base::Closure& callback); 61 void RegisterKeyboardMicStream(const base::Closure& callback);
62 void UnregisterKeyboardMicStream(); 62 void UnregisterKeyboardMicStream();
63 #endif 63 #endif
64 64
65 private: 65 private:
66 typedef std::vector<StreamDeviceInfo> StreamDeviceList; 66 typedef std::vector<StreamDeviceInfo> StreamDeviceList;
67 ~AudioInputDeviceManager() override; 67 ~AudioInputDeviceManager() override;
68 68
69 // Opens the device on media stream device thread. 69 // Opens the device on media stream device thread.
70 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); 70 void OpenOnDeviceThread(int session_id, const MediaStreamDevice& device);
71 71
72 // Callback used by OpenOnDeviceThread(), called with the session_id 72 // Callback used by OpenOnDeviceThread(), called with the session_id
73 // referencing the opened device on IO thread. 73 // referencing the opened device on IO thread.
74 void OpenedOnIOThread(int session_id, const StreamDeviceInfo& info); 74 void OpenedOnIOThread(int session_id, const StreamDeviceInfo& info);
75 // Callback used by CloseOnDeviceThread(), called with the session_id 75 // Callback used by CloseOnDeviceThread(), called with the session_id
76 // referencing the closed device on IO thread. 76 // referencing the closed device on IO thread.
77 void ClosedOnIOThread(MediaStreamType type, int session_id); 77 void ClosedOnIOThread(MediaStreamType type, int session_id);
78 78
79 // Verifies that the calling thread is media stream device thread. 79 // Verifies that the calling thread is media stream device thread.
80 bool IsOnDeviceThread() const; 80 bool IsOnDeviceThread() const;
81 81
82 // Helper to return iterator to the device referenced by |session_id|. If no 82 // Helper to return iterator to the device referenced by |session_id|. If no
83 // device is found, it will return devices_.end(). 83 // device is found, it will return devices_.end().
84 StreamDeviceList::iterator GetDevice(int session_id); 84 StreamDeviceList::iterator GetDevice(int session_id);
85 85
86 #if defined(OS_CHROMEOS) 86 #if defined(OS_CHROMEOS)
87 // Calls Cras audio handler and sets keyboard mic active status. 87 // Calls Cras audio handler and sets keyboard mic active status.
88 void SetKeyboardMicStreamActiveOnUIThread(bool active); 88 void SetKeyboardMicStreamActiveOnUIThread(bool active);
89 #endif 89 #endif
90 90
91 // Only accessed on Browser::IO thread. 91 // Only accessed on Browser::IO thread.
92 MediaStreamProviderListener* listener_; 92 base::ObserverList<MediaStreamProviderListener> listeners_;
93 int next_capture_session_id_; 93 int next_capture_session_id_;
94 StreamDeviceList devices_; 94 StreamDeviceList devices_;
95 95
96 #if defined(OS_CHROMEOS) 96 #if defined(OS_CHROMEOS)
97 // Keeps count of how many streams are using keyboard mic. 97 // Keeps count of how many streams are using keyboard mic.
98 int keyboard_mic_streams_count_; 98 int keyboard_mic_streams_count_;
99 #endif 99 #endif
100 100
101 media::AudioManager* const audio_manager_; // Weak. 101 media::AudioManager* const audio_manager_; // Weak.
102 102
103 // The message loop of media stream device thread that this object runs on. 103 // The message loop of media stream device thread that this object runs on.
104 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; 104 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 106 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
107 }; 107 };
108 108
109 } // namespace content 109 } // namespace content
110 110
111 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 111 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | 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