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

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

Issue 90743004: Add generic interfaces for the sinks of the media stream audio track (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the nits. Created 7 years 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 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 <vector>
9
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
11 #include "base/time/time.h" 13 #include "base/time/time.h"
12 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
13 #include "content/renderer/media/webrtc_audio_device_impl.h" 15 #include "content/public/renderer/media_stream_audio_sink.h"
14 #include "media/base/audio_converter.h" 16 #include "media/base/audio_converter.h"
15 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 17 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
16 #include "third_party/WebKit/public/platform/WebVector.h" 18 #include "third_party/WebKit/public/platform/WebVector.h"
17 19
18 namespace media { 20 namespace media {
19 class AudioBus; 21 class AudioBus;
20 class AudioConverter; 22 class AudioConverter;
21 class AudioFifo; 23 class AudioFifo;
22 class AudioParameters; 24 class AudioParameters;
23 } 25 }
24 26
25 namespace blink { 27 namespace blink {
26 class WebAudioSourceProviderClient; 28 class WebAudioSourceProviderClient;
27 } 29 }
28 30
29 namespace content { 31 namespace content {
30 32
31 // WebRtcLocalAudioSourceProvider provides a bridge between classes: 33 // WebRtcLocalAudioSourceProvider provides a bridge between classes:
32 // WebRtcAudioCapturer ---> blink::WebAudioSourceProvider 34 // WebRtcAudioCapturer ---> blink::WebAudioSourceProvider
33 // 35 //
34 // WebRtcLocalAudioSourceProvider works as a sink to the WebRtcAudiocapturer 36 // WebRtcLocalAudioSourceProvider works as a sink to the WebRtcAudiocapturer
35 // and store the capture data to a FIFO. When the media stream is connected to 37 // and store the capture data to a FIFO. When the media stream is connected to
36 // WebAudio as a source provider, WebAudio will periodically call 38 // WebAudio as a source provider, WebAudio will periodically call
37 // provideInput() to get the data from the FIFO. 39 // provideInput() to get the data from the FIFO.
38 // 40 //
39 // All calls are protected by a lock. 41 // All calls are protected by a lock.
40 class CONTENT_EXPORT WebRtcLocalAudioSourceProvider 42 class CONTENT_EXPORT WebRtcLocalAudioSourceProvider
41 : NON_EXPORTED_BASE(public media::AudioConverter::InputCallback), 43 : NON_EXPORTED_BASE(public blink::WebAudioSourceProvider),
42 NON_EXPORTED_BASE(public blink::WebAudioSourceProvider), 44 NON_EXPORTED_BASE(public media::AudioConverter::InputCallback),
43 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink) { 45 NON_EXPORTED_BASE(public MediaStreamAudioSink) {
44 public: 46 public:
45 static const size_t kWebAudioRenderBufferSize; 47 static const size_t kWebAudioRenderBufferSize;
46 48
47 WebRtcLocalAudioSourceProvider(); 49 WebRtcLocalAudioSourceProvider();
48 virtual ~WebRtcLocalAudioSourceProvider(); 50 virtual ~WebRtcLocalAudioSourceProvider();
49 51
50 // WebRtcAudioCapturerSink implementation. 52 // MediaStreamAudioSink implementation.
51 virtual int CaptureData(const std::vector<int>& channels, 53 virtual void OnData(const int16* audio_data,
52 const int16* audio_data, 54 int sample_rate,
53 int sample_rate, 55 int number_of_channels,
54 int number_of_channels, 56 int number_of_frames) OVERRIDE;
55 int number_of_frames, 57 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE;
56 int audio_delay_milliseconds,
57 int current_volume,
58 bool need_audio_processing,
59 bool key_pressed) OVERRIDE;
60 virtual void SetCaptureFormat(const media::AudioParameters& params) OVERRIDE;
61 58
62 // blink::WebAudioSourceProvider implementation. 59 // blink::WebAudioSourceProvider implementation.
63 virtual void setClient(blink::WebAudioSourceProviderClient* client) OVERRIDE; 60 virtual void setClient(blink::WebAudioSourceProviderClient* client) OVERRIDE;
64 virtual void provideInput(const blink::WebVector<float*>& audio_data, 61 virtual void provideInput(const blink::WebVector<float*>& audio_data,
65 size_t number_of_frames) OVERRIDE; 62 size_t number_of_frames) OVERRIDE;
66 63
67 // media::AudioConverter::Inputcallback implementation. 64 // media::AudioConverter::Inputcallback implementation.
68 // This function is triggered by provideInput()on the WebAudio audio thread, 65 // This function is triggered by provideInput()on the WebAudio audio thread,
69 // so it has been under the protection of |lock_|. 66 // so it has been under the protection of |lock_|.
70 virtual double ProvideInput(media::AudioBus* audio_bus, 67 virtual double ProvideInput(media::AudioBus* audio_bus,
(...skipping 25 matching lines...) Expand all
96 93
97 // Used to report the correct delay to |webaudio_source_|. 94 // Used to report the correct delay to |webaudio_source_|.
98 base::TimeTicks last_fill_; 95 base::TimeTicks last_fill_;
99 96
100 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioSourceProvider); 97 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioSourceProvider);
101 }; 98 };
102 99
103 } // namespace content 100 } // namespace content
104 101
105 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_ 102 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_local_audio_renderer.cc ('k') | content/renderer/media/webrtc_local_audio_source_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698