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 | |
turaj@webrtc.org | 6ea3d1c | 2013-10-02 21:44:33 +0000 | [diff] [blame^] | 26 | class Config; |
| 27 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 28 | // TestPacketization callback which writes the encoded payloads to file |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 29 | class TestPacketization : public AudioPacketizationCallback { |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 30 | public: |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 31 | TestPacketization(RTPStream *rtpStream, uint16_t frequency); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 32 | ~TestPacketization(); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 33 | virtual int32_t SendData(const FrameType frameType, const uint8_t payloadType, |
| 34 | const uint32_t timeStamp, const uint8_t* payloadData, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 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, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 40 | int16_t seqNo, uint32_t timeStamp, uint32_t ssrc); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 41 | RTPStream* _rtpStream; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 42 | int32_t _frequency; |
| 43 | int16_t _seqNo; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 46 | class Sender { |
| 47 | public: |
| 48 | Sender(); |
| 49 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream); |
| 50 | void Teardown(); |
| 51 | void Run(); |
| 52 | bool Add10MsData(); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 53 | |
| 54 | //for auto_test and logging |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 55 | uint8_t testMode; |
| 56 | uint8_t codeId; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 57 | |
| 58 | private: |
| 59 | AudioCodingModule* _acm; |
| 60 | PCMFile _pcmFile; |
| 61 | AudioFrame _audioFrame; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 62 | TestPacketization* _packetization; |
| 63 | }; |
| 64 | |
| 65 | class Receiver { |
| 66 | public: |
| 67 | Receiver(); |
| 68 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream); |
| 69 | void Teardown(); |
| 70 | void Run(); |
| 71 | bool IncomingPacket(); |
| 72 | bool PlayoutData(); |
| 73 | |
| 74 | //for auto_test and logging |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 75 | uint8_t codeId; |
| 76 | uint8_t testMode; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 77 | |
| 78 | private: |
| 79 | AudioCodingModule* _acm; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 80 | RTPStream* _rtpStream; |
| 81 | PCMFile _pcmFile; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 82 | int16_t* _playoutBuffer; |
| 83 | uint16_t _playoutLengthSmpls; |
| 84 | uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD]; |
| 85 | uint16_t _payloadSizeBytes; |
| 86 | uint16_t _realPayloadSizeBytes; |
| 87 | int32_t _frequency; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 88 | bool _firstTime; |
| 89 | WebRtcRTPHeader _rtpInfo; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 90 | uint32_t _nextTime; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 93 | class EncodeDecodeTest : public ACMTest { |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 94 | public: |
turaj@webrtc.org | 6ea3d1c | 2013-10-02 21:44:33 +0000 | [diff] [blame^] | 95 | explicit EncodeDecodeTest(const Config& config); |
| 96 | EncodeDecodeTest(int testMode, const Config& config); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 97 | virtual void Perform(); |
| 98 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 99 | uint16_t _playoutFreq; |
| 100 | uint8_t _testMode; |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 101 | |
| 102 | private: |
| 103 | void EncodeToFile(int fileType, int codeId, int* codePars, int testMode); |
| 104 | |
turaj@webrtc.org | 6ea3d1c | 2013-10-02 21:44:33 +0000 | [diff] [blame^] | 105 | const Config& config_; |
| 106 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 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 | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 112 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
turaj@webrtc.org | 6ea3d1c | 2013-10-02 21:44:33 +0000 | [diff] [blame^] | 114 | #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_ |