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

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

Issue 23691038: Switch LiveAudio to source provider solution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and fixed some unittests Created 7 years, 3 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h"
11 #include "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "media/base/audio_converter.h"
14 #include "third_party/WebKit/public/platform/WebVector.h"
15 #include "third_party/WebKit/public/web/WebAudioSourceProvider.h"
16
17 namespace media {
18 class AudioBus;
19 class AudioConverter;
20 class AudioFifo;
21 class AudioParameters;
22 }
23
24 namespace WebKit {
25 class WebAudioSourceProviderClient;
26 }
27
28 namespace content {
29
30 // WebRtcLocalAudioSourceProvider provides a bridge between classes:
31 // WebKit::WebAudioSourceProvider <---> WebRtcAudioCapturer
tommi (sloooow) - chröme 2013/09/06 11:20:30 is the flow of data bidirectional or unidirectiona
no longer working on chromium 2013/09/10 12:43:15 It is one way, from WebRtcAudioCapturer to WebKit:
32 //
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
35 // WebAudio as a source provider, WebAudio will periodically call
36 // provideInput() to get the data from the FIFO.
37 //
38 // All calls are protected by a lock.
39 class CONTENT_EXPORT WebRtcLocalAudioSourceProvider
40 : NON_EXPORTED_BASE(public media::AudioConverter::InputCallback),
tommi (sloooow) - chröme 2013/09/06 11:20:30 nit: public NON_EXPORTED_BASE(media::AudioConverte
no longer working on chromium 2013/09/10 12:43:15 Ignore as discussed offline.
41 NON_EXPORTED_BASE(public WebKit::WebAudioSourceProvider) {
42 public:
43 WebRtcLocalAudioSourceProvider();
44 ~WebRtcLocalAudioSourceProvider();
tommi (sloooow) - chröme 2013/09/06 11:20:30 virtual?
no longer working on chromium 2013/09/10 12:43:15 :) why not? Done.
45
46 // Initialize function for the souce provider. This can be called multiple
47 // times if the source format has changed.
48 void Initialize(const media::AudioParameters& source_params);
49
50 // Called by the WebRtcAudioCapturer to deliever captured data into fifo.
51 void DeliverData(media::AudioBus* audio_source,
52 int audio_delay_milliseconds,
53 int volume,
54 bool key_pressed);
55
56 // Called by the WebAudioCapturerSource to get the information of the stream.
57 // This function is triggered by provideInput(), so it has been under the
58 // protection of |lock_|.
59 void GetStreamInfo(int* delay_ms, int* volume, bool* key_pressed);
tommi (sloooow) - chröme 2013/09/06 11:20:30 Can we call this something to indicate audio proce
no longer working on chromium 2013/09/10 12:43:15 Done.
60
61 // WebKit::WebAudioSourceProvider implementation.
62 virtual void setClient(WebKit::WebAudioSourceProviderClient* client) OVERRIDE;
63 virtual void provideInput(const WebKit::WebVector<float*>& audio_data,
64 size_t number_of_frames) OVERRIDE;
65
66 // media::AudioConverter::Inputcallback implementation.
67 // This function is triggered by provideInput(), so it has been under the
68 // protection of |lock_|.
69 virtual double ProvideInput(media::AudioBus* audio_bus,
70 base::TimeDelta buffer_delay) OVERRIDE;
71
72 private:
73 // Used to DCHECK that we are called on the correct thread.
74 base::ThreadChecker thread_checker_;
75
76 scoped_ptr<media::AudioConverter> audio_converter_;
77 scoped_ptr<media::AudioFifo> fifo_;
78 scoped_ptr<media::AudioBus> bus_wrapper_;
79 int audio_delay_ms_;
80 int volume_;
81 bool key_pressed_;
82 bool is_enabled_;
83 base::Lock lock_;
tommi (sloooow) - chröme 2013/09/06 11:20:30 document what the lock is used to protect?
no longer working on chromium 2013/09/10 12:43:15 The lock is protecting all the member variables. D
84 media::AudioParameters source_params_;
85
86 // Used to report the correct delay to |webaudio_source_|.
87 base::TimeTicks last_fill_;
88
89 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioSourceProvider);
90 };
91
92 } // namespace content
93
94 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_SOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698