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 16 matching lines...) Expand all Loading... |
27 #include <map> | 27 #include <map> |
28 #include <string> | 28 #include <string> |
29 | 29 |
30 #include "base/compiler_specific.h" | 30 #include "base/compiler_specific.h" |
31 #include "base/gtest_prod_util.h" | 31 #include "base/gtest_prod_util.h" |
32 #include "base/memory/ref_counted.h" | 32 #include "base/memory/ref_counted.h" |
33 #include "base/memory/scoped_ptr.h" | 33 #include "base/memory/scoped_ptr.h" |
34 #include "base/process.h" | 34 #include "base/process.h" |
35 #include "base/sequenced_task_runner_helpers.h" | 35 #include "base/sequenced_task_runner_helpers.h" |
36 #include "base/shared_memory.h" | 36 #include "base/shared_memory.h" |
| 37 #include "content/common/media/audio_messages.h" |
37 #include "content/public/browser/browser_message_filter.h" | 38 #include "content/public/browser/browser_message_filter.h" |
38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
39 #include "media/audio/audio_input_controller.h" | 40 #include "media/audio/audio_input_controller.h" |
40 #include "media/audio/audio_io.h" | 41 #include "media/audio/audio_io.h" |
41 #include "media/audio/simple_sources.h" | 42 #include "media/audio/simple_sources.h" |
42 | 43 |
43 namespace media { | 44 namespace media { |
44 class AudioManager; | 45 class AudioManager; |
45 class AudioParameters; | 46 class AudioParameters; |
46 } | 47 } |
(...skipping 30 matching lines...) Expand all Loading... |
77 friend class base::DeleteHelper<AudioInputRendererHost>; | 78 friend class base::DeleteHelper<AudioInputRendererHost>; |
78 | 79 |
79 struct AudioEntry; | 80 struct AudioEntry; |
80 typedef std::map<int, AudioEntry*> AudioEntryMap; | 81 typedef std::map<int, AudioEntry*> AudioEntryMap; |
81 | 82 |
82 virtual ~AudioInputRendererHost(); | 83 virtual ~AudioInputRendererHost(); |
83 | 84 |
84 // Methods called on IO thread ---------------------------------------------- | 85 // Methods called on IO thread ---------------------------------------------- |
85 | 86 |
86 // Audio related IPC message handlers. | 87 // Audio related IPC message handlers. |
87 // Creates an audio input stream with the specified session id and format. | 88 |
88 // |session_id| is used to find out which device to be used for the stream, | 89 // Creates an audio input stream with the specified format whose data is |
89 // when it is AudioInputDeviceManager::kFakeOpenSessionId, it uses the | 90 // consumed by an entity in the render view referenced by |render_view_id|. |
90 // the default device. If this call is successful this object would keep an | 91 // |session_id| is used to find out which device to be used for the stream. |
91 // internal entry of the stream for the required properties. | 92 // When it is AudioInputDeviceManager::kFakeOpenSessionId, it uses the the |
| 93 // default device. Upon success/failure, the peer is notified via the |
| 94 // NotifyStreamCreated message. |
92 void OnCreateStream(int stream_id, | 95 void OnCreateStream(int stream_id, |
| 96 int render_view_id, |
93 int session_id, | 97 int session_id, |
94 const media::AudioParameters& params, | 98 const AudioInputHostMsg_CreateStream_Config& config); |
95 bool automatic_gain_control, | |
96 int shared_memory_count); | |
97 | |
98 // Track that the data for the audio stream referenced by |stream_id| is | |
99 // consumed by an entity in the render view referenced by |render_view_id|. | |
100 void OnAssociateStreamWithConsumer(int stream_id, int render_view_id); | |
101 | 99 |
102 // Record the audio input stream referenced by |stream_id|. | 100 // Record the audio input stream referenced by |stream_id|. |
103 void OnRecordStream(int stream_id); | 101 void OnRecordStream(int stream_id); |
104 | 102 |
105 // Close the audio stream referenced by |stream_id|. | 103 // Close the audio stream referenced by |stream_id|. |
106 void OnCloseStream(int stream_id); | 104 void OnCloseStream(int stream_id); |
107 | 105 |
108 // Set the volume of the audio stream referenced by |stream_id|. | 106 // Set the volume of the audio stream referenced by |stream_id|. |
109 void OnSetVolume(int stream_id, double volume); | 107 void OnSetVolume(int stream_id, double volume); |
110 | 108 |
111 // Complete the process of creating an audio input stream. This will set up | 109 // Complete the process of creating an audio input stream. This will set up |
112 // the shared memory or shared socket in low latency mode. | 110 // the shared memory or shared socket in low latency mode and send the |
| 111 // NotifyStreamCreated message to the peer. |
113 void DoCompleteCreation(media::AudioInputController* controller); | 112 void DoCompleteCreation(media::AudioInputController* controller); |
114 | 113 |
115 // Send a state change message to the renderer. | 114 // Send a state change message to the renderer. |
116 void DoSendRecordingMessage(media::AudioInputController* controller); | 115 void DoSendRecordingMessage(media::AudioInputController* controller); |
117 | 116 |
118 // Handle error coming from audio stream. | 117 // Handle error coming from audio stream. |
119 void DoHandleError(media::AudioInputController* controller); | 118 void DoHandleError(media::AudioInputController* controller); |
120 | 119 |
121 // Send an error message to the renderer. | 120 // Send an error message to the renderer. |
122 void SendErrorMessage(int stream_id); | 121 void SendErrorMessage(int stream_id); |
(...skipping 28 matching lines...) Expand all Loading... |
151 | 150 |
152 // A map of stream IDs to audio sources. | 151 // A map of stream IDs to audio sources. |
153 AudioEntryMap audio_entries_; | 152 AudioEntryMap audio_entries_; |
154 | 153 |
155 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 154 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
156 }; | 155 }; |
157 | 156 |
158 } // namespace content | 157 } // namespace content |
159 | 158 |
160 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 159 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
OLD | NEW |