OLD | NEW |
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_local_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "content/renderer/media/audio_device_factory.h" | 11 #include "content/renderer/media/audio_device_factory.h" |
12 #include "content/renderer/media/renderer_audio_output_device.h" | |
13 #include "content/renderer/media/webrtc_audio_capturer.h" | 12 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 13 #include "media/audio/audio_output_device.h" |
14 #include "media/base/audio_bus.h" | 14 #include "media/base/audio_bus.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 // media::AudioRendererSink::RenderCallback implementation | 18 // media::AudioRendererSink::RenderCallback implementation |
19 int WebRtcLocalAudioRenderer::Render( | 19 int WebRtcLocalAudioRenderer::Render( |
20 media::AudioBus* audio_bus, int audio_delay_milliseconds) { | 20 media::AudioBus* audio_bus, int audio_delay_milliseconds) { |
21 base::AutoLock auto_lock(thread_lock_); | 21 base::AutoLock auto_lock(thread_lock_); |
22 | 22 |
23 if (!playing_) { | 23 if (!playing_) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 DCHECK(!loopback_fifo_); | 151 DCHECK(!loopback_fifo_); |
152 loopback_fifo_.reset(new media::AudioFifo( | 152 loopback_fifo_.reset(new media::AudioFifo( |
153 source_params.channels(), | 153 source_params.channels(), |
154 10 * source_params.frames_per_buffer())); | 154 10 * source_params.frames_per_buffer())); |
155 | 155 |
156 media::AudioParameters sink_params(source_params.format(), | 156 media::AudioParameters sink_params(source_params.format(), |
157 source_params.channel_layout(), | 157 source_params.channel_layout(), |
158 source_params.sample_rate(), | 158 source_params.sample_rate(), |
159 source_params.bits_per_sample(), | 159 source_params.bits_per_sample(), |
160 2 * source_params.frames_per_buffer()); | 160 2 * source_params.frames_per_buffer()); |
161 sink_ = AudioDeviceFactory::NewOutputDevice(); | 161 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_view_id_); |
162 // TODO(henrika): we could utilize the unified audio here instead and do | 162 // TODO(henrika): we could utilize the unified audio here instead and do |
163 // sink_->InitializeIO(sink_params, 2, callback_.get()); | 163 // sink_->InitializeIO(sink_params, 2, callback_.get()); |
164 // It would then be possible to avoid using the WebRtcAudioCapturer. | 164 // It would then be possible to avoid using the WebRtcAudioCapturer. |
165 sink_->Initialize(sink_params, this); | 165 sink_->Initialize(sink_params, this); |
166 sink_->SetSourceRenderView(source_render_view_id_); | |
167 | 166 |
168 // Start the capturer and local rendering. Note that, the capturer is owned | 167 // Start the capturer and local rendering. Note that, the capturer is owned |
169 // by the WebRTC ADM and might already bee running. | 168 // by the WebRTC ADM and might already bee running. |
170 source_->Start(); | 169 source_->Start(); |
171 sink_->Start(); | 170 sink_->Start(); |
172 | 171 |
173 last_render_time_ = base::Time::Now(); | 172 last_render_time_ = base::Time::Now(); |
174 playing_ = false; | 173 playing_ = false; |
175 } | 174 } |
176 | 175 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (!sink_) | 251 if (!sink_) |
253 return base::TimeDelta(); | 252 return base::TimeDelta(); |
254 return total_render_time(); | 253 return total_render_time(); |
255 } | 254 } |
256 | 255 |
257 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const { | 256 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const { |
258 return true; | 257 return true; |
259 } | 258 } |
260 | 259 |
261 } // namespace content | 260 } // namespace content |
OLD | NEW |