OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // This class implements an AudioCaptureModule that can be used to detect if | 11 // This class implements an AudioCaptureModule that can be used to detect if |
12 // audio is being received properly if it is fed by another AudioCaptureModule | 12 // audio is being received properly if it is fed by another AudioCaptureModule |
13 // in some arbitrary audio pipeline where they are connected. It does not play | 13 // in some arbitrary audio pipeline where they are connected. It does not play |
14 // out or record any audio so it does not need access to any hardware and can | 14 // out or record any audio so it does not need access to any hardware and can |
15 // therefore be used in the gtest testing framework. | 15 // therefore be used in the gtest testing framework. |
16 | 16 |
17 // Note P postfix of a function indicates that it should only be called by the | 17 // Note P postfix of a function indicates that it should only be called by the |
18 // processing thread. | 18 // processing thread. |
19 | 19 |
20 #ifndef WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ | 20 #ifndef WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ |
21 #define WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ | 21 #define WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ |
22 | 22 |
| 23 #include <memory> |
| 24 |
23 #include "webrtc/base/basictypes.h" | 25 #include "webrtc/base/basictypes.h" |
24 #include "webrtc/base/criticalsection.h" | 26 #include "webrtc/base/criticalsection.h" |
25 #include "webrtc/base/messagehandler.h" | 27 #include "webrtc/base/messagehandler.h" |
26 #include "webrtc/base/scoped_ptr.h" | 28 #include "webrtc/base/scoped_ptr.h" |
27 #include "webrtc/base/scoped_ref_ptr.h" | 29 #include "webrtc/base/scoped_ref_ptr.h" |
28 #include "webrtc/common_types.h" | 30 #include "webrtc/common_types.h" |
29 #include "webrtc/modules/audio_device/include/audio_device.h" | 31 #include "webrtc/modules/audio_device/include/audio_device.h" |
30 | 32 |
31 namespace rtc { | 33 namespace rtc { |
32 class Thread; | 34 class Thread; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // modify the current mic level. The implementation does not care about the | 242 // modify the current mic level. The implementation does not care about the |
241 // mic level so it just feeds back what it receives. | 243 // mic level so it just feeds back what it receives. |
242 uint32_t current_mic_level_; | 244 uint32_t current_mic_level_; |
243 | 245 |
244 // next_frame_time_ is updated in a non-drifting manner to indicate the next | 246 // next_frame_time_ is updated in a non-drifting manner to indicate the next |
245 // wall clock time the next frame should be generated and received. started_ | 247 // wall clock time the next frame should be generated and received. started_ |
246 // ensures that next_frame_time_ can be initialized properly on first call. | 248 // ensures that next_frame_time_ can be initialized properly on first call. |
247 bool started_; | 249 bool started_; |
248 uint32_t next_frame_time_; | 250 uint32_t next_frame_time_; |
249 | 251 |
250 rtc::scoped_ptr<rtc::Thread> process_thread_; | 252 std::unique_ptr<rtc::Thread> process_thread_; |
251 | 253 |
252 // Buffer for storing samples received from the webrtc::AudioTransport. | 254 // Buffer for storing samples received from the webrtc::AudioTransport. |
253 char rec_buffer_[kNumberSamples * kNumberBytesPerSample]; | 255 char rec_buffer_[kNumberSamples * kNumberBytesPerSample]; |
254 // Buffer for samples to send to the webrtc::AudioTransport. | 256 // Buffer for samples to send to the webrtc::AudioTransport. |
255 char send_buffer_[kNumberSamples * kNumberBytesPerSample]; | 257 char send_buffer_[kNumberSamples * kNumberBytesPerSample]; |
256 | 258 |
257 // Counter of frames received that have samples of high enough amplitude to | 259 // Counter of frames received that have samples of high enough amplitude to |
258 // indicate that the frames are not faked somewhere in the audio pipeline | 260 // indicate that the frames are not faked somewhere in the audio pipeline |
259 // (e.g. by a jitter buffer). | 261 // (e.g. by a jitter buffer). |
260 int frames_received_; | 262 int frames_received_; |
261 | 263 |
262 // Protects variables that are accessed from process_thread_ and | 264 // Protects variables that are accessed from process_thread_ and |
263 // the main thread. | 265 // the main thread. |
264 rtc::CriticalSection crit_; | 266 rtc::CriticalSection crit_; |
265 // Protects |audio_callback_| that is accessed from process_thread_ and | 267 // Protects |audio_callback_| that is accessed from process_thread_ and |
266 // the main thread. | 268 // the main thread. |
267 rtc::CriticalSection crit_callback_; | 269 rtc::CriticalSection crit_callback_; |
268 }; | 270 }; |
269 | 271 |
270 #endif // WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ | 272 #endif // WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ |
OLD | NEW |