niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 14 | #include <stdio.h> |
| 15 | |
| 16 | #include "ACMTest.h" |
| 17 | #include "audio_coding_module.h" |
| 18 | #include "RTPFile.h" |
| 19 | #include "PCMFile.h" |
| 20 | #include "typedefs.h" |
| 21 | |
| 22 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
| 24 | #define MAX_INCOMING_PAYLOAD 8096 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 26 | // TestPacketization callback which writes the encoded payloads to file |
| 27 | class TestPacketization: public AudioPacketizationCallback { |
| 28 | public: |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 29 | TestPacketization(RTPStream *rtpStream, uint16_t frequency); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 30 | ~TestPacketization(); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 31 | virtual int32_t SendData(const FrameType frameType, |
| 32 | const uint8_t payloadType, |
| 33 | const uint32_t timeStamp, |
| 34 | const uint8_t* payloadData, |
| 35 | const uint16_t payloadSize, |
| 36 | const RTPFragmentationHeader* fragmentation); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 38 | private: |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 39 | static void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, |
| 40 | int16_t seqNo, uint32_t timeStamp, |
| 41 | uint32_t ssrc); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 42 | RTPStream* _rtpStream; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 43 | int32_t _frequency; |
| 44 | int16_t _seqNo; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 47 | class Sender { |
| 48 | public: |
| 49 | Sender(); |
| 50 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream); |
| 51 | void Teardown(); |
| 52 | void Run(); |
| 53 | bool Add10MsData(); |
| 54 | bool Process(); |
| 55 | |
| 56 | //for auto_test and logging |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 57 | uint8_t testMode; |
| 58 | uint8_t codeId; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 59 | |
| 60 | private: |
| 61 | AudioCodingModule* _acm; |
| 62 | PCMFile _pcmFile; |
| 63 | AudioFrame _audioFrame; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 64 | TestPacketization* _packetization; |
| 65 | }; |
| 66 | |
| 67 | class Receiver { |
| 68 | public: |
| 69 | Receiver(); |
| 70 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream); |
| 71 | void Teardown(); |
| 72 | void Run(); |
| 73 | bool IncomingPacket(); |
| 74 | bool PlayoutData(); |
| 75 | |
| 76 | //for auto_test and logging |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 77 | uint8_t codeId; |
| 78 | uint8_t testMode; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 79 | |
| 80 | private: |
| 81 | AudioCodingModule* _acm; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 82 | RTPStream* _rtpStream; |
| 83 | PCMFile _pcmFile; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 84 | int16_t* _playoutBuffer; |
| 85 | uint16_t _playoutLengthSmpls; |
| 86 | uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD]; |
| 87 | uint16_t _payloadSizeBytes; |
| 88 | uint16_t _realPayloadSizeBytes; |
| 89 | int32_t _frequency; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 90 | bool _firstTime; |
| 91 | WebRtcRTPHeader _rtpInfo; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 92 | uint32_t _nextTime; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | class EncodeDecodeTest: public ACMTest { |
| 96 | public: |
| 97 | EncodeDecodeTest(); |
| 98 | EncodeDecodeTest(int testMode); |
| 99 | virtual void Perform(); |
| 100 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 101 | uint16_t _playoutFreq; |
| 102 | uint8_t _testMode; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 103 | |
| 104 | private: |
| 105 | void EncodeToFile(int fileType, int codeId, int* codePars, int testMode); |
| 106 | |
| 107 | protected: |
| 108 | Sender _sender; |
| 109 | Receiver _receiver; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 110 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 112 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
| 114 | #endif |