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

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

Issue 185413009: Implements the GetSignalLevel and GetStats interface for the local audio track. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 6 years, 9 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
« no previous file with comments | « no previous file | content/renderer/media/media_stream_audio_processor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/renderer/media/webrtc_audio_device_impl.h" 13 #include "content/renderer/media/webrtc_audio_device_impl.h"
14 #include "media/base/audio_converter.h" 14 #include "media/base/audio_converter.h"
15 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
15 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " 16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h "
16 #include "third_party/webrtc/modules/interface/module_common_types.h" 17 #include "third_party/webrtc/modules/interface/module_common_types.h"
17 18
18 namespace blink { 19 namespace blink {
19 class WebMediaConstraints; 20 class WebMediaConstraints;
20 } 21 }
21 22
22 namespace media { 23 namespace media {
23 class AudioBus; 24 class AudioBus;
24 class AudioFifo; 25 class AudioFifo;
25 class AudioParameters; 26 class AudioParameters;
26 } // namespace media 27 } // namespace media
27 28
28 namespace webrtc { 29 namespace webrtc {
29 class AudioFrame; 30 class AudioFrame;
30 class TypingDetection; 31 class TypingDetection;
31 } 32 }
32 33
33 namespace content { 34 namespace content {
34 35
35 class RTCMediaConstraints; 36 class RTCMediaConstraints;
36 37
38 using webrtc::AudioProcessorInterface;
39
37 // This class owns an object of webrtc::AudioProcessing which contains signal 40 // This class owns an object of webrtc::AudioProcessing which contains signal
38 // processing components like AGC, AEC and NS. It enables the components based 41 // processing components like AGC, AEC and NS. It enables the components based
39 // on the getUserMedia constraints, processes the data and outputs it in a unit 42 // on the getUserMedia constraints, processes the data and outputs it in a unit
40 // of 10 ms data chunk. 43 // of 10 ms data chunk.
41 class CONTENT_EXPORT MediaStreamAudioProcessor : 44 class CONTENT_EXPORT MediaStreamAudioProcessor :
42 public base::RefCountedThreadSafe<MediaStreamAudioProcessor>, 45 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink),
43 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink) { 46 NON_EXPORTED_BASE(public AudioProcessorInterface) {
44 public: 47 public:
45 // |playout_data_source| is used to register this class as a sink to the 48 // |playout_data_source| is used to register this class as a sink to the
46 // WebRtc playout data for processing AEC. If clients do not enable AEC, 49 // WebRtc playout data for processing AEC. If clients do not enable AEC,
47 // |playout_data_source| won't be used. 50 // |playout_data_source| won't be used.
48 MediaStreamAudioProcessor(const media::AudioParameters& source_params, 51 MediaStreamAudioProcessor(const media::AudioParameters& source_params,
49 const blink::WebMediaConstraints& constraints, 52 const blink::WebMediaConstraints& constraints,
50 int effects, 53 int effects,
51 WebRtcPlayoutDataSource* playout_data_source); 54 WebRtcPlayoutDataSource* playout_data_source);
52 55
53 // Pushes capture data in |audio_source| to the internal FIFO. 56 // Pushes capture data in |audio_source| to the internal FIFO.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 friend class MediaStreamAudioProcessorTest; 94 friend class MediaStreamAudioProcessorTest;
92 95
93 class MediaStreamAudioConverter; 96 class MediaStreamAudioConverter;
94 97
95 // WebRtcPlayoutDataSource::Sink implementation. 98 // WebRtcPlayoutDataSource::Sink implementation.
96 virtual void OnPlayoutData(media::AudioBus* audio_bus, 99 virtual void OnPlayoutData(media::AudioBus* audio_bus,
97 int sample_rate, 100 int sample_rate,
98 int audio_delay_milliseconds) OVERRIDE; 101 int audio_delay_milliseconds) OVERRIDE;
99 virtual void OnPlayoutDataSourceChanged() OVERRIDE; 102 virtual void OnPlayoutDataSourceChanged() OVERRIDE;
100 103
104 // webrtc::AudioProcessorInterface implementation.
105 // This method is called on the libjingle thread.
106 virtual void GetStats(AudioProcessorStats* stats) OVERRIDE;
107
101 // Helper to initialize the WebRtc AudioProcessing. 108 // Helper to initialize the WebRtc AudioProcessing.
102 void InitializeAudioProcessingModule( 109 void InitializeAudioProcessingModule(
103 const blink::WebMediaConstraints& constraints, int effects); 110 const blink::WebMediaConstraints& constraints, int effects);
104 111
105 // Helper to initialize the capture converter. 112 // Helper to initialize the capture converter.
106 void InitializeCaptureConverter(const media::AudioParameters& source_params); 113 void InitializeCaptureConverter(const media::AudioParameters& source_params);
107 114
108 // Helper to initialize the render converter. 115 // Helper to initialize the render converter.
109 void InitializeRenderConverterIfNeeded(int sample_rate, 116 void InitializeRenderConverterIfNeeded(int sample_rate,
110 int number_of_channels, 117 int number_of_channels,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 164
158 // Used to DCHECK that PushRenderData() is called on the render audio thread. 165 // Used to DCHECK that PushRenderData() is called on the render audio thread.
159 base::ThreadChecker render_thread_checker_; 166 base::ThreadChecker render_thread_checker_;
160 167
161 // Flag to enable the stereo channels mirroring. 168 // Flag to enable the stereo channels mirroring.
162 bool audio_mirroring_; 169 bool audio_mirroring_;
163 170
164 // Used by the typing detection. 171 // Used by the typing detection.
165 scoped_ptr<webrtc::TypingDetection> typing_detector_; 172 scoped_ptr<webrtc::TypingDetection> typing_detector_;
166 173
167 // Result from the typing detection. 174 // This flag is used to show the result of typing detection.
168 bool typing_detected_; 175 // It can be accessed by the capture audio thread and by the libjingle thread
176 // which calls GetStats().
177 base::subtle::Atomic32 typing_detected_;
169 }; 178 };
170 179
171 } // namespace content 180 } // namespace content
172 181
173 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 182 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_stream_audio_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698