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