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

Side by Side Diff: content/renderer/media/webrtc_audio_renderer.cc

Issue 14347002: Adds support for 192kHz native output sample rate for WebRTC clients (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/media/webrtc_audio_renderer.h" 5 #include "content/renderer/media/webrtc_audio_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/renderer/media/audio_device_factory.h" 10 #include "content/renderer/media/audio_device_factory.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 media::ChannelLayout channel_layout = media::CHANNEL_LAYOUT_MONO; 116 media::ChannelLayout channel_layout = media::CHANNEL_LAYOUT_MONO;
117 #if defined(OS_WIN) 117 #if defined(OS_WIN)
118 channel_layout = media::CHANNEL_LAYOUT_STEREO; 118 channel_layout = media::CHANNEL_LAYOUT_STEREO;
119 #endif 119 #endif
120 120
121 // Ask the renderer for the default audio output hardware sample-rate. 121 // Ask the renderer for the default audio output hardware sample-rate.
122 media::AudioHardwareConfig* hardware_config = 122 media::AudioHardwareConfig* hardware_config =
123 RenderThreadImpl::current()->GetAudioHardwareConfig(); 123 RenderThreadImpl::current()->GetAudioHardwareConfig();
124 int sample_rate = hardware_config->GetOutputSampleRate(); 124 int sample_rate = hardware_config->GetOutputSampleRate();
125 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate; 125 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate;
126
127 // WebRTC does not yet support higher rates than 96000 on the client side
128 // and 48000 is the preferred sample rate. Therefore, if 192000 is detected,
129 // we change the rate to 48000 instead. The consequence is that the native
130 // layer will be opened up at 192kHz but WebRTC will provide data at 48kHz
131 // which will then be resampled by the audio converted on the browser side
132 // to match the native audio layer.
133 if (sample_rate == 192000) {
134 DVLOG(1) << "Resampling from 48000 to 192000 is required";
135 sample_rate = 48000;
136 }
126 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate", 137 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate",
127 sample_rate, media::kUnexpectedAudioSampleRate); 138 sample_rate, media::kUnexpectedAudioSampleRate);
128 139
129 // Verify that the reported output hardware sample rate is supported 140 // Verify that the reported output hardware sample rate is supported
130 // on the current platform. 141 // on the current platform.
131 if (std::find(&kValidOutputRates[0], 142 if (std::find(&kValidOutputRates[0],
132 &kValidOutputRates[0] + arraysize(kValidOutputRates), 143 &kValidOutputRates[0] + arraysize(kValidOutputRates),
133 sample_rate) == 144 sample_rate) ==
134 &kValidOutputRates[arraysize(kValidOutputRates)]) { 145 &kValidOutputRates[arraysize(kValidOutputRates)]) {
135 DLOG(ERROR) << sample_rate << " is not a supported output rate."; 146 DLOG(ERROR) << sample_rate << " is not a supported output rate.";
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 354 }
344 355
345 // De-interleave each channel and convert to 32-bit floating-point 356 // De-interleave each channel and convert to 32-bit floating-point
346 // with nominal range -1.0 -> +1.0 to match the callback format. 357 // with nominal range -1.0 -> +1.0 to match the callback format.
347 audio_bus->FromInterleaved(buffer_.get(), 358 audio_bus->FromInterleaved(buffer_.get(),
348 audio_bus->frames(), 359 audio_bus->frames(),
349 sizeof(buffer_[0])); 360 sizeof(buffer_[0]));
350 } 361 }
351 362
352 } // namespace content 363 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698