1 /* 2 * Copyright (c) 2015 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_NETEQ_TOOLS_NETEQ_EXTERNAL_DECODER_TEST_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EXTERNAL_DECODER_TEST_H_ 13 14 #include <memory> 15 #include <string> 16 17 #include "api/audio_codecs/audio_decoder.h" 18 #include "common_types.h" // NOLINT(build/include) 19 #include "modules/audio_coding/neteq/include/neteq.h" 20 #include "modules/include/module_common_types.h" 21 22 namespace webrtc { 23 namespace test { 24 // This test class provides a way run NetEQ with an external decoder. 25 class NetEqExternalDecoderTest { 26 protected: 27 static const uint8_t kPayloadType = 95; 28 static const int kOutputLengthMs = 10; 29 30 // The external decoder |decoder| is suppose to be of type |codec|. 31 NetEqExternalDecoderTest(NetEqDecoder codec, 32 int sample_rate_hz, 33 AudioDecoder* decoder); 34 ~NetEqExternalDecoderTest()35 virtual ~NetEqExternalDecoderTest() { } 36 37 // In Init(), we register the external decoder. 38 void Init(); 39 40 // Inserts a new packet with |rtp_header| and |payload| of 41 // |payload_size_bytes| bytes. The |receive_timestamp| is an indication 42 // of the time when the packet was received, and should be measured with 43 // the same tick rate as the RTP timestamp of the current payload. 44 virtual void InsertPacket(RTPHeader rtp_header, 45 rtc::ArrayView<const uint8_t> payload, 46 uint32_t receive_timestamp); 47 48 // Get 10 ms of audio data. 49 void GetOutputAudio(AudioFrame* output); 50 neteq()51 NetEq* neteq() { return neteq_.get(); } 52 53 private: 54 NetEqDecoder codec_; 55 std::string name_ = "dummy name"; 56 AudioDecoder* decoder_; 57 int sample_rate_hz_; 58 size_t channels_; 59 std::unique_ptr<NetEq> neteq_; 60 }; 61 62 } // namespace test 63 } // namespace webrtc 64 65 #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EXTERNAL_DECODER_TEST_H_ 66