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

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

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 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 | Annotate | Revision Log
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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 15 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
16 #include "content/browser/renderer_host/media/media_stream_requester.h" 16 #include "content/browser/renderer_host/media/media_stream_requester.h"
17 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" 17 #include "content/browser/renderer_host/media/media_stream_ui_controller.h"
18 #include "content/browser/renderer_host/media/video_capture_manager.h" 18 #include "content/browser/renderer_host/media/video_capture_manager.h"
19 #include "content/browser/renderer_host/media/web_contents_capture_util.h" 19 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/media_observer.h" 22 #include "content/public/browser/media_observer.h"
23 #include "content/public/browser/media_request_state.h" 23 #include "content/public/browser/media_request_state.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/media_stream_request.h" 25 #include "content/public/common/media_stream_request.h"
26 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
27 #include "media/audio/audio_manager_base.h" 27 #include "media/audio/audio_manager_base.h"
28 #include "media/audio/audio_util.h" 28 #include "media/audio/audio_parameters.h"
29 #include "media/base/channel_layout.h" 29 #include "media/base/channel_layout.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "base/win/scoped_com_initializer.h" 32 #include "base/win/scoped_com_initializer.h"
33 #endif 33 #endif
34 34
35 namespace content { 35 namespace content {
36 36
37 // Creates a random label used to identify requests. 37 // Creates a random label used to identify requests.
38 static std::string RandomLabel() { 38 static std::string RandomLabel() {
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 // TODO(justinlin): Nicer way to do this? 845 // TODO(justinlin): Nicer way to do this?
846 // Re-append the device's id since we lost it when posting request to UI. 846 // Re-append the device's id since we lost it when posting request to UI.
847 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE || 847 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE ||
848 device_info.device.type == content::MEDIA_TAB_AUDIO_CAPTURE) { 848 device_info.device.type == content::MEDIA_TAB_AUDIO_CAPTURE) {
849 device_info.device.id = request->requested_device_id; 849 device_info.device.id = request->requested_device_id;
850 850
851 // Initialize the sample_rate and channel_layout here since for audio 851 // Initialize the sample_rate and channel_layout here since for audio
852 // mirroring, we don't go through EnumerateDevices where these are usually 852 // mirroring, we don't go through EnumerateDevices where these are usually
853 // initialized. 853 // initialized.
854 if (device_info.device.type == content::MEDIA_TAB_AUDIO_CAPTURE) { 854 if (device_info.device.type == content::MEDIA_TAB_AUDIO_CAPTURE) {
855 int sample_rate = media::GetAudioHardwareSampleRate(); 855 const media::AudioParameters parameters =
856 audio_manager_->GetDefaultOutputStreamParameters();
857 int sample_rate = parameters.sample_rate();
856 // If we weren't able to get the native sampling rate, it most likely 858 // If we weren't able to get the native sampling rate, it most likely
857 // means the system did not have an output device, but for mirroring we 859 // means the system did not have an output device, but for mirroring we
858 // still want to startup the audio engine, so set reasonable defaults. 860 // still want to startup the audio engine, so set reasonable defaults.
859 if (sample_rate == 0) 861 if (sample_rate == 0)
860 sample_rate = 44100; 862 sample_rate = 44100;
861 863
862 device_info.device.sample_rate = sample_rate; 864 device_info.device.sample_rate = sample_rate;
863 device_info.device.channel_layout = media::CHANNEL_LAYOUT_STEREO; 865 device_info.device.channel_layout = media::CHANNEL_LAYOUT_STEREO;
864 } 866 }
865 } 867 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1078 }
1077 1079
1078 // Always do enumeration even though some enumeration is in progress, 1080 // Always do enumeration even though some enumeration is in progress,
1079 // because those enumeration commands could be sent before these devices 1081 // because those enumeration commands could be sent before these devices
1080 // change. 1082 // change.
1081 ++active_enumeration_ref_count_[stream_type]; 1083 ++active_enumeration_ref_count_[stream_type];
1082 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 1084 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
1083 } 1085 }
1084 1086
1085 } // namespace content 1087 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698