Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 1825633002: Adds UMA histograms for desktop tab and audio capture through (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/web_contents_audio_input_stream.h" 20 #include "content/browser/media/capture/web_contents_audio_input_stream.h"
20 #include "content/browser/media/media_internals.h" 21 #include "content/browser/media/media_internals.h"
21 #include "content/browser/media/webrtc/webrtc_internals.h" 22 #include "content/browser/media/webrtc/webrtc_internals.h"
22 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" 23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h"
23 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 24 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
24 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" 25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
25 #include "content/browser/renderer_host/media/media_stream_manager.h" 26 #include "content/browser/renderer_host/media/media_stream_manager.h"
26 #include "content/public/browser/web_contents_media_capture_id.h" 27 #include "content/public/browser/web_contents_media_capture_id.h"
27 #include "media/audio/audio_manager_base.h" 28 #include "media/audio/audio_manager_base.h"
28 #include "media/base/audio_bus.h" 29 #include "media/base/audio_bus.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 MaybeUnregisterKeyboardMicStream(config); 376 MaybeUnregisterKeyboardMicStream(config);
376 return; 377 return;
377 } 378 }
378 379
379 media::AudioParameters audio_params(config.params); 380 media::AudioParameters audio_params(config.params);
380 if (media_stream_manager_->audio_input_device_manager() 381 if (media_stream_manager_->audio_input_device_manager()
381 ->ShouldUseFakeDevice()) 382 ->ShouldUseFakeDevice())
382 audio_params.set_format(media::AudioParameters::AUDIO_FAKE); 383 audio_params.set_format(media::AudioParameters::AUDIO_FAKE);
383 384
384 // 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;
385 std::string device_name; 387 std::string device_name;
386 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; 388 std::string device_id = media::AudioManagerBase::kDefaultDeviceId;
387 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { 389 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) {
388 const StreamDeviceInfo* info = media_stream_manager_-> 390 const StreamDeviceInfo* info = media_stream_manager_->
389 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); 391 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id);
390 if (!info) { 392 if (!info) {
391 SendErrorMessage(stream_id, PERMISSION_DENIED); 393 SendErrorMessage(stream_id, PERMISSION_DENIED);
392 DLOG(WARNING) << "No permission has been granted to input stream with " 394 DLOG(WARNING) << "No permission has been granted to input stream with "
393 << "session_id=" << session_id; 395 << "session_id=" << session_id;
394 MaybeUnregisterKeyboardMicStream(config); 396 MaybeUnregisterKeyboardMicStream(config);
395 return; 397 return;
396 } 398 }
397 399 type = info->device.type;
398 device_id = info->device.id; 400 device_id = info->device.id;
399 device_name = info->device.name; 401 device_name = info->device.name;
400 oss << ": device_name=" << device_name; 402 oss << ": device_name=" << device_name;
401 } 403 }
402 404
403 // Create a new AudioEntry structure. 405 // Create a new AudioEntry structure.
404 scoped_ptr<AudioEntry> entry(new AudioEntry()); 406 scoped_ptr<AudioEntry> entry(new AudioEntry());
405 407
406 const uint32_t segment_size = 408 const uint32_t segment_size =
407 (sizeof(media::AudioInputBufferParameters) + 409 (sizeof(media::AudioInputBufferParameters) +
(...skipping 29 matching lines...) Expand all
437 entry->controller = media::AudioInputController::CreateForStream( 439 entry->controller = media::AudioInputController::CreateForStream(
438 audio_manager_->GetTaskRunner(), 440 audio_manager_->GetTaskRunner(),
439 this, 441 this,
440 WebContentsAudioInputStream::Create( 442 WebContentsAudioInputStream::Create(
441 device_id, 443 device_id,
442 audio_params, 444 audio_params,
443 audio_manager_->GetWorkerTaskRunner(), 445 audio_manager_->GetWorkerTaskRunner(),
444 audio_mirroring_manager_), 446 audio_mirroring_manager_),
445 entry->writer.get(), 447 entry->writer.get(),
446 user_input_monitor_); 448 user_input_monitor_);
449 // Only count for captures from desktop media picker dialog.
450 if (entry->controller.get() && type == MEDIA_DESKTOP_AUDIO_CAPTURE)
451 IncrementDesktopCaptureCounter(TAB_AUDIO_CAPTURER_CREATED);
447 } else { 452 } else {
448 // We call CreateLowLatency regardless of the value of 453 // We call CreateLowLatency regardless of the value of
449 // |audio_params.format|. Low latency can currently mean different things in 454 // |audio_params.format|. Low latency can currently mean different things in
450 // different parts of the stack. 455 // different parts of the stack.
451 // TODO(grunell): Clean up the low latency terminology so that it's less 456 // TODO(grunell): Clean up the low latency terminology so that it's less
452 // confusing. 457 // confusing.
453 entry->controller = media::AudioInputController::CreateLowLatency( 458 entry->controller = media::AudioInputController::CreateLowLatency(
454 audio_manager_, 459 audio_manager_,
455 this, 460 this,
456 audio_params, 461 audio_params,
457 device_id, 462 device_id,
458 entry->writer.get(), 463 entry->writer.get(),
459 user_input_monitor_, 464 user_input_monitor_,
460 config.automatic_gain_control); 465 config.automatic_gain_control);
461 oss << ", AGC=" << config.automatic_gain_control; 466 oss << ", AGC=" << config.automatic_gain_control;
467
468 // Only count for captures from desktop media picker dialog and system loop
469 // back audio.
470 if (entry->controller.get() && type == MEDIA_DESKTOP_AUDIO_CAPTURE &&
471 device_id == media::AudioManagerBase::kLoopbackInputDeviceId) {
472 IncrementDesktopCaptureCounter(SYSTEM_LOOPBACK_AUDIO_CAPTURER_CREATED);
473 }
462 } 474 }
463 475
464 if (!entry->controller.get()) { 476 if (!entry->controller.get()) {
465 SendErrorMessage(stream_id, STREAM_CREATE_ERROR); 477 SendErrorMessage(stream_id, STREAM_CREATE_ERROR);
466 MaybeUnregisterKeyboardMicStream(config); 478 MaybeUnregisterKeyboardMicStream(config);
467 return; 479 return;
468 } 480 }
469 481
470 #if defined(OS_CHROMEOS) 482 #if defined(OS_CHROMEOS)
471 if (config.params.channel_layout() == 483 if (config.params.channel_layout() ==
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 if (entry->input_debug_writer.get()) { 729 if (entry->input_debug_writer.get()) {
718 BrowserThread::PostTask( 730 BrowserThread::PostTask(
719 BrowserThread::FILE, FROM_HERE, 731 BrowserThread::FILE, FROM_HERE,
720 base::Bind(&DeleteInputDebugWriterOnFileThread, 732 base::Bind(&DeleteInputDebugWriterOnFileThread,
721 base::Passed(std::move(entry->input_debug_writer)))); 733 base::Passed(std::move(entry->input_debug_writer))));
722 } 734 }
723 } 735 }
724 #endif // defined(ENABLE_WEBRTC) 736 #endif // defined(ENABLE_WEBRTC)
725 737
726 } // namespace content 738 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698