OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 #ifndef VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ | 10 #ifndef VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ |
11 #define VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ | 11 #define VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ |
12 | 12 |
13 #include <math.h> | 13 #include <math.h> |
14 | 14 |
15 class FakeMediaProcess : public webrtc::VoEMediaProcess { | 15 class FakeMediaProcess : public webrtc::VoEMediaProcess { |
16 public: | 16 public: |
17 FakeMediaProcess() : frequency(0) {} | 17 FakeMediaProcess() : frequency(0) {} |
18 virtual void Process(int channel, | 18 virtual void Process(int channel, |
19 const webrtc::ProcessingTypes type, | 19 const webrtc::ProcessingTypes type, |
20 int16_t audio_10ms[], | 20 int16_t audio_10ms[], |
21 int length, | 21 size_t length, |
22 int sampling_freq_hz, | 22 int sampling_freq_hz, |
23 bool stereo) { | 23 bool stereo) { |
24 for (int i = 0; i < length; i++) { | 24 for (size_t i = 0; i < length; i++) { |
25 if (!stereo) { | 25 if (!stereo) { |
26 audio_10ms[i] = static_cast<int16_t>(audio_10ms[i] * | 26 audio_10ms[i] = static_cast<int16_t>(audio_10ms[i] * |
27 sin(2.0 * 3.14 * frequency * 400.0 / sampling_freq_hz)); | 27 sin(2.0 * 3.14 * frequency * 400.0 / sampling_freq_hz)); |
28 } else { | 28 } else { |
29 // Interleaved stereo. | 29 // Interleaved stereo. |
30 audio_10ms[2 * i] = static_cast<int16_t> ( | 30 audio_10ms[2 * i] = static_cast<int16_t> ( |
31 audio_10ms[2 * i] * sin(2.0 * 3.14 * | 31 audio_10ms[2 * i] * sin(2.0 * 3.14 * |
32 frequency * 400.0 / sampling_freq_hz)); | 32 frequency * 400.0 / sampling_freq_hz)); |
33 audio_10ms[2 * i + 1] = static_cast<int16_t> ( | 33 audio_10ms[2 * i + 1] = static_cast<int16_t> ( |
34 audio_10ms[2 * i + 1] * sin(2.0 * 3.14 * | 34 audio_10ms[2 * i + 1] * sin(2.0 * 3.14 * |
35 frequency * 400.0 / sampling_freq_hz)); | 35 frequency * 400.0 / sampling_freq_hz)); |
36 } | 36 } |
37 frequency++; | 37 frequency++; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 int frequency; | 42 int frequency; |
43 }; | 43 }; |
44 | 44 |
45 #endif // VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ | 45 #endif // VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKE_MEDIA_PROCESS_H_ |
OLD | NEW |