| 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 #ifndef CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // audio stream to the WebRtcLocalAudioTrack::Capture() method. | 28 // audio stream to the WebRtcLocalAudioTrack::Capture() method. |
| 29 class WebAudioCapturerSource | 29 class WebAudioCapturerSource |
| 30 : public base::RefCountedThreadSafe<WebAudioCapturerSource>, | 30 : public base::RefCountedThreadSafe<WebAudioCapturerSource>, |
| 31 public blink::WebAudioDestinationConsumer { | 31 public blink::WebAudioDestinationConsumer { |
| 32 public: | 32 public: |
| 33 explicit WebAudioCapturerSource( | 33 explicit WebAudioCapturerSource( |
| 34 const blink::WebMediaStreamSource& blink_source); | 34 const blink::WebMediaStreamSource& blink_source); |
| 35 | 35 |
| 36 // WebAudioDestinationConsumer implementation. | 36 // WebAudioDestinationConsumer implementation. |
| 37 // setFormat() is called early on, so that we can configure the audio track. | 37 // setFormat() is called early on, so that we can configure the audio track. |
| 38 virtual void setFormat(size_t number_of_channels, float sample_rate) override; | 38 void setFormat(size_t number_of_channels, float sample_rate) override; |
| 39 // MediaStreamAudioDestinationNode periodically calls consumeAudio(). | 39 // MediaStreamAudioDestinationNode periodically calls consumeAudio(). |
| 40 // Called on the WebAudio audio thread. | 40 // Called on the WebAudio audio thread. |
| 41 virtual void consumeAudio(const blink::WebVector<const float*>& audio_data, | 41 void consumeAudio(const blink::WebVector<const float*>& audio_data, |
| 42 size_t number_of_frames) override; | 42 size_t number_of_frames) override; |
| 43 | 43 |
| 44 // Called when the WebAudioCapturerSource is hooking to a media audio track. | 44 // Called when the WebAudioCapturerSource is hooking to a media audio track. |
| 45 // |track| is the sink of the data flow. |source_provider| is the source of | 45 // |track| is the sink of the data flow. |source_provider| is the source of |
| 46 // the data flow where stream information like delay, volume, key_pressed, | 46 // the data flow where stream information like delay, volume, key_pressed, |
| 47 // is stored. | 47 // is stored. |
| 48 void Start(WebRtcLocalAudioTrack* track); | 48 void Start(WebRtcLocalAudioTrack* track); |
| 49 | 49 |
| 50 // Called when the media audio track is stopping. | 50 // Called when the media audio track is stopping. |
| 51 void Stop(); | 51 void Stop(); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 friend class base::RefCountedThreadSafe<WebAudioCapturerSource>; | 54 friend class base::RefCountedThreadSafe<WebAudioCapturerSource>; |
| 55 virtual ~WebAudioCapturerSource(); | 55 ~WebAudioCapturerSource() override; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Removes this object from a blink::WebMediaStreamSource with which it | 58 // Removes this object from a blink::WebMediaStreamSource with which it |
| 59 // might be registered. The goal is to avoid dangling pointers. | 59 // might be registered. The goal is to avoid dangling pointers. |
| 60 void removeFromBlinkSource(); | 60 void removeFromBlinkSource(); |
| 61 | 61 |
| 62 // Used to DCHECK that some methods are called on the correct thread. | 62 // Used to DCHECK that some methods are called on the correct thread. |
| 63 base::ThreadChecker thread_checker_; | 63 base::ThreadChecker thread_checker_; |
| 64 | 64 |
| 65 // The audio track this WebAudioCapturerSource is feeding data to. | 65 // The audio track this WebAudioCapturerSource is feeding data to. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 // This object registers with a blink::WebMediaStreamSource. We keep track of | 88 // This object registers with a blink::WebMediaStreamSource. We keep track of |
| 89 // that in order to be able to deregister before stopping the audio track. | 89 // that in order to be able to deregister before stopping the audio track. |
| 90 blink::WebMediaStreamSource blink_source_; | 90 blink::WebMediaStreamSource blink_source_; |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(WebAudioCapturerSource); | 92 DISALLOW_COPY_AND_ASSIGN(WebAudioCapturerSource); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace content | 95 } // namespace content |
| 96 | 96 |
| 97 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ | 97 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIO_CAPTURER_SOURCE_H_ |
| OLD | NEW |