| 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/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 DeleteEntryOnError(entry); | 177 DeleteEntryOnError(entry); |
| 178 } | 178 } |
| 179 | 179 |
| 180 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message, | 180 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message, |
| 181 bool* message_was_ok) { | 181 bool* message_was_ok) { |
| 182 bool handled = true; | 182 bool handled = true; |
| 183 IPC_BEGIN_MESSAGE_MAP_EX(AudioInputRendererHost, message, *message_was_ok) | 183 IPC_BEGIN_MESSAGE_MAP_EX(AudioInputRendererHost, message, *message_was_ok) |
| 184 IPC_MESSAGE_HANDLER(AudioInputHostMsg_StartDevice, OnStartDevice) | 184 IPC_MESSAGE_HANDLER(AudioInputHostMsg_StartDevice, OnStartDevice) |
| 185 IPC_MESSAGE_HANDLER(AudioInputHostMsg_CreateStream, OnCreateStream) | 185 IPC_MESSAGE_HANDLER(AudioInputHostMsg_CreateStream, OnCreateStream) |
| 186 IPC_MESSAGE_HANDLER(AudioInputHostMsg_AssociateStreamWithConsumer, |
| 187 OnAssociateStreamWithConsumer) |
| 186 IPC_MESSAGE_HANDLER(AudioInputHostMsg_RecordStream, OnRecordStream) | 188 IPC_MESSAGE_HANDLER(AudioInputHostMsg_RecordStream, OnRecordStream) |
| 187 IPC_MESSAGE_HANDLER(AudioInputHostMsg_CloseStream, OnCloseStream) | 189 IPC_MESSAGE_HANDLER(AudioInputHostMsg_CloseStream, OnCloseStream) |
| 188 IPC_MESSAGE_HANDLER(AudioInputHostMsg_SetVolume, OnSetVolume) | 190 IPC_MESSAGE_HANDLER(AudioInputHostMsg_SetVolume, OnSetVolume) |
| 189 IPC_MESSAGE_UNHANDLED(handled = false) | 191 IPC_MESSAGE_UNHANDLED(handled = false) |
| 190 IPC_END_MESSAGE_MAP_EX() | 192 IPC_END_MESSAGE_MAP_EX() |
| 191 | 193 |
| 192 return handled; | 194 return handled; |
| 193 } | 195 } |
| 194 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { | 196 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { |
| 195 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" | 197 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) | 269 if (params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) |
| 268 entry->controller->SetAutomaticGainControl(automatic_gain_control); | 270 entry->controller->SetAutomaticGainControl(automatic_gain_control); |
| 269 | 271 |
| 270 // If we have created the controller successfully create a entry and add it | 272 // If we have created the controller successfully create a entry and add it |
| 271 // to the map. | 273 // to the map. |
| 272 entry->stream_id = stream_id; | 274 entry->stream_id = stream_id; |
| 273 | 275 |
| 274 audio_entries_.insert(std::make_pair(stream_id, entry.release())); | 276 audio_entries_.insert(std::make_pair(stream_id, entry.release())); |
| 275 } | 277 } |
| 276 | 278 |
| 279 void AudioInputRendererHost::OnAssociateStreamWithConsumer(int stream_id, |
| 280 int render_view_id) { |
| 281 // TODO(miu): Will use render_view_id in upcoming change. |
| 282 DVLOG(1) << "AudioInputRendererHost@" << this |
| 283 << "::OnAssociateStreamWithConsumer(stream_id=" << stream_id |
| 284 << ", render_view_id=" << render_view_id << ")"; |
| 285 } |
| 286 |
| 277 void AudioInputRendererHost::OnRecordStream(int stream_id) { | 287 void AudioInputRendererHost::OnRecordStream(int stream_id) { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 279 | 289 |
| 280 AudioEntry* entry = LookupById(stream_id); | 290 AudioEntry* entry = LookupById(stream_id); |
| 281 if (!entry) { | 291 if (!entry) { |
| 282 SendErrorMessage(stream_id); | 292 SendErrorMessage(stream_id); |
| 283 return; | 293 return; |
| 284 } | 294 } |
| 285 | 295 |
| 286 entry->controller->Record(); | 296 entry->controller->Record(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 for (SessionEntryMap::iterator it = session_entries_.begin(); | 441 for (SessionEntryMap::iterator it = session_entries_.begin(); |
| 432 it != session_entries_.end(); ++it) { | 442 it != session_entries_.end(); ++it) { |
| 433 if (stream_id == it->second) { | 443 if (stream_id == it->second) { |
| 434 return it->first; | 444 return it->first; |
| 435 } | 445 } |
| 436 } | 446 } |
| 437 return 0; | 447 return 0; |
| 438 } | 448 } |
| 439 | 449 |
| 440 } // namespace content | 450 } // namespace content |
| OLD | NEW |