OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2013 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 | |
11 #ifndef WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_ | |
12 #define WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_ | |
13 | |
14 #include <map> | |
15 | |
16 #include "webrtc/base/scoped_ptr.h" | |
17 #include "webrtc/test/fake_common.h" | |
18 #include "webrtc/voice_engine/include/voe_external_media.h" | |
19 | |
20 namespace webrtc { | |
21 | |
22 class FakeVoEExternalMedia : public VoEExternalMedia { | |
23 public: | |
24 FakeVoEExternalMedia() {} | |
25 virtual ~FakeVoEExternalMedia() {} | |
26 | |
27 WEBRTC_STUB(Release, ()); | |
28 WEBRTC_FUNC(RegisterExternalMediaProcessing, | |
29 (int channel, ProcessingTypes type, VoEMediaProcess& processObject)) { | |
30 callback_map_[type] = &processObject; | |
31 return 0; | |
32 } | |
33 WEBRTC_FUNC(DeRegisterExternalMediaProcessing, | |
34 (int channel, ProcessingTypes type)) { | |
35 callback_map_.erase(type); | |
36 return 0; | |
37 } | |
38 WEBRTC_STUB(GetAudioFrame, (int channel, int desired_sample_rate_hz, | |
39 AudioFrame* frame)); | |
40 WEBRTC_STUB(SetExternalMixing, (int channel, bool enable)); | |
41 | |
42 // Use this to trigger the Process() callback to a registered media processor. | |
43 // If |audio| is NULL, a zero array of the correct length will be forwarded. | |
44 void CallProcess(ProcessingTypes type, int16_t* audio, | |
45 size_t samples_per_channel, int sample_rate_hz, | |
46 int num_channels) { | |
47 const size_t length = samples_per_channel * num_channels; | |
48 rtc::scoped_ptr<int16_t[]> data; | |
49 if (!audio) { | |
50 data.reset(new int16_t[length]); | |
51 memset(data.get(), 0, length * sizeof(data[0])); | |
52 audio = data.get(); | |
53 } | |
54 | |
55 std::map<ProcessingTypes, VoEMediaProcess*>::const_iterator it = | |
56 callback_map_.find(type); | |
57 if (it != callback_map_.end()) { | |
58 it->second->Process(0, type, audio, samples_per_channel, sample_rate_hz, | |
59 num_channels == 2 ? true : false); | |
60 } | |
61 } | |
62 | |
63 private: | |
64 std::map<ProcessingTypes, VoEMediaProcess*> callback_map_; | |
65 }; | |
66 | |
67 } // namespace webrtc | |
68 | |
69 #endif // WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_ | |
OLD | NEW |