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

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

Issue 2696533002: Rmoving the notion of task runner from MediaStreamProvider interface. (Closed)
Patch Set: Created 3 years, 10 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 13 matching lines...) Expand all
24 #include "content/common/content_export.h" 24 #include "content/common/content_export.h"
25 #include "content/common/media/media_stream_options.h" 25 #include "content/common/media/media_stream_options.h"
26 #include "content/public/common/media_stream_request.h" 26 #include "content/public/common/media_stream_request.h"
27 27
28 namespace media { 28 namespace media {
29 class AudioManager; 29 class AudioManager;
30 } 30 }
31 31
32 namespace content { 32 namespace content {
33 33
34 // Should be used on IO thread only.
34 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { 35 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
35 public: 36 public:
36 // Calling Start() with this kFakeOpenSessionId will open the default device, 37 // 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 38 // even though Open() has not been called. This is used to be able to use the
38 // AudioInputDeviceManager before MediaStream is implemented. 39 // AudioInputDeviceManager before MediaStream is implemented.
39 // TODO(xians): Remove it when the webrtc unittest does not need it any more. 40 // TODO(xians): Remove it when the webrtc unittest does not need it any more.
40 static const int kFakeOpenSessionId; 41 static const int kFakeOpenSessionId;
41 42
42 explicit AudioInputDeviceManager(media::AudioManager* audio_manager); 43 explicit AudioInputDeviceManager(media::AudioManager* audio_manager);
43 44
44 // 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
45 // is not opened, otherwise the opened device. Called on IO thread. 46 // is not opened, otherwise the opened device. Called on IO thread.
46 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id); 47 const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id);
47 48
48 void Unregister(); 49 // MediaStreamProvider implementation.
49 50 void RegisterListener(MediaStreamProviderListener* listener) override;
50 // MediaStreamProvider implementation, called on IO thread. 51 void UnregisterListener() override;
51 void Register(MediaStreamProviderListener* listener,
52 const scoped_refptr<base::SingleThreadTaskRunner>&
53 device_task_runner) override;
54 int Open(const StreamDeviceInfo& device) override; 52 int Open(const StreamDeviceInfo& device) override;
55 void Close(int session_id) override; 53 void Close(int session_id) override;
56 54
57 #if defined(OS_CHROMEOS) 55 #if defined(OS_CHROMEOS)
58 // 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
59 // 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
60 // 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
61 // 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
62 // which is called when activated. 60 // which is called when activated.
63 // Called on the IO thread.
64 void RegisterKeyboardMicStream(const base::Closure& callback); 61 void RegisterKeyboardMicStream(const base::Closure& callback);
65 void UnregisterKeyboardMicStream(); 62 void UnregisterKeyboardMicStream();
66 #endif 63 #endif
67 64
68 private: 65 private:
69 typedef std::vector<StreamDeviceInfo> StreamDeviceList; 66 typedef std::vector<StreamDeviceInfo> StreamDeviceList;
70 ~AudioInputDeviceManager() override; 67 ~AudioInputDeviceManager() override;
71 68
72 // Opens the device on media stream device thread. 69 // Opens the device on media stream device thread.
73 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info); 70 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 102
106 // 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.
107 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; 104 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
108 105
109 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 106 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
110 }; 107 };
111 108
112 } // namespace content 109 } // namespace content
113 110
114 #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