• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ACM2_ACM_RECEIVE_TEST_OLDAPI_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_OLDAPI_H_
13 
14 #include <string>
15 
16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/system_wrappers/include/clock.h"
19 
20 namespace webrtc {
21 class AudioCodingModule;
22 class AudioDecoder;
23 struct CodecInst;
24 
25 namespace test {
26 class AudioSink;
27 class PacketSource;
28 
29 class AcmReceiveTestOldApi {
30  public:
31   enum NumOutputChannels {
32     kArbitraryChannels = 0,
33     kMonoOutput = 1,
34     kStereoOutput = 2
35   };
36 
37   AcmReceiveTestOldApi(PacketSource* packet_source,
38                        AudioSink* audio_sink,
39                        int output_freq_hz,
40                        NumOutputChannels exptected_output_channels);
~AcmReceiveTestOldApi()41   virtual ~AcmReceiveTestOldApi() {}
42 
43   // Registers the codecs with default parameters from ACM.
44   void RegisterDefaultCodecs();
45 
46   // Registers codecs with payload types matching the pre-encoded NetEq test
47   // files.
48   void RegisterNetEqTestCodecs();
49 
50   int RegisterExternalReceiveCodec(int rtp_payload_type,
51                                    AudioDecoder* external_decoder,
52                                    int sample_rate_hz,
53                                    int num_channels,
54                                    const std::string& name);
55 
56   // Runs the test and returns true if successful.
57   void Run();
58 
59  protected:
60   // Method is called after each block of output audio is received from ACM.
AfterGetAudio()61   virtual void AfterGetAudio() {}
62 
63   SimulatedClock clock_;
64   rtc::scoped_ptr<AudioCodingModule> acm_;
65   PacketSource* packet_source_;
66   AudioSink* audio_sink_;
67   int output_freq_hz_;
68   NumOutputChannels exptected_output_channels_;
69 
70   RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
71 };
72 
73 // This test toggles the output frequency every |toggle_period_ms|. The test
74 // starts with |output_freq_hz_1|. Except for the toggling, it does the same
75 // thing as AcmReceiveTestOldApi.
76 class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi {
77  public:
78   AcmReceiveTestToggleOutputFreqOldApi(
79       PacketSource* packet_source,
80       AudioSink* audio_sink,
81       int output_freq_hz_1,
82       int output_freq_hz_2,
83       int toggle_period_ms,
84       NumOutputChannels exptected_output_channels);
85 
86  protected:
87   void AfterGetAudio() override;
88 
89   const int output_freq_hz_1_;
90   const int output_freq_hz_2_;
91   const int toggle_period_ms_;
92   int64_t last_toggle_time_ms_;
93 };
94 
95 }  // namespace test
96 }  // namespace webrtc
97 #endif  // WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_OLDAPI_H_
98