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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review (dalecurtis@ and maxmorin@). Created 3 years, 11 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 // AudioManager is deleted on the audio thread, and the AudioManager outlives
336 // this object, so it's safe to post unretained.
337 media::AudioManager* audio_manager = media::AudioManager::Get();
338 audio_manager->GetTaskRunner()->PostTask(
339 FROM_HERE, base::Bind(&media::AudioManager::DisableOutputDebugRecording,
340 base::Unretained(audio_manager)));
333 #endif 341 #endif
334 } 342 }
335 343
336 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { 344 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const {
337 DCHECK_CURRENTLY_ON(BrowserThread::UI); 345 DCHECK_CURRENTLY_ON(BrowserThread::UI);
338 return audio_debug_recordings_; 346 return audio_debug_recordings_;
339 } 347 }
340 348
341 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { 349 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const {
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); 350 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 update->SetInteger("rid", render_process_id); 492 update->SetInteger("rid", render_process_id);
485 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); 493 SendUpdate("removeGetUserMediaForRenderer", std::move(update));
486 } 494 }
487 } 495 }
488 496
489 #if BUILDFLAG(ENABLE_WEBRTC) 497 #if BUILDFLAG(ENABLE_WEBRTC)
490 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { 498 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() {
491 DCHECK_CURRENTLY_ON(BrowserThread::UI); 499 DCHECK_CURRENTLY_ON(BrowserThread::UI);
492 500
493 audio_debug_recordings_ = true; 501 audio_debug_recordings_ = true;
502
494 for (RenderProcessHost::iterator i( 503 for (RenderProcessHost::iterator i(
495 content::RenderProcessHost::AllHostsIterator()); 504 content::RenderProcessHost::AllHostsIterator());
496 !i.IsAtEnd(); i.Advance()) { 505 !i.IsAtEnd(); i.Advance()) {
497 i.GetCurrentValue()->EnableAudioDebugRecordings( 506 i.GetCurrentValue()->EnableAudioDebugRecordings(
498 audio_debug_recordings_file_path_); 507 audio_debug_recordings_file_path_);
499 } 508 }
509
510 // AudioManager is deleted on the audio thread, and the AudioManager outlives
511 // this object, so it's safe to post unretained.
512 media::AudioManager* audio_manager = media::AudioManager::Get();
513 audio_manager->GetTaskRunner()->PostTask(
514 FROM_HERE, base::Bind(&media::AudioManager::EnableOutputDebugRecording,
515 base::Unretained(audio_manager),
516 audio_debug_recordings_file_path_));
500 } 517 }
501 518
502 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { 519 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() {
503 DCHECK_CURRENTLY_ON(BrowserThread::UI); 520 DCHECK_CURRENTLY_ON(BrowserThread::UI);
504 521
505 event_log_recordings_ = true; 522 event_log_recordings_ = true;
506 for (RenderProcessHost::iterator i( 523 for (RenderProcessHost::iterator i(
507 content::RenderProcessHost::AllHostsIterator()); 524 content::RenderProcessHost::AllHostsIterator());
508 !i.IsAtEnd(); i.Advance()) 525 !i.IsAtEnd(); i.Advance())
509 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); 526 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); 565 DCHECK_CURRENTLY_ON(BrowserThread::UI);
549 while (!pending_updates_.empty()) { 566 while (!pending_updates_.empty()) {
550 const auto& update = pending_updates_.front(); 567 const auto& update = pending_updates_.front();
551 for (auto& observer : observers_) 568 for (auto& observer : observers_)
552 observer.OnUpdate(update.command(), update.value()); 569 observer.OnUpdate(update.command(), update.value());
553 pending_updates_.pop(); 570 pending_updates_.pop();
554 } 571 }
555 } 572 }
556 573
557 } // namespace content 574 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698