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_SEND_TEST_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_ 13 14 #include <vector> 15 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" 21 22 namespace webrtc { 23 24 namespace test { 25 class InputAudioFile; 26 class Packet; 27 28 class AcmSendTest : public AudioPacketizationCallback, public PacketSource { 29 public: 30 AcmSendTest(InputAudioFile* audio_source, 31 int source_rate_hz, 32 int test_duration_ms); 33 virtual ~AcmSendTest() {} 34 35 // Registers the send codec. Returns true on success, false otherwise. 36 bool RegisterCodec(int codec_type, 37 int channels, 38 int payload_type, 39 int frame_size_samples); 40 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; 45 46 // Inherited from AudioPacketizationCallback. 47 virtual int32_t SendData( 48 FrameType frame_type, 49 uint8_t payload_type, 50 uint32_t timestamp, 51 const uint8_t* payload_data, 52 uint16_t payload_len_bytes, 53 const RTPFragmentationHeader* fragmentation) OVERRIDE; 54 55 private: 56 static const int kBlockSizeMs = 10; 57 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(); 62 63 SimulatedClock clock_; 64 scoped_ptr<AudioCoding> acm_; 65 InputAudioFile* audio_source_; 66 int source_rate_hz_; 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_; 73 int payload_type_; 74 uint32_t timestamp_; 75 uint16_t sequence_number_; 76 std::vector<uint8_t> last_payload_vec_; 77 78 DISALLOW_COPY_AND_ASSIGN(AcmSendTest); 79 }; 80 81 } // namespace test 82 } // namespace webrtc 83 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SEND_TEST_H_ 84