| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "media/audio/audio_parameters.h" |
| 11 #include "media/base/audio_capturer_source.h" |
| 12 #include "media/base/audio_fifo.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // WebAudioCapturerSource is the missing link between |
| 18 // WebAudio's MediaStreamAudioDestinationNode and WebRtcAudioCapturer. |
| 19 // HandleCapture() is called (indirectly) by WebAudio which dispatches |
| 20 // to WebRtcAudioCapturer::Capture(). |
| 21 class WebAudioCapturerSource : public media::AudioCapturerSource { |
| 22 public: |
| 23 WebAudioCapturerSource(); |
| 24 |
| 25 // Handles the audio stream from WebAudio's MediaStreamAudioDestinationNode. |
| 26 void HandleCapture( |
| 27 const WebKit::WebVector<const float*>& audio_data, |
| 28 size_t number_of_frames); |
| 29 |
| 30 // AudioCapturerSource implementation. |
| 31 virtual void Initialize( |
| 32 const media::AudioParameters& params, |
| 33 media::AudioCapturerSource::CaptureCallback* callback, |
| 34 media::AudioCapturerSource::CaptureEventHandler* event_handler) OVERRIDE; |
| 35 |
| 36 virtual void Start() OVERRIDE; |
| 37 virtual void Stop() OVERRIDE; |
| 38 virtual void SetVolume(double volume) OVERRIDE { } |
| 39 virtual void SetDevice(int session_id) OVERRIDE { } |
| 40 virtual void SetAutomaticGainControl(bool enable) OVERRIDE { } |
| 41 |
| 42 private: |
| 43 virtual ~WebAudioCapturerSource(); |
| 44 |
| 45 media::AudioParameters params_; |
| 46 media::AudioCapturerSource::CaptureCallback* callback_; |
| 47 |
| 48 // Wraps data coming from HandleCapture(). |
| 49 scoped_ptr<media::AudioBus> wrapper_bus_; |
| 50 |
| 51 // Bus for reading from FIFO and calling the CaptureCallback. |
| 52 scoped_ptr<media::AudioBus> capture_bus_; |
| 53 |
| 54 // Handles mismatch between WebAudio buffer size and WebRTC. |
| 55 scoped_ptr<media::AudioFifo> fifo_; |
| 56 |
| 57 // Synchronizes HandleCapture() with AudioCapturerSource calls. |
| 58 base::Lock lock_; |
| 59 bool started_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(WebAudioCapturerSource); |
| 62 }; |
| 63 |
| 64 } // namespace content |
| 65 |
| 66 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| OLD | NEW |