• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #ifndef MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
12 #define MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
13 
14 #include <memory>
15 
16 #include "modules/audio_coding/include/audio_coding_module.h"
17 #include "modules/audio_coding/test/PCMFile.h"
18 
19 namespace webrtc {
20 
21 class TestPack : public AudioPacketizationCallback {
22  public:
23   TestPack();
24   ~TestPack();
25 
26   void RegisterReceiverACM(AudioCodingModule* acm);
27 
28   int32_t SendData(AudioFrameType frame_type,
29                    uint8_t payload_type,
30                    uint32_t timestamp,
31                    const uint8_t* payload_data,
32                    size_t payload_size,
33                    int64_t absolute_capture_timestamp_ms) override;
34 
35   size_t payload_size();
36   uint32_t timestamp_diff();
37   void reset_payload_size();
38 
39  private:
40   AudioCodingModule* receiver_acm_;
41   uint16_t sequence_number_;
42   uint8_t payload_data_[60 * 32 * 2 * 2];
43   uint32_t timestamp_diff_;
44   uint32_t last_in_timestamp_;
45   uint64_t total_bytes_;
46   size_t payload_size_;
47 };
48 
49 class TestAllCodecs {
50  public:
51   TestAllCodecs();
52   ~TestAllCodecs();
53 
54   void Perform();
55 
56  private:
57   // The default value of '-1' indicates that the registration is based only on
58   // codec name, and a sampling frequency matching is not required.
59   // This is useful for codecs which support several sampling frequency.
60   // Note! Only mono mode is tested in this test.
61   void RegisterSendCodec(char side,
62                          char* codec_name,
63                          int32_t sampling_freq_hz,
64                          int rate,
65                          int packet_size,
66                          size_t extra_byte);
67 
68   void Run(TestPack* channel);
69   void OpenOutFile(int test_number);
70 
71   std::unique_ptr<AudioCodingModule> acm_a_;
72   std::unique_ptr<AudioCodingModule> acm_b_;
73   TestPack* channel_a_to_b_;
74   PCMFile infile_a_;
75   PCMFile outfile_b_;
76   int test_count_;
77   int packet_size_samples_;
78   size_t packet_size_bytes_;
79 };
80 
81 }  // namespace webrtc
82 
83 #endif  // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
84