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