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

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: added unittest 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
28 // processing components based on the constraints, process the data and output
Henrik Grunell 2013/11/01 07:22:36 I would suggest: "...processes the data and output
no longer working on chromium 2013/11/01 11:44:43 Done.
29 // the post-processed data in a unit of 10ms data chunk.
30 class CONTENT_EXPORT WebRtcAudioProcessor {
Henrik Grunell 2013/11/01 07:22:36 Is this class thread safe? Does it live on one thr
no longer working on chromium 2013/11/01 11:44:43 No, I can add comment to explain which thread the
31 public:
32 explicit WebRtcAudioProcessor(
33 const webrtc::MediaConstraintsInterface* constraints);
34 ~WebRtcAudioProcessor();
35
36 // Pushes in capture data for processing.
Henrik Grunell 2013/11/01 07:22:36 How much data? (In ms.) 10 ms? Everything in |audi
no longer working on chromium 2013/11/01 11:44:43 everything in the |audio_bus|
37 void PushCaptureData(media::AudioBus* audio_source);
38
39 // Processes a block of 10ms data and output the post-processed data via
Henrik Grunell 2013/11/01 07:22:36 "Processes a block of 10 ms data and outputs it vi
no longer working on chromium 2013/11/01 11:44:43 Done.
40 // |out|. The output data format is exposed via |sample_rate|,
Henrik Grunell 2013/11/01 07:22:36 I don't understand "The output data format is expo
no longer working on chromium 2013/11/01 11:44:43 Old comment, I removed the code but forgot the upd
41 // |number_of_channels| and |number_of_frames|.
42 // Returns true if it has 10ms data for processing, otherwise false.
Henrik Grunell 2013/11/01 07:22:36 "10 ms" It's a bit unclear. I assume returning fa
no longer working on chromium 2013/11/01 11:44:43 Done.
43 bool ProcessAndConsume10MsData(int capture_audio_delay_ms,
44 int volume,
45 bool key_pressed,
46 int16** out);
47
48 // Called when the format of the capture data has changed.
49 void SetCaptureFormat(const media::AudioParameters& source_params);
50
51 // Feed render audio to AudioProcessing for analysis. This is needed
52 // iff echo processing is enabled.
53 void FeedRenderDataToAudioProcessing(const int16* render_audio,
Henrik Grunell 2013/11/01 07:22:36 Maybe it should be named as for capture: PushRende
no longer working on chromium 2013/11/01 11:44:43 Done.
54 int sample_rate,
55 int number_of_channels,
56 int number_of_frames,
57 int render_delay_ms);
58
59 // The audio format of the output from the processor.
60 const media::AudioParameters& OutputFormat() const;
61
62 // Accessor to check if the audio processing is enabled or not.
Henrik Grunell 2013/11/01 07:22:36 It can't be set, right? So, in what cases is it en
no longer working on chromium 2013/11/01 11:44:43 When the constraints are all set to be false, ther
63 bool has_audio_processing() const { return audio_processing_.get() != NULL; }
64
65 private:
66 class WebRtcAudioConverter;
67
68 // Helper to initialize the WebRtc AudioProcessing.
69 void InitializeAudioProcessingModule(
70 const webrtc::MediaConstraintsInterface* constraints);
71
72 // Helper to initialize the render converter.
73 void InitializeRenderConverterIfNeeded(int sample_rate,
74 int number_of_channels,
75 int frames_per_buffer);
76
77 // Called by ProcessAndConsume10MsData().
78 void ProcessData(int audio_delay_milliseconds,
79 int volume,
80 bool key_pressed);
81
82 // Called when the processor is going away.
83 void StopAudioProcessing();
84
85 // Cached value for the render delay latency.
86 int render_delay_ms_;
87
88 // Protects |render_delay_ms_|.
89 // TODO(xians): Can we get rid of the lock?
90 mutable base::Lock lock_;
91
92 scoped_ptr<webrtc::AudioProcessing> audio_processing_;
Henrik Grunell 2013/11/01 07:22:36 Comment.
no longer working on chromium 2013/11/01 11:44:43 Done.
93
94 // Converter used for the down-mixing and resampling of the capture data.
95 scoped_ptr<WebRtcAudioConverter> capture_converter_;
96
97 // Converter used for the down-mixing and resampling of the render data when
98 // the AEC is enabled.
99 scoped_ptr<WebRtcAudioConverter> render_converter_;
100 };
101
102 } // namespace content
103
104 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698