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