OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "content/common/media/media_stream_options.h" | 12 #include "content/common/media/media_stream_options.h" |
13 #include "content/renderer/media/media_stream_audio_level_calculator.h" | 13 #include "content/renderer/media/media_stream_audio_level_calculator.h" |
14 #include "content/renderer/media/media_stream_audio_processor.h" | 14 #include "content/renderer/media/media_stream_audio_processor.h" |
15 #include "content/renderer/media/media_stream_audio_source.h" | 15 #include "content/renderer/media/media_stream_audio_source.h" |
16 #include "media/base/audio_capturer_source.h" | 16 #include "media/base/audio_capturer_source.h" |
17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
18 | 18 |
| 19 #include "base/timer/timer.h" |
| 20 |
19 namespace media { | 21 namespace media { |
20 class AudioBus; | 22 class AudioBus; |
21 } | 23 } |
22 | 24 |
23 namespace content { | 25 namespace content { |
24 | 26 |
25 class PeerConnectionDependencyFactory; | 27 class PeerConnectionDependencyFactory; |
26 | 28 |
27 // Represents a local source of audio data that is routed through the WebRTC | 29 // Represents a local source of audio data that is routed through the WebRTC |
28 // audio pipeline for post-processing (e.g., for echo cancellation during a | 30 // audio pipeline for post-processing (e.g., for echo cancellation during a |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 int audio_delay_milliseconds, | 96 int audio_delay_milliseconds, |
95 double volume, | 97 double volume, |
96 bool key_pressed) override; | 98 bool key_pressed) override; |
97 void OnCaptureError(const std::string& message) override; | 99 void OnCaptureError(const std::string& message) override; |
98 | 100 |
99 private: | 101 private: |
100 // Helper function to get the source buffer size based on whether audio | 102 // Helper function to get the source buffer size based on whether audio |
101 // processing will take place. | 103 // processing will take place. |
102 int GetBufferSize(int sample_rate) const; | 104 int GetBufferSize(int sample_rate) const; |
103 | 105 |
| 106 void CheckIfInputStreamIsAlive(); |
| 107 |
104 // The RenderFrame that will consume the audio data. Used when creating | 108 // The RenderFrame that will consume the audio data. Used when creating |
105 // AudioCapturerSources. | 109 // AudioCapturerSources. |
106 const int consumer_render_frame_id_; | 110 const int consumer_render_frame_id_; |
107 | 111 |
108 PeerConnectionDependencyFactory* const pc_factory_; | 112 PeerConnectionDependencyFactory* const pc_factory_; |
109 | 113 |
110 // In debug builds, check that all methods that could cause object graph | 114 // In debug builds, check that all methods that could cause object graph |
111 // or data flow changes are being called on the main thread. | 115 // or data flow changes are being called on the main thread. |
112 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
113 | 117 |
(...skipping 15 matching lines...) Expand all Loading... |
129 | 133 |
130 // Stores latest microphone volume received in a CaptureData() callback. | 134 // Stores latest microphone volume received in a CaptureData() callback. |
131 // Range is [0, 255]. | 135 // Range is [0, 255]. |
132 base::subtle::Atomic32 volume_; | 136 base::subtle::Atomic32 volume_; |
133 | 137 |
134 // Used to calculate the signal level that shows in the UI. | 138 // Used to calculate the signal level that shows in the UI. |
135 MediaStreamAudioLevelCalculator level_calculator_; | 139 MediaStreamAudioLevelCalculator level_calculator_; |
136 | 140 |
137 bool allow_invalid_render_frame_id_for_testing_; | 141 bool allow_invalid_render_frame_id_for_testing_; |
138 | 142 |
| 143 base::RepeatingTimer check_alive_timer_; |
| 144 base::subtle::Atomic32 input_callback_is_active_; |
| 145 base::TimeTicks last_callback_time_; |
| 146 |
139 DISALLOW_COPY_AND_ASSIGN(ProcessedLocalAudioSource); | 147 DISALLOW_COPY_AND_ASSIGN(ProcessedLocalAudioSource); |
140 }; | 148 }; |
141 | 149 |
142 } // namespace content | 150 } // namespace content |
143 | 151 |
144 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ | 152 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_PROCESSED_LOCAL_AUDIO_SOURCE_H_ |
OLD | NEW |