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

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.h

Issue 10537121: Adds AudioDevice factory for all audio clients in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed DVLOGs Created 8 years, 6 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 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop_proxy.h" 16 #include "base/message_loop_proxy.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/renderer/media/audio_device.h"
20 #include "content/renderer/media/audio_input_device.h" 19 #include "content/renderer/media/audio_input_device.h"
20 #include "media/base/audio_renderer_sink.h"
21 #include "third_party/webrtc/modules/audio_device/main/interface/audio_device.h" 21 #include "third_party/webrtc/modules/audio_device/main/interface/audio_device.h"
22 22
23 class AudioDeviceFactoryInterface;
24
23 // A WebRtcAudioDeviceImpl instance implements the abstract interface 25 // A WebRtcAudioDeviceImpl instance implements the abstract interface
24 // webrtc::AudioDeviceModule which makes it possible for a user (e.g. webrtc:: 26 // webrtc::AudioDeviceModule which makes it possible for a user (e.g. webrtc::
25 // VoiceEngine) to register this class as an external AudioDeviceModule (ADM). 27 // VoiceEngine) to register this class as an external AudioDeviceModule (ADM).
26 // Then WebRtcAudioDeviceImpl::SetSessionId() needs to be called to set the 28 // Then WebRtcAudioDeviceImpl::SetSessionId() needs to be called to set the
27 // session id that tells which device to use. The user can either get the 29 // session id that tells which device to use. The user can either get the
28 // session id from the MediaStream or use a value of 1 (AudioInputDeviceManager 30 // session id from the MediaStream or use a value of 1 (AudioInputDeviceManager
29 // ::kFakeOpenSessionId), the later will open the default device without going 31 // ::kFakeOpenSessionId), the later will open the default device without going
30 // through the MediaStream. The user can then call WebRtcAudioDeviceImpl:: 32 // through the MediaStream. The user can then call WebRtcAudioDeviceImpl::
31 // StartPlayout() and WebRtcAudioDeviceImpl::StartRecording() from the render 33 // StartPlayout() and WebRtcAudioDeviceImpl::StartRecording() from the render
32 // process to initiate and start audio rendering and capturing in the browser 34 // process to initiate and start audio rendering and capturing in the browser
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // (WebRTC client a media layer). This approach ensures that we can avoid 204 // (WebRTC client a media layer). This approach ensures that we can avoid
203 // transferring maximum levels between the renderer and the browser. 205 // transferring maximum levels between the renderer and the browser.
204 // 206 //
205 class CONTENT_EXPORT WebRtcAudioDeviceImpl 207 class CONTENT_EXPORT WebRtcAudioDeviceImpl
206 : NON_EXPORTED_BASE(public webrtc::AudioDeviceModule), 208 : NON_EXPORTED_BASE(public webrtc::AudioDeviceModule),
207 public media::AudioRendererSink::RenderCallback, 209 public media::AudioRendererSink::RenderCallback,
208 public AudioInputDevice::CaptureCallback, 210 public AudioInputDevice::CaptureCallback,
209 public AudioInputDevice::CaptureEventHandler { 211 public AudioInputDevice::CaptureEventHandler {
210 public: 212 public:
211 // Methods called on main render thread. 213 // Methods called on main render thread.
212 WebRtcAudioDeviceImpl(); 214 WebRtcAudioDeviceImpl(AudioDeviceFactoryInterface* audio_device_factory);
213 215
214 // webrtc::RefCountedModule implementation. 216 // webrtc::RefCountedModule implementation.
215 // The creator must call AddRef() after construction and use Release() 217 // The creator must call AddRef() after construction and use Release()
216 // to release the reference and delete this object. 218 // to release the reference and delete this object.
217 virtual int32_t AddRef() OVERRIDE; 219 virtual int32_t AddRef() OVERRIDE;
218 virtual int32_t Release() OVERRIDE; 220 virtual int32_t Release() OVERRIDE;
219 221
220 // We need this one to support runnable method tasks. 222 // We need this one to support runnable method tasks.
221 static bool ImplementsThreadSafeReferenceCounting() { return true; } 223 static bool ImplementsThreadSafeReferenceCounting() { return true; }
222 224
223 // AudioDevice::RenderCallback implementation. 225 // media::AudioRendererSink::RenderCallback implementation.
224 virtual int Render(const std::vector<float*>& audio_data, 226 virtual int Render(const std::vector<float*>& audio_data,
225 int number_of_frames, 227 int number_of_frames,
226 int audio_delay_milliseconds) OVERRIDE; 228 int audio_delay_milliseconds) OVERRIDE;
227 virtual void OnRenderError() OVERRIDE; 229 virtual void OnRenderError() OVERRIDE;
228 230
229 // AudioInputDevice::CaptureCallback implementation. 231 // AudioInputDevice::CaptureCallback implementation.
230 virtual void Capture(const std::vector<float*>& audio_data, 232 virtual void Capture(const std::vector<float*>& audio_data,
231 int number_of_frames, 233 int number_of_frames,
232 int audio_delay_milliseconds, 234 int audio_delay_milliseconds,
233 double volume) OVERRIDE; 235 double volume) OVERRIDE;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 int ref_count_; 402 int ref_count_;
401 403
402 // Gives access to the message loop of the render thread on which this 404 // Gives access to the message loop of the render thread on which this
403 // object is created. 405 // object is created.
404 scoped_refptr<base::MessageLoopProxy> render_loop_; 406 scoped_refptr<base::MessageLoopProxy> render_loop_;
405 407
406 // Provides access to the native audio input layer in the browser process. 408 // Provides access to the native audio input layer in the browser process.
407 scoped_refptr<AudioInputDevice> audio_input_device_; 409 scoped_refptr<AudioInputDevice> audio_input_device_;
408 410
409 // Provides access to the native audio output layer in the browser process. 411 // Provides access to the native audio output layer in the browser process.
410 scoped_refptr<AudioDevice> audio_output_device_; 412 scoped_refptr<media::AudioRendererSink> audio_output_device_;
411 413
412 // Weak reference to the audio callback. 414 // Weak reference to the audio callback.
413 // The webrtc client defines |audio_transport_callback_| by calling 415 // The webrtc client defines |audio_transport_callback_| by calling
414 // RegisterAudioCallback(). 416 // RegisterAudioCallback().
415 webrtc::AudioTransport* audio_transport_callback_; 417 webrtc::AudioTransport* audio_transport_callback_;
416 418
417 // Cached values of utilized audio parameters. Platform dependent. 419 // Cached values of utilized audio parameters. Platform dependent.
418 media::AudioParameters input_audio_parameters_; 420 media::AudioParameters input_audio_parameters_;
419 media::AudioParameters output_audio_parameters_; 421 media::AudioParameters output_audio_parameters_;
420 422
(...skipping 29 matching lines...) Expand all
450 bool agc_is_enabled_; 452 bool agc_is_enabled_;
451 453
452 // Used for histograms of total recording and playout times. 454 // Used for histograms of total recording and playout times.
453 base::Time start_capture_time_; 455 base::Time start_capture_time_;
454 base::Time start_render_time_; 456 base::Time start_render_time_;
455 457
456 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); 458 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl);
457 }; 459 };
458 460
459 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 461 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698