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

Unified Diff: content/renderer/media/webrtc_audio_processor.h

Issue 37793005: move the APM to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added a switch, it uses the APM in WebRtc if the switch is off, otherwise use the APM in Chrome. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_audio_processor.h
diff --git a/content/renderer/media/webrtc_audio_processor.h b/content/renderer/media/webrtc_audio_processor.h
new file mode 100644
index 0000000000000000000000000000000000000000..94b5d305ea77fc21e576b37f72f859aef0d1cec7
--- /dev/null
+++ b/content/renderer/media/webrtc_audio_processor.h
@@ -0,0 +1,88 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_
+#define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_
+
+#include "base/synchronization/lock.h"
+#include "content/common/content_export.h"
+#include "media/base/audio_converter.h"
+#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
+#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
+#include "third_party/webrtc/modules/interface/module_common_types.h"
+
+namespace media {
+class AudioBus;
+class AudioFifo;
+class AudioParameters;
+} // namespace media
+
+namespace webrtc {
+class AudioFrame;
+}
+
+namespace content {
+
+// This class is a wrapper class of webrtc::AudioProcessing.
+class CONTENT_EXPORT WebRtcAudioProcessor {
+ public:
+ explicit WebRtcAudioProcessor(
+ const webrtc::MediaConstraintsInterface* constraints);
+ ~WebRtcAudioProcessor();
+
+ // TODO(xians): Add comment.
+ void SetFormat(const media::AudioParameters& source_params);
+
+ void Push(media::AudioBus* audio_source);
Henrik Grunell 2013/10/31 11:56:12 Add comment.
+
+ // Returns true if it has 10ms data for processing, otherwise false.
+ bool ProcessAndConsume10MsData(int capture_audio_delay_ms,
+ int volume,
+ bool key_pressed);
+
+ const int16* OutputBuffer() const;
+ const media::AudioParameters& OutputFormat() const;
+
+ // Feed render audio to AudioProcessing for analysis. This is needed
+ // if and only if echo processing is enabled.
+ void FeedRenderDataToAudioProcessing(const int16* render_audio,
+ int sample_rate,
+ int number_of_channels,
+ int number_of_frames,
+ int render_delay_ms);
+
+ bool has_audio_processing() const { return audio_processing_.get() != NULL; }
+
+ private:
+ class WebRtcAudioConverter;
+
+ void InitializeAudioProcessingModule(
+ const webrtc::MediaConstraintsInterface* constraints);
+ void InitializeRenderConverterIfNeeded(int sample_rate,
+ int number_of_channels,
+ int frames_per_buffer);
+ // Processes 10ms data.
+ void Process10MsData(int audio_delay_milliseconds,
+ int volume,
+ bool key_pressed);
+
+ void StopAudioProcessing();
+
+ // Cached value for the render delay latency.
+ int render_delay_ms_;
+
+ // Protects |render_delay_ms_|.
+ // TODO(xians): Can we get rid of the lock?
+ mutable base::Lock lock_;
+
+ // Hanles processing the audio data.
+ scoped_ptr<webrtc::AudioProcessing> audio_processing_;
+
+ scoped_ptr<WebRtcAudioConverter> capture_converter_;
+ scoped_ptr<WebRtcAudioConverter> render_converter_;
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_

Powered by Google App Engine
This is Rietveld 408576698