| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/numerics/safe_math.h" | 14 #include "base/numerics/safe_math.h" |
| 15 #include "base/process/process.h" | 15 #include "base/process/process.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" | 19 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" |
| 20 #include "content/browser/media/capture/web_contents_audio_input_stream.h" | 20 #include "content/browser/media/capture/web_contents_audio_input_stream.h" |
| 21 #include "content/browser/media/media_internals.h" | 21 #include "content/browser/media/media_internals.h" |
| 22 #include "content/browser/media/webrtc/webrtc_internals.h" | 22 #include "content/browser/media/webrtc/webrtc_internals.h" |
| 23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" | 23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" |
| 24 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 24 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" | 25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
| 26 #include "content/browser/renderer_host/media/media_stream_manager.h" | 26 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 27 #include "content/public/browser/web_contents_media_capture_id.h" | 27 #include "content/public/browser/web_contents_media_capture_id.h" |
| 28 #include "media/audio/audio_manager_base.h" | 28 #include "media/audio/audio_device_description.h" |
| 29 #include "media/base/audio_bus.h" | 29 #include "media/base/audio_bus.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 #ifdef ENABLE_WEBRTC | 35 #ifdef ENABLE_WEBRTC |
| 36 const base::FilePath::CharType kDebugRecordingFileNameAddition[] = | 36 const base::FilePath::CharType kDebugRecordingFileNameAddition[] = |
| 37 FILE_PATH_LITERAL("source_input"); | 37 FILE_PATH_LITERAL("source_input"); |
| 38 const base::FilePath::CharType kDebugRecordingFileNameExtension[] = | 38 const base::FilePath::CharType kDebugRecordingFileNameExtension[] = |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 | 379 |
| 380 media::AudioParameters audio_params(config.params); | 380 media::AudioParameters audio_params(config.params); |
| 381 if (media_stream_manager_->audio_input_device_manager() | 381 if (media_stream_manager_->audio_input_device_manager() |
| 382 ->ShouldUseFakeDevice()) | 382 ->ShouldUseFakeDevice()) |
| 383 audio_params.set_format(media::AudioParameters::AUDIO_FAKE); | 383 audio_params.set_format(media::AudioParameters::AUDIO_FAKE); |
| 384 | 384 |
| 385 // Check if we have the permission to open the device and which device to use. | 385 // Check if we have the permission to open the device and which device to use. |
| 386 MediaStreamType type = MEDIA_NO_SERVICE; | 386 MediaStreamType type = MEDIA_NO_SERVICE; |
| 387 std::string device_name; | 387 std::string device_name; |
| 388 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; | 388 std::string device_id = media::AudioDeviceDescription::kDefaultDeviceId; |
| 389 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { | 389 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { |
| 390 const StreamDeviceInfo* info = media_stream_manager_-> | 390 const StreamDeviceInfo* info = media_stream_manager_-> |
| 391 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); | 391 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); |
| 392 if (!info) { | 392 if (!info) { |
| 393 SendErrorMessage(stream_id, PERMISSION_DENIED); | 393 SendErrorMessage(stream_id, PERMISSION_DENIED); |
| 394 DLOG(WARNING) << "No permission has been granted to input stream with " | 394 DLOG(WARNING) << "No permission has been granted to input stream with " |
| 395 << "session_id=" << session_id; | 395 << "session_id=" << session_id; |
| 396 MaybeUnregisterKeyboardMicStream(config); | 396 MaybeUnregisterKeyboardMicStream(config); |
| 397 return; | 397 return; |
| 398 } | 398 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 audio_params, | 461 audio_params, |
| 462 device_id, | 462 device_id, |
| 463 entry->writer.get(), | 463 entry->writer.get(), |
| 464 user_input_monitor_, | 464 user_input_monitor_, |
| 465 config.automatic_gain_control); | 465 config.automatic_gain_control); |
| 466 oss << ", AGC=" << config.automatic_gain_control; | 466 oss << ", AGC=" << config.automatic_gain_control; |
| 467 | 467 |
| 468 // Only count for captures from desktop media picker dialog and system loop | 468 // Only count for captures from desktop media picker dialog and system loop |
| 469 // back audio. | 469 // back audio. |
| 470 if (entry->controller.get() && type == MEDIA_DESKTOP_AUDIO_CAPTURE && | 470 if (entry->controller.get() && type == MEDIA_DESKTOP_AUDIO_CAPTURE && |
| 471 device_id == media::AudioManagerBase::kLoopbackInputDeviceId) { | 471 device_id == media::AudioDeviceDescription::kLoopbackInputDeviceId) { |
| 472 IncrementDesktopCaptureCounter(SYSTEM_LOOPBACK_AUDIO_CAPTURER_CREATED); | 472 IncrementDesktopCaptureCounter(SYSTEM_LOOPBACK_AUDIO_CAPTURER_CREATED); |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 if (!entry->controller.get()) { | 476 if (!entry->controller.get()) { |
| 477 SendErrorMessage(stream_id, STREAM_CREATE_ERROR); | 477 SendErrorMessage(stream_id, STREAM_CREATE_ERROR); |
| 478 MaybeUnregisterKeyboardMicStream(config); | 478 MaybeUnregisterKeyboardMicStream(config); |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 | 481 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 if (entry->input_debug_writer.get()) { | 729 if (entry->input_debug_writer.get()) { |
| 730 BrowserThread::PostTask( | 730 BrowserThread::PostTask( |
| 731 BrowserThread::FILE, FROM_HERE, | 731 BrowserThread::FILE, FROM_HERE, |
| 732 base::Bind(&DeleteInputDebugWriterOnFileThread, | 732 base::Bind(&DeleteInputDebugWriterOnFileThread, |
| 733 base::Passed(std::move(entry->input_debug_writer)))); | 733 base::Passed(std::move(entry->input_debug_writer)))); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 #endif // defined(ENABLE_WEBRTC) | 736 #endif // defined(ENABLE_WEBRTC) |
| 737 | 737 |
| 738 } // namespace content | 738 } // namespace content |
| OLD | NEW |