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

Side by Side Diff: content/browser/webrtc/webrtc_internals.cc

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/webrtc/webrtc_internals.h" 5 #include "content/browser/webrtc/webrtc_internals.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/browser/renderer_host/render_process_host_impl.h" 14 #include "content/browser/renderer_host/render_process_host_impl.h"
15 #include "content/browser/web_contents/web_contents_view.h" 15 #include "content/browser/web_contents/web_contents_view.h"
16 #include "content/browser/webrtc/webrtc_internals_ui_observer.h" 16 #include "content/browser/webrtc/webrtc_internals_ui_observer.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "device/power_save_blocker/power_save_blocker.h" 20 #include "device/power_save_blocker/power_save_blocker.h"
21 #include "ipc/ipc_platform_file.h" 21 #include "ipc/ipc_platform_file.h"
22 #include "media/audio/audio_manager.h"
22 #include "media/media_features.h" 23 #include "media/media_features.h"
23 24
24 #if defined(OS_WIN) 25 #if defined(OS_WIN)
25 #define IntToStringType base::IntToString16 26 #define IntToStringType base::IntToString16
26 #else 27 #else
27 #define IntToStringType base::IntToString 28 #define IntToStringType base::IntToString
28 #endif 29 #endif
29 30
30 using base::ProcessId; 31 using base::ProcessId;
31 using std::string; 32 using std::string;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #endif 317 #endif
317 } 318 }
318 319
319 void WebRTCInternals::DisableAudioDebugRecordings() { 320 void WebRTCInternals::DisableAudioDebugRecordings() {
320 DCHECK_CURRENTLY_ON(BrowserThread::UI); 321 DCHECK_CURRENTLY_ON(BrowserThread::UI);
321 #if BUILDFLAG(ENABLE_WEBRTC) 322 #if BUILDFLAG(ENABLE_WEBRTC)
322 audio_debug_recordings_ = false; 323 audio_debug_recordings_ = false;
323 324
324 // Tear down the dialog since the user has unchecked the audio debug 325 // Tear down the dialog since the user has unchecked the audio debug
325 // recordings box. 326 // recordings box.
326 select_file_dialog_ = NULL; 327 select_file_dialog_ = nullptr;
327 328
328 for (RenderProcessHost::iterator i( 329 for (RenderProcessHost::iterator i(
329 content::RenderProcessHost::AllHostsIterator()); 330 content::RenderProcessHost::AllHostsIterator());
330 !i.IsAtEnd(); i.Advance()) { 331 !i.IsAtEnd(); i.Advance()) {
331 i.GetCurrentValue()->DisableAudioDebugRecordings(); 332 i.GetCurrentValue()->DisableAudioDebugRecordings();
332 } 333 }
334
335 // It's safe to get the AudioManager pointer here. That pointer is invalidated
336 // on the UI thread, which we're on.
337 // AudioManager is deleted on the audio thread, and the AudioManager outlives
338 // this object, so it's safe to post unretained to the audio thread.
339 media::AudioManager* audio_manager = media::AudioManager::Get();
340 audio_manager->GetTaskRunner()->PostTask(
341 FROM_HERE, base::Bind(&media::AudioManager::DisableOutputDebugRecording,
342 base::Unretained(audio_manager)));
333 #endif 343 #endif
334 } 344 }
335 345
336 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { 346 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const {
337 DCHECK_CURRENTLY_ON(BrowserThread::UI); 347 DCHECK_CURRENTLY_ON(BrowserThread::UI);
338 return audio_debug_recordings_; 348 return audio_debug_recordings_;
339 } 349 }
340 350
341 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { 351 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const {
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); 352 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 update->SetInteger("rid", render_process_id); 494 update->SetInteger("rid", render_process_id);
485 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); 495 SendUpdate("removeGetUserMediaForRenderer", std::move(update));
486 } 496 }
487 } 497 }
488 498
489 #if BUILDFLAG(ENABLE_WEBRTC) 499 #if BUILDFLAG(ENABLE_WEBRTC)
490 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { 500 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() {
491 DCHECK_CURRENTLY_ON(BrowserThread::UI); 501 DCHECK_CURRENTLY_ON(BrowserThread::UI);
492 502
493 audio_debug_recordings_ = true; 503 audio_debug_recordings_ = true;
504
494 for (RenderProcessHost::iterator i( 505 for (RenderProcessHost::iterator i(
495 content::RenderProcessHost::AllHostsIterator()); 506 content::RenderProcessHost::AllHostsIterator());
496 !i.IsAtEnd(); i.Advance()) { 507 !i.IsAtEnd(); i.Advance()) {
497 i.GetCurrentValue()->EnableAudioDebugRecordings( 508 i.GetCurrentValue()->EnableAudioDebugRecordings(
498 audio_debug_recordings_file_path_); 509 audio_debug_recordings_file_path_);
499 } 510 }
511
512 // It's safe to get the AudioManager pointer here. That pointer is invalidated
513 // on the UI thread, which we're on.
514 // AudioManager is deleted on the audio thread, and the AudioManager outlives
515 // this object, so it's safe to post unretained to the audio thread.
516 media::AudioManager* audio_manager = media::AudioManager::Get();
517 audio_manager->GetTaskRunner()->PostTask(
518 FROM_HERE, base::Bind(&media::AudioManager::EnableOutputDebugRecording,
519 base::Unretained(audio_manager),
520 audio_debug_recordings_file_path_));
500 } 521 }
501 522
502 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { 523 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() {
503 DCHECK_CURRENTLY_ON(BrowserThread::UI); 524 DCHECK_CURRENTLY_ON(BrowserThread::UI);
504 525
505 event_log_recordings_ = true; 526 event_log_recordings_ = true;
506 for (RenderProcessHost::iterator i( 527 for (RenderProcessHost::iterator i(
507 content::RenderProcessHost::AllHostsIterator()); 528 content::RenderProcessHost::AllHostsIterator());
508 !i.IsAtEnd(); i.Advance()) 529 !i.IsAtEnd(); i.Advance())
509 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); 530 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 DCHECK_CURRENTLY_ON(BrowserThread::UI); 569 DCHECK_CURRENTLY_ON(BrowserThread::UI);
549 while (!pending_updates_.empty()) { 570 while (!pending_updates_.empty()) {
550 const auto& update = pending_updates_.front(); 571 const auto& update = pending_updates_.front();
551 for (auto& observer : observers_) 572 for (auto& observer : observers_)
552 observer.OnUpdate(update.command(), update.value()); 573 observer.OnUpdate(update.command(), update.value());
553 pending_updates_.pop(); 574 pending_updates_.pop();
554 } 575 }
555 } 576 }
556 577
557 } // namespace content 578 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698