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

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

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
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"
11 #include "content/renderer/media/renderer_audio_output_device.h"
12 #include "content/renderer/media/webrtc_audio_device_impl.h" 11 #include "content/renderer/media/webrtc_audio_device_impl.h"
13 #include "content/renderer/render_thread_impl.h" 12 #include "content/renderer/render_thread_impl.h"
13 #include "media/audio/audio_output_device.h"
14 #include "media/audio/audio_parameters.h" 14 #include "media/audio/audio_parameters.h"
15 #include "media/audio/sample_rates.h" 15 #include "media/audio/sample_rates.h"
16 #include "media/base/audio_hardware_config.h" 16 #include "media/base/audio_hardware_config.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
20 #include "media/audio/win/core_audio_util_win.h" 20 #include "media/audio/win/core_audio_util_win.h"
21 #endif 21 #endif
22 22
23 namespace content { 23 namespace content {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { 105 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
106 DVLOG(1) << "WebRtcAudioRenderer::Initialize()"; 106 DVLOG(1) << "WebRtcAudioRenderer::Initialize()";
107 DCHECK(thread_checker_.CalledOnValidThread()); 107 DCHECK(thread_checker_.CalledOnValidThread());
108 base::AutoLock auto_lock(lock_); 108 base::AutoLock auto_lock(lock_);
109 DCHECK_EQ(state_, UNINITIALIZED); 109 DCHECK_EQ(state_, UNINITIALIZED);
110 DCHECK(source); 110 DCHECK(source);
111 DCHECK(!sink_); 111 DCHECK(!sink_);
112 DCHECK(!source_); 112 DCHECK(!source_);
113 113
114 sink_ = AudioDeviceFactory::NewOutputDevice();
115 DCHECK(sink_);
116
117 // Use mono on all platforms but Windows for now. 114 // Use mono on all platforms but Windows for now.
118 // TODO(henrika): Tracking at http://crbug.com/166771. 115 // TODO(henrika): Tracking at http://crbug.com/166771.
119 media::ChannelLayout channel_layout = media::CHANNEL_LAYOUT_MONO; 116 media::ChannelLayout channel_layout = media::CHANNEL_LAYOUT_MONO;
120 #if defined(OS_WIN) 117 #if defined(OS_WIN)
121 channel_layout = media::CHANNEL_LAYOUT_STEREO; 118 channel_layout = media::CHANNEL_LAYOUT_STEREO;
122 #endif 119 #endif
123 120
124 // Ask the renderer for the default audio output hardware sample-rate. 121 // Ask the renderer for the default audio output hardware sample-rate.
125 media::AudioHardwareConfig* hardware_config = 122 media::AudioHardwareConfig* hardware_config =
126 RenderThreadImpl::current()->GetAudioHardwareConfig(); 123 RenderThreadImpl::current()->GetAudioHardwareConfig();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // It is assumed that each audio sample contains 16 bits and each 198 // It is assumed that each audio sample contains 16 bits and each
202 // audio frame contains one or two audio samples depending on the 199 // audio frame contains one or two audio samples depending on the
203 // number of channels. 200 // number of channels.
204 buffer_.reset( 201 buffer_.reset(
205 new int16[source_params.frames_per_buffer() * source_params.channels()]); 202 new int16[source_params.frames_per_buffer() * source_params.channels()]);
206 203
207 source_ = source; 204 source_ = source;
208 source->SetRenderFormat(source_params); 205 source->SetRenderFormat(source_params);
209 206
210 // Configure the audio rendering client and start rendering. 207 // Configure the audio rendering client and start rendering.
208 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_view_id_);
211 sink_->Initialize(sink_params, this); 209 sink_->Initialize(sink_params, this);
212 sink_->SetSourceRenderView(source_render_view_id_);
213 sink_->Start(); 210 sink_->Start();
214 211
215 // User must call Play() before any audio can be heard. 212 // User must call Play() before any audio can be heard.
216 state_ = PAUSED; 213 state_ = PAUSED;
217 214
218 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", 215 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout",
219 source_params.channel_layout(), 216 source_params.channel_layout(),
220 media::CHANNEL_LAYOUT_MAX); 217 media::CHANNEL_LAYOUT_MAX);
221 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", 218 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer",
222 source_params.frames_per_buffer(), 219 source_params.frames_per_buffer(),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 343 }
347 344
348 // De-interleave each channel and convert to 32-bit floating-point 345 // De-interleave each channel and convert to 32-bit floating-point
349 // with nominal range -1.0 -> +1.0 to match the callback format. 346 // with nominal range -1.0 -> +1.0 to match the callback format.
350 audio_bus->FromInterleaved(buffer_.get(), 347 audio_bus->FromInterleaved(buffer_.get(),
351 audio_bus->frames(), 348 audio_bus->frames(),
352 sizeof(buffer_[0])); 349 sizeof(buffer_[0]));
353 } 350 }
354 351
355 } // namespace content 352 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_renderer.h ('k') | content/renderer/media/webrtc_local_audio_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698