| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCAL_AUDIO_SOURCE_PROVIDER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "media/base/audio_converter.h" | 13 #include "media/base/audio_converter.h" |
| 14 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" | 14 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" | 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 class AudioBus; | 18 class AudioBus; |
| 19 class AudioConverter; | 19 class AudioConverter; |
| 20 class AudioFifo; | 20 class AudioFifo; |
| 21 class AudioParameters; | 21 class AudioParameters; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace WebKit { | 24 namespace blink { |
| 25 class WebAudioSourceProviderClient; | 25 class WebAudioSourceProviderClient; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 // WebRtcLocalAudioSourceProvider provides a bridge between classes: | 30 // WebRtcLocalAudioSourceProvider provides a bridge between classes: |
| 31 // WebRtcAudioCapturer ---> WebKit::WebAudioSourceProvider | 31 // WebRtcAudioCapturer ---> blink::WebAudioSourceProvider |
| 32 // | 32 // |
| 33 // WebRtcLocalAudioSourceProvider works as a sink to the WebRtcAudiocapturer | 33 // WebRtcLocalAudioSourceProvider works as a sink to the WebRtcAudiocapturer |
| 34 // and store the capture data to a FIFO. When the media stream is connected to | 34 // and store the capture data to a FIFO. When the media stream is connected to |
| 35 // WebAudio as a source provider, WebAudio will periodically call | 35 // WebAudio as a source provider, WebAudio will periodically call |
| 36 // provideInput() to get the data from the FIFO. | 36 // provideInput() to get the data from the FIFO. |
| 37 // | 37 // |
| 38 // All calls are protected by a lock. | 38 // All calls are protected by a lock. |
| 39 class CONTENT_EXPORT WebRtcLocalAudioSourceProvider | 39 class CONTENT_EXPORT WebRtcLocalAudioSourceProvider |
| 40 : NON_EXPORTED_BASE(public media::AudioConverter::InputCallback), | 40 : NON_EXPORTED_BASE(public media::AudioConverter::InputCallback), |
| 41 NON_EXPORTED_BASE(public WebKit::WebAudioSourceProvider) { | 41 NON_EXPORTED_BASE(public blink::WebAudioSourceProvider) { |
| 42 public: | 42 public: |
| 43 static const size_t kWebAudioRenderBufferSize; | 43 static const size_t kWebAudioRenderBufferSize; |
| 44 | 44 |
| 45 WebRtcLocalAudioSourceProvider(); | 45 WebRtcLocalAudioSourceProvider(); |
| 46 virtual ~WebRtcLocalAudioSourceProvider(); | 46 virtual ~WebRtcLocalAudioSourceProvider(); |
| 47 | 47 |
| 48 // Initialize function for the souce provider. This can be called multiple | 48 // Initialize function for the souce provider. This can be called multiple |
| 49 // times if the source format has changed. | 49 // times if the source format has changed. |
| 50 void Initialize(const media::AudioParameters& source_params); | 50 void Initialize(const media::AudioParameters& source_params); |
| 51 | 51 |
| 52 // Called by the WebRtcAudioCapturer to deliever captured data into fifo on | 52 // Called by the WebRtcAudioCapturer to deliever captured data into fifo on |
| 53 // the capture audio thread. | 53 // the capture audio thread. |
| 54 void DeliverData(media::AudioBus* audio_source, | 54 void DeliverData(media::AudioBus* audio_source, |
| 55 int audio_delay_milliseconds, | 55 int audio_delay_milliseconds, |
| 56 int volume, | 56 int volume, |
| 57 bool key_pressed); | 57 bool key_pressed); |
| 58 | 58 |
| 59 // Called by the WebAudioCapturerSource to get the audio processing params. | 59 // Called by the WebAudioCapturerSource to get the audio processing params. |
| 60 // This function is triggered by provideInput() on the WebAudio audio thread, | 60 // This function is triggered by provideInput() on the WebAudio audio thread, |
| 61 // so it has been under the protection of |lock_|. | 61 // so it has been under the protection of |lock_|. |
| 62 void GetAudioProcessingParams(int* delay_ms, int* volume, bool* key_pressed); | 62 void GetAudioProcessingParams(int* delay_ms, int* volume, bool* key_pressed); |
| 63 | 63 |
| 64 // WebKit::WebAudioSourceProvider implementation. | 64 // blink::WebAudioSourceProvider implementation. |
| 65 virtual void setClient(WebKit::WebAudioSourceProviderClient* client) OVERRIDE; | 65 virtual void setClient(blink::WebAudioSourceProviderClient* client) OVERRIDE; |
| 66 virtual void provideInput(const WebKit::WebVector<float*>& audio_data, | 66 virtual void provideInput(const blink::WebVector<float*>& audio_data, |
| 67 size_t number_of_frames) OVERRIDE; | 67 size_t number_of_frames) OVERRIDE; |
| 68 | 68 |
| 69 // media::AudioConverter::Inputcallback implementation. | 69 // media::AudioConverter::Inputcallback implementation. |
| 70 // This function is triggered by provideInput()on the WebAudio audio thread, | 70 // This function is triggered by provideInput()on the WebAudio audio thread, |
| 71 // so it has been under the protection of |lock_|. | 71 // so it has been under the protection of |lock_|. |
| 72 virtual double ProvideInput(media::AudioBus* audio_bus, | 72 virtual double ProvideInput(media::AudioBus* audio_bus, |
| 73 base::TimeDelta buffer_delay) OVERRIDE; | 73 base::TimeDelta buffer_delay) OVERRIDE; |
| 74 | 74 |
| 75 // Method to allow the unittests to inject its own sink parameters to avoid | 75 // Method to allow the unittests to inject its own sink parameters to avoid |
| 76 // query the hardware. | 76 // query the hardware. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 // Used to report the correct delay to |webaudio_source_|. | 101 // Used to report the correct delay to |webaudio_source_|. |
| 102 base::TimeTicks last_fill_; | 102 base::TimeTicks last_fill_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioSourceProvider); | 104 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioSourceProvider); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace content | 107 } // namespace content |
| 108 | 108 |
| 109 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ | 109 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ |
| OLD | NEW |