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 // AudioInputRendererHost serves audio related requests from audio capturer | 5 // AudioInputRendererHost serves audio related requests from audio capturer |
6 // which lives inside the render process and provide access to audio hardware. | 6 // which lives inside the render process and provide access to audio hardware. |
7 // | 7 // |
8 // Create stream sequence (AudioInputController = AIC): | 8 // Create stream sequence (AudioInputController = AIC): |
9 // | 9 // |
10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> | 10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
62 #include "media/audio/audio_input_controller.h" | 62 #include "media/audio/audio_input_controller.h" |
63 #include "media/audio/audio_io.h" | 63 #include "media/audio/audio_io.h" |
64 #include "media/audio/simple_sources.h" | 64 #include "media/audio/simple_sources.h" |
65 | 65 |
66 namespace media { | 66 namespace media { |
67 class AudioManager; | 67 class AudioManager; |
68 class AudioParameters; | 68 class AudioParameters; |
69 } | 69 } |
70 | 70 |
71 namespace media_stream { | 71 namespace content { |
72 class MediaStreamManager; | 72 class MediaStreamManager; |
73 } | |
74 | |
75 namespace content { | |
76 | 73 |
77 class CONTENT_EXPORT AudioInputRendererHost | 74 class CONTENT_EXPORT AudioInputRendererHost |
78 : public BrowserMessageFilter, | 75 : public BrowserMessageFilter, |
79 public media::AudioInputController::EventHandler, | 76 public media::AudioInputController::EventHandler, |
80 public media_stream::AudioInputDeviceManagerEventHandler { | 77 public AudioInputDeviceManagerEventHandler { |
81 public: | 78 public: |
82 // Called from UI thread from the owner of this object. | 79 // Called from UI thread from the owner of this object. |
83 AudioInputRendererHost( | 80 AudioInputRendererHost( |
84 media::AudioManager* audio_manager, | 81 media::AudioManager* audio_manager, |
85 media_stream::MediaStreamManager* media_stream_manager); | 82 MediaStreamManager* media_stream_manager); |
86 | 83 |
87 // content::BrowserMessageFilter implementation. | 84 // BrowserMessageFilter implementation. |
88 virtual void OnChannelClosing() OVERRIDE; | 85 virtual void OnChannelClosing() OVERRIDE; |
89 virtual void OnDestruct() const OVERRIDE; | 86 virtual void OnDestruct() const OVERRIDE; |
90 virtual bool OnMessageReceived(const IPC::Message& message, | 87 virtual bool OnMessageReceived(const IPC::Message& message, |
91 bool* message_was_ok) OVERRIDE; | 88 bool* message_was_ok) OVERRIDE; |
92 | 89 |
93 // AudioInputController::EventHandler implementation. | 90 // AudioInputController::EventHandler implementation. |
94 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; | 91 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; |
95 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; | 92 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; |
96 virtual void OnError(media::AudioInputController* controller, | 93 virtual void OnError(media::AudioInputController* controller, |
97 int error_code) OVERRIDE; | 94 int error_code) OVERRIDE; |
98 virtual void OnData(media::AudioInputController* controller, | 95 virtual void OnData(media::AudioInputController* controller, |
99 const uint8* data, | 96 const uint8* data, |
100 uint32 size) OVERRIDE; | 97 uint32 size) OVERRIDE; |
101 | 98 |
102 // media_stream::AudioInputDeviceManagerEventHandler implementation. | 99 // AudioInputDeviceManagerEventHandler implementation. |
103 virtual void OnDeviceStarted(int session_id, | 100 virtual void OnDeviceStarted(int session_id, |
104 const std::string& device_id) OVERRIDE; | 101 const std::string& device_id) OVERRIDE; |
105 virtual void OnDeviceStopped(int session_id) OVERRIDE; | 102 virtual void OnDeviceStopped(int session_id) OVERRIDE; |
106 | 103 |
107 private: | 104 private: |
108 // TODO(henrika): extend test suite (compare AudioRenderHost) | 105 // TODO(henrika): extend test suite (compare AudioRenderHost) |
109 friend class BrowserThread; | 106 friend class BrowserThread; |
110 friend class base::DeleteHelper<AudioInputRendererHost>; | 107 friend class base::DeleteHelper<AudioInputRendererHost>; |
111 | 108 |
112 struct AudioEntry; | 109 struct AudioEntry; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 AudioEntry* LookupByController(media::AudioInputController* controller); | 175 AudioEntry* LookupByController(media::AudioInputController* controller); |
179 | 176 |
180 // A helper method to look up a session identified by |stream_id|. | 177 // A helper method to look up a session identified by |stream_id|. |
181 // Returns 0 if not found. | 178 // Returns 0 if not found. |
182 int LookupSessionById(int stream_id); | 179 int LookupSessionById(int stream_id); |
183 | 180 |
184 // Used to create an AudioInputController. | 181 // Used to create an AudioInputController. |
185 media::AudioManager* audio_manager_; | 182 media::AudioManager* audio_manager_; |
186 | 183 |
187 // Used to access to AudioInputDeviceManager. | 184 // Used to access to AudioInputDeviceManager. |
188 media_stream::MediaStreamManager* media_stream_manager_; | 185 MediaStreamManager* media_stream_manager_; |
189 | 186 |
190 // A map of stream IDs to audio sources. | 187 // A map of stream IDs to audio sources. |
191 AudioEntryMap audio_entries_; | 188 AudioEntryMap audio_entries_; |
192 | 189 |
193 // A map of session IDs to audio session sources. | 190 // A map of session IDs to audio session sources. |
194 SessionEntryMap session_entries_; | 191 SessionEntryMap session_entries_; |
195 | 192 |
196 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 193 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
197 }; | 194 }; |
198 | 195 |
199 } // namespace content | 196 } // namespace content |
200 | 197 |
201 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 198 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
OLD | NEW |