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

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

Issue 54383003: Added an "enable-audio-processor" flag and WebRtcAudioProcessor class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Henrik's comment. Created 7 years, 1 month 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_AUDIO_PROCESSOR_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_
7
8 #include "base/synchronization/lock.h"
9 #include "content/common/content_export.h"
10 #include "media/base/audio_converter.h"
11 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
12 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h "
13 #include "third_party/webrtc/modules/interface/module_common_types.h"
14
15 namespace media {
16 class AudioBus;
17 class AudioFifo;
18 class AudioParameters;
19 } // namespace media
20
21 namespace webrtc {
22 class AudioFrame;
23 }
24
25 namespace content {
26
27 // This class owns an object of webrtc::AudioProcessing, it enables the audio
perkj_chrome 2013/11/04 12:30:14 explain what type of processing it enables
no longer working on chromium 2013/11/04 15:28:17 Done.
28 // processing components based on the constraints, processes the data and
29 // outputs it in a unit of 10 ms data chunk.
30 class CONTENT_EXPORT WebRtcAudioProcessor {
31 public:
32 explicit WebRtcAudioProcessor(
33 const webrtc::MediaConstraintsInterface* constraints);
34 ~WebRtcAudioProcessor();
35
36 // Pushes capture data in |audio_source| to the internal FIFO.
37 // Called on the capture audio thread.
38 void PushCaptureData(media::AudioBus* audio_source);
perkj_chrome 2013/11/04 12:30:14 Is it really necessary to have both PushCaptureDat
no longer working on chromium 2013/11/04 15:28:17 It is possible, but the client of the processor ne
39
40 // Processes a block of 10 ms data from the internal FIFO and outputs it via
41 // |out|.
42 // Returns true if the internal FIFO has at least 10ms data for processing,
43 // otherwise false.
44 // Called on the capture audio thread.
45 bool ProcessAndConsume10MsData(int capture_audio_delay_ms,
46 int volume,
47 bool key_pressed,
48 int16** out);
49
50 // Called when the format of the capture data has changed.
51 // Called on the main render thread.
52 void SetCaptureFormat(const media::AudioParameters& source_params);
53
54 // Push the render audio to WebRtc::AudioProcessing for analysis. This is
55 // needed iff echo processing is enabled.
56 // Called on the render audio thread.
57 void PushRenderData(const int16* render_audio,
58 int sample_rate,
59 int number_of_channels,
60 int number_of_frames,
61 int render_delay_ms);
62
63 // The audio format of the output from the processor.
64 const media::AudioParameters& OutputFormat() const;
65
66 // Accessor to check if the audio processing is enabled or not.
67 bool has_audio_processing() const { return audio_processing_.get() != NULL; }
68
69 private:
70 class WebRtcAudioConverter;
71
72 // Helper to initialize the WebRtc AudioProcessing.
73 void InitializeAudioProcessingModule(
74 const webrtc::MediaConstraintsInterface* constraints);
75
76 // Helper to initialize the render converter.
77 void InitializeRenderConverterIfNeeded(int sample_rate,
78 int number_of_channels,
79 int frames_per_buffer);
80
81 // Called by ProcessAndConsume10MsData().
82 void ProcessData(int audio_delay_milliseconds,
83 int volume,
84 bool key_pressed);
85
86 // Called when the processor is going away.
87 void StopAudioProcessing();
88
89 // Cached value for the render delay latency.
90 int render_delay_ms_;
91
92 // Protects |render_delay_ms_|.
93 // TODO(xians): Can we get rid of the lock?
94 mutable base::Lock lock_;
95
96 // WebRtc AudioProcessing module which does AEC, AGC, NS, HighPass filter,
97 // ..etc.
98 scoped_ptr<webrtc::AudioProcessing> audio_processing_;
99
100 // Converter used for the down-mixing and resampling of the capture data.
101 scoped_ptr<WebRtcAudioConverter> capture_converter_;
102
103 // Converter used for the down-mixing and resampling of the render data when
104 // the AEC is enabled.
105 scoped_ptr<WebRtcAudioConverter> render_converter_;
106 };
107
108 } // namespace content
109
110 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698