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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Fix in a unit test. Rebase. Created 3 years, 9 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 update->SetInteger("rid", render_process_id); 496 update->SetInteger("rid", render_process_id);
487 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); 497 SendUpdate("removeGetUserMediaForRenderer", std::move(update));
488 } 498 }
489 } 499 }
490 500
491 #if BUILDFLAG(ENABLE_WEBRTC) 501 #if BUILDFLAG(ENABLE_WEBRTC)
492 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { 502 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() {
493 DCHECK_CURRENTLY_ON(BrowserThread::UI); 503 DCHECK_CURRENTLY_ON(BrowserThread::UI);
494 504
495 audio_debug_recordings_ = true; 505 audio_debug_recordings_ = true;
506
496 for (RenderProcessHost::iterator i( 507 for (RenderProcessHost::iterator i(
497 content::RenderProcessHost::AllHostsIterator()); 508 content::RenderProcessHost::AllHostsIterator());
498 !i.IsAtEnd(); i.Advance()) { 509 !i.IsAtEnd(); i.Advance()) {
499 i.GetCurrentValue()->EnableAudioDebugRecordings( 510 i.GetCurrentValue()->EnableAudioDebugRecordings(
500 audio_debug_recordings_file_path_); 511 audio_debug_recordings_file_path_);
501 } 512 }
513
514 // It's safe to get the AudioManager pointer here. That pointer is invalidated
515 // on the UI thread, which we're on.
516 // AudioManager is deleted on the audio thread, and the AudioManager outlives
517 // this object, so it's safe to post unretained to the audio thread.
518 media::AudioManager* audio_manager = media::AudioManager::Get();
519 audio_manager->GetTaskRunner()->PostTask(
520 FROM_HERE, base::Bind(&media::AudioManager::EnableOutputDebugRecording,
521 base::Unretained(audio_manager),
522 audio_debug_recordings_file_path_));
502 } 523 }
503 524
504 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { 525 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() {
505 DCHECK_CURRENTLY_ON(BrowserThread::UI); 526 DCHECK_CURRENTLY_ON(BrowserThread::UI);
506 527
507 event_log_recordings_ = true; 528 event_log_recordings_ = true;
508 for (RenderProcessHost::iterator i( 529 for (RenderProcessHost::iterator i(
509 content::RenderProcessHost::AllHostsIterator()); 530 content::RenderProcessHost::AllHostsIterator());
510 !i.IsAtEnd(); i.Advance()) 531 !i.IsAtEnd(); i.Advance())
511 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); 532 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 DCHECK_CURRENTLY_ON(BrowserThread::UI); 571 DCHECK_CURRENTLY_ON(BrowserThread::UI);
551 while (!pending_updates_.empty()) { 572 while (!pending_updates_.empty()) {
552 const auto& update = pending_updates_.front(); 573 const auto& update = pending_updates_.front();
553 for (auto& observer : observers_) 574 for (auto& observer : observers_)
554 observer.OnUpdate(update.command(), update.value()); 575 observer.OnUpdate(update.command(), update.value());
555 pending_updates_.pop(); 576 pending_updates_.pop();
556 } 577 }
557 } 578 }
558 579
559 } // namespace content 580 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698