Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_coding / main / acm2 / acm_receive_test_oldapi.h
1 /*
2  *  Copyright (c) 2014 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_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_
13
14 #include "webrtc/base/constructormagic.h"
15 #include "webrtc/system_wrappers/interface/clock.h"
16 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
17
18 namespace webrtc {
19 class AudioCodingModule;
20 struct CodecInst;
21
22 namespace test {
23 class AudioSink;
24 class PacketSource;
25
26 class AcmReceiveTestOldApi {
27  public:
28   enum NumOutputChannels {
29     kArbitraryChannels = 0,
30     kMonoOutput = 1,
31     kStereoOutput = 2
32   };
33
34   AcmReceiveTestOldApi(PacketSource* packet_source,
35                        AudioSink* audio_sink,
36                        int output_freq_hz,
37                        NumOutputChannels exptected_output_channels);
38   virtual ~AcmReceiveTestOldApi() {}
39
40   // Registers the codecs with default parameters from ACM.
41   void RegisterDefaultCodecs();
42
43   // Registers codecs with payload types matching the pre-encoded NetEq test
44   // files.
45   void RegisterNetEqTestCodecs();
46
47   // Runs the test and returns true if successful.
48   void Run();
49
50  protected:
51   // Method is called after each block of output audio is received from ACM.
52   virtual void AfterGetAudio() {}
53
54   SimulatedClock clock_;
55   scoped_ptr<AudioCodingModule> acm_;
56   PacketSource* packet_source_;
57   AudioSink* audio_sink_;
58   int output_freq_hz_;
59   NumOutputChannels exptected_output_channels_;
60
61   DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
62 };
63
64 // This test toggles the output frequency every |toggle_period_ms|. The test
65 // starts with |output_freq_hz_1|. Except for the toggling, it does the same
66 // thing as AcmReceiveTestOldApi.
67 class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi {
68  public:
69   AcmReceiveTestToggleOutputFreqOldApi(
70       PacketSource* packet_source,
71       AudioSink* audio_sink,
72       int output_freq_hz_1,
73       int output_freq_hz_2,
74       int toggle_period_ms,
75       NumOutputChannels exptected_output_channels);
76
77  protected:
78   void AfterGetAudio() OVERRIDE;
79
80   const int output_freq_hz_1_;
81   const int output_freq_hz_2_;
82   const int toggle_period_ms_;
83   int64_t last_toggle_time_ms_;
84 };
85
86 }  // namespace test
87 }  // namespace webrtc
88 #endif  // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_