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 #include "content/renderer/media/audio_input_message_filter.h" | 5 #include "content/renderer/media/audio_input_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "content/common/media/audio_messages.h" | 9 #include "content/common/media/audio_messages.h" |
10 #include "ipc/ipc_logging.h" | 10 #include "ipc/ipc_logging.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 bool AudioInputMessageFilter::OnMessageReceived(const IPC::Message& message) { | 43 bool AudioInputMessageFilter::OnMessageReceived(const IPC::Message& message) { |
44 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 44 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
45 bool handled = true; | 45 bool handled = true; |
46 IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message) | 46 IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message) |
47 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated, | 47 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated, |
48 OnStreamCreated) | 48 OnStreamCreated) |
49 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume) | 49 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume) |
50 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged, | 50 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged, |
51 OnStreamStateChanged) | 51 OnStreamStateChanged) |
52 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyDeviceStarted, | |
53 OnDeviceStarted) | |
54 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
55 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
56 return handled; | 54 return handled; |
57 } | 55 } |
58 | 56 |
59 void AudioInputMessageFilter::OnFilterAdded(IPC::Channel* channel) { | 57 void AudioInputMessageFilter::OnFilterAdded(IPC::Channel* channel) { |
60 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 58 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
61 | 59 |
62 // Captures the channel for IPC. | 60 // Captures the channel for IPC. |
63 channel_ = channel; | 61 channel_ = channel; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 127 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
130 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id); | 128 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id); |
131 if (!delegate) { | 129 if (!delegate) { |
132 DLOG(WARNING) << "Got audio stream event for a non-existent or removed" | 130 DLOG(WARNING) << "Got audio stream event for a non-existent or removed" |
133 << " audio renderer."; | 131 << " audio renderer."; |
134 return; | 132 return; |
135 } | 133 } |
136 delegate->OnStateChanged(state); | 134 delegate->OnStateChanged(state); |
137 } | 135 } |
138 | 136 |
139 void AudioInputMessageFilter::OnDeviceStarted(int stream_id, | |
140 const std::string& device_id) { | |
141 DCHECK(io_message_loop_->BelongsToCurrentThread()); | |
142 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id); | |
143 if (!delegate) { | |
144 NOTREACHED(); | |
145 return; | |
146 } | |
147 delegate->OnDeviceReady(device_id); | |
148 } | |
149 | |
150 int AudioInputMessageFilter::AddDelegate( | 137 int AudioInputMessageFilter::AddDelegate( |
151 media::AudioInputIPCDelegate* delegate) { | 138 media::AudioInputIPCDelegate* delegate) { |
152 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 139 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
153 return delegates_.Add(delegate); | 140 return delegates_.Add(delegate); |
154 } | 141 } |
155 | 142 |
156 void AudioInputMessageFilter::RemoveDelegate(int id) { | 143 void AudioInputMessageFilter::RemoveDelegate(int id) { |
157 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 144 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
158 delegates_.Remove(id); | 145 delegates_.Remove(id); |
159 } | 146 } |
160 | 147 |
161 void AudioInputMessageFilter::CreateStream(int stream_id, | 148 void AudioInputMessageFilter::CreateStream(int stream_id, |
| 149 int session_id, |
162 const media::AudioParameters& params, | 150 const media::AudioParameters& params, |
163 const std::string& device_id, | |
164 bool automatic_gain_control, | 151 bool automatic_gain_control, |
165 uint32 total_segments) { | 152 uint32 total_segments) { |
166 Send(new AudioInputHostMsg_CreateStream( | 153 Send(new AudioInputHostMsg_CreateStream( |
167 stream_id, params, device_id, automatic_gain_control, | 154 stream_id, session_id, params, automatic_gain_control, total_segments)); |
168 total_segments)); | 155 |
169 } | 156 } |
170 | 157 |
171 void AudioInputMessageFilter::AssociateStreamWithConsumer(int stream_id, | 158 void AudioInputMessageFilter::AssociateStreamWithConsumer(int stream_id, |
172 int render_view_id) { | 159 int render_view_id) { |
173 Send(new AudioInputHostMsg_AssociateStreamWithConsumer( | 160 Send(new AudioInputHostMsg_AssociateStreamWithConsumer( |
174 stream_id, render_view_id)); | 161 stream_id, render_view_id)); |
175 } | 162 } |
176 | 163 |
177 void AudioInputMessageFilter::StartDevice(int stream_id, int session_id) { | |
178 Send(new AudioInputHostMsg_StartDevice(stream_id, session_id)); | |
179 } | |
180 | |
181 void AudioInputMessageFilter::RecordStream(int stream_id) { | 164 void AudioInputMessageFilter::RecordStream(int stream_id) { |
182 Send(new AudioInputHostMsg_RecordStream(stream_id)); | 165 Send(new AudioInputHostMsg_RecordStream(stream_id)); |
183 } | 166 } |
184 | 167 |
185 void AudioInputMessageFilter::CloseStream(int stream_id) { | 168 void AudioInputMessageFilter::CloseStream(int stream_id) { |
186 Send(new AudioInputHostMsg_CloseStream(stream_id)); | 169 Send(new AudioInputHostMsg_CloseStream(stream_id)); |
187 } | 170 } |
188 | 171 |
189 void AudioInputMessageFilter::SetVolume(int stream_id, double volume) { | 172 void AudioInputMessageFilter::SetVolume(int stream_id, double volume) { |
190 Send(new AudioInputHostMsg_SetVolume(stream_id, volume)); | 173 Send(new AudioInputHostMsg_SetVolume(stream_id, volume)); |
191 } | 174 } |
192 | 175 |
193 } // namespace content | 176 } // namespace content |
OLD | NEW |