| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // (*) Using SyncSocket for inter-process synchronization with low latency. | 84 // (*) Using SyncSocket for inter-process synchronization with low latency. |
| 85 // The actual data is transferred via SharedMemory. IPC is not involved | 85 // The actual data is transferred via SharedMemory. IPC is not involved |
| 86 // in the actual media transfer. | 86 // in the actual media transfer. |
| 87 // | 87 // |
| 88 // Implementation notes: | 88 // Implementation notes: |
| 89 // | 89 // |
| 90 // - This class must be created on the main render thread. | 90 // - This class must be created on the main render thread. |
| 91 // - The webrtc::AudioDeviceModule is reference counted. | 91 // - The webrtc::AudioDeviceModule is reference counted. |
| 92 // - Recording is currently not supported on Mac OS X. | 92 // - Recording is currently not supported on Mac OS X. |
| 93 // | 93 // |
| 94 class WebRtcAudioDeviceImpl | 94 class CONTENT_EXPORT WebRtcAudioDeviceImpl |
| 95 : public webrtc::AudioDeviceModule, | 95 : public webrtc::AudioDeviceModule, |
| 96 public AudioDevice::RenderCallback, | 96 public AudioDevice::RenderCallback, |
| 97 public AudioInputDevice::CaptureCallback, | 97 public AudioInputDevice::CaptureCallback, |
| 98 public AudioInputDevice::CaptureEventHandler { | 98 public AudioInputDevice::CaptureEventHandler { |
| 99 public: | 99 public: |
| 100 // Methods called on main render thread. | 100 // Methods called on main render thread. |
| 101 CONTENT_EXPORT WebRtcAudioDeviceImpl(); | 101 WebRtcAudioDeviceImpl(); |
| 102 | 102 |
| 103 // webrtc::RefCountedModule implementation. | 103 // webrtc::RefCountedModule implementation. |
| 104 // The creator must call AddRef() after construction and use Release() | 104 // The creator must call AddRef() after construction and use Release() |
| 105 // to release the reference and delete this object. | 105 // to release the reference and delete this object. |
| 106 virtual int32_t AddRef() OVERRIDE; | 106 virtual int32_t AddRef() OVERRIDE; |
| 107 virtual int32_t Release() OVERRIDE; | 107 virtual int32_t Release() OVERRIDE; |
| 108 | 108 |
| 109 // We need this one to support runnable method tasks. | 109 // We need this one to support runnable method tasks. |
| 110 static bool ImplementsThreadSafeReferenceCounting() { return true; } | 110 static bool ImplementsThreadSafeReferenceCounting() { return true; } |
| 111 | 111 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 const uint32_t samples_per_sec) OVERRIDE; | 243 const uint32_t samples_per_sec) OVERRIDE; |
| 244 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 244 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
| 245 virtual int32_t SetPlayoutSampleRate(const uint32_t samples_per_sec) OVERRIDE; | 245 virtual int32_t SetPlayoutSampleRate(const uint32_t samples_per_sec) OVERRIDE; |
| 246 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 246 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
| 247 | 247 |
| 248 virtual int32_t ResetAudioDevice() OVERRIDE; | 248 virtual int32_t ResetAudioDevice() OVERRIDE; |
| 249 virtual int32_t SetLoudspeakerStatus(bool enable) OVERRIDE; | 249 virtual int32_t SetLoudspeakerStatus(bool enable) OVERRIDE; |
| 250 virtual int32_t GetLoudspeakerStatus(bool* enabled) const OVERRIDE; | 250 virtual int32_t GetLoudspeakerStatus(bool* enabled) const OVERRIDE; |
| 251 | 251 |
| 252 // Sets the session id. | 252 // Sets the session id. |
| 253 CONTENT_EXPORT void SetSessionId(int session_id); | 253 void SetSessionId(int session_id); |
| 254 | 254 |
| 255 // Accessors. | 255 // Accessors. |
| 256 size_t input_buffer_size() const { return input_buffer_size_; } | 256 size_t input_buffer_size() const { return input_buffer_size_; } |
| 257 size_t output_buffer_size() const { return output_buffer_size_; } | 257 size_t output_buffer_size() const { return output_buffer_size_; } |
| 258 int input_channels() const { return input_channels_; } | 258 int input_channels() const { return input_channels_; } |
| 259 int output_channels() const { return output_channels_; } | 259 int output_channels() const { return output_channels_; } |
| 260 int input_sample_rate() const { return static_cast<int>(input_sample_rate_); } |
| 261 int output_sample_rate() const { |
| 262 return static_cast<int>(output_sample_rate_); |
| 263 } |
| 264 int input_delay_ms() const { return input_delay_ms_; } |
| 265 int output_delay_ms() const { return output_delay_ms_; } |
| 266 bool initialized() const { return initialized_; } |
| 267 bool playing() const { return playing_; } |
| 268 bool recording() const { return recording_; } |
| 260 | 269 |
| 261 private: | 270 private: |
| 262 // Make destructor private to ensure that we can only be deleted by Release(). | 271 // Make destructor private to ensure that we can only be deleted by Release(). |
| 263 virtual ~WebRtcAudioDeviceImpl(); | 272 virtual ~WebRtcAudioDeviceImpl(); |
| 264 | 273 |
| 265 // Methods called on the main render thread ---------------------------------- | 274 // Methods called on the main render thread ---------------------------------- |
| 266 // The following methods are tasks posted on the render thread that needs to | 275 // The following methods are tasks posted on the render thread that needs to |
| 267 // be executed on that thread. | 276 // be executed on that thread. |
| 268 void InitOnRenderThread(int32_t* error, base::WaitableEvent* event); | 277 void InitOnRenderThread(int32_t* error, base::WaitableEvent* event); |
| 269 | 278 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 scoped_array<int16> output_buffer_; | 313 scoped_array<int16> output_buffer_; |
| 305 | 314 |
| 306 webrtc::AudioDeviceModule::ErrorCode last_error_; | 315 webrtc::AudioDeviceModule::ErrorCode last_error_; |
| 307 | 316 |
| 308 base::TimeTicks last_process_time_; | 317 base::TimeTicks last_process_time_; |
| 309 | 318 |
| 310 // Id of the media session to be started, it tells which device to be used | 319 // Id of the media session to be started, it tells which device to be used |
| 311 // on the input/capture side. | 320 // on the input/capture side. |
| 312 int session_id_; | 321 int session_id_; |
| 313 | 322 |
| 314 // Protect |recording_|. | 323 // Protects |recording_|. |
| 315 base::Lock lock_; | 324 base::Lock lock_; |
| 316 | 325 |
| 317 int bytes_per_sample_; | 326 int bytes_per_sample_; |
| 318 | 327 |
| 319 bool initialized_; | 328 bool initialized_; |
| 320 bool playing_; | 329 bool playing_; |
| 321 bool recording_; | 330 bool recording_; |
| 322 | 331 |
| 323 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 332 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
| 324 }; | 333 }; |
| 325 | 334 |
| 326 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 335 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
| OLD | NEW |