2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_
16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
18 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h"
19 #include "webrtc/system_wrappers/interface/clock.h"
20 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
28 class AcmSendTest : public AudioPacketizationCallback, public PacketSource {
30 AcmSendTest(InputAudioFile* audio_source,
32 int test_duration_ms);
33 virtual ~AcmSendTest() {}
35 // Registers the send codec. Returns true on success, false otherwise.
36 bool RegisterCodec(int codec_type,
39 int frame_size_samples);
41 // Returns the next encoded packet. Returns NULL if the test duration was
42 // exceeded. Ownership of the packet is handed over to the caller.
43 // Inherited from PacketSource.
44 virtual Packet* NextPacket() OVERRIDE;
46 // Inherited from AudioPacketizationCallback.
47 virtual int32_t SendData(
51 const uint8_t* payload_data,
52 uint16_t payload_len_bytes,
53 const RTPFragmentationHeader* fragmentation) OVERRIDE;
56 static const int kBlockSizeMs = 10;
58 // Creates a Packet object from the last packet produced by ACM (and received
59 // through the SendData method as a callback). Ownership of the new Packet
60 // object is transferred to the caller.
61 Packet* CreatePacket();
63 SimulatedClock clock_;
64 scoped_ptr<AudioCoding> acm_;
65 InputAudioFile* audio_source_;
67 const int input_block_size_samples_;
68 AudioFrame input_frame_;
69 bool codec_registered_;
70 int test_duration_ms_;
71 // The following member variables are set whenever SendData() is called.
72 FrameType frame_type_;
75 uint16_t sequence_number_;
76 std::vector<uint8_t> last_payload_vec_;
78 DISALLOW_COPY_AND_ASSIGN(AcmSendTest);
83 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_