blob: f407a6b357120392c32a095c447040f86632bdb0 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org554ae1a2011-12-16 10:09:04 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000014#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
22namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24#define MAX_INCOMING_PAYLOAD 8096
niklase@google.com470e71d2011-07-07 08:21:25 +000025
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000026// TestPacketization callback which writes the encoded payloads to file
27class TestPacketization: public AudioPacketizationCallback {
28 public:
29 TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency);
30 ~TestPacketization();
31 virtual WebRtc_Word32 SendData(const FrameType frameType,
32 const WebRtc_UWord8 payloadType,
33 const WebRtc_UWord32 timeStamp,
34 const WebRtc_UWord8* payloadData,
35 const WebRtc_UWord16 payloadSize,
36 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000038 private:
39 static void MakeRTPheader(WebRtc_UWord8* rtpHeader, WebRtc_UWord8 payloadType,
40 WebRtc_Word16 seqNo, WebRtc_UWord32 timeStamp,
41 WebRtc_UWord32 ssrc);
42 RTPStream* _rtpStream;
43 WebRtc_Word32 _frequency;
44 WebRtc_Word16 _seqNo;
niklase@google.com470e71d2011-07-07 08:21:25 +000045};
46
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000047class 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
57 WebRtc_UWord8 testMode;
58 WebRtc_UWord8 codeId;
59
60 private:
61 AudioCodingModule* _acm;
62 PCMFile _pcmFile;
63 AudioFrame _audioFrame;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000064 TestPacketization* _packetization;
65};
66
67class 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
77 WebRtc_UWord8 codeId;
78 WebRtc_UWord8 testMode;
79
80 private:
81 AudioCodingModule* _acm;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000082 RTPStream* _rtpStream;
83 PCMFile _pcmFile;
84 WebRtc_Word16* _playoutBuffer;
85 WebRtc_UWord16 _playoutLengthSmpls;
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000086 WebRtc_UWord8 _incomingPayload[MAX_INCOMING_PAYLOAD];
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000087 WebRtc_UWord16 _payloadSizeBytes;
88 WebRtc_UWord16 _realPayloadSizeBytes;
89 WebRtc_Word32 _frequency;
90 bool _firstTime;
91 WebRtcRTPHeader _rtpInfo;
92 WebRtc_UWord32 _nextTime;
93};
94
95class EncodeDecodeTest: public ACMTest {
96 public:
97 EncodeDecodeTest();
98 EncodeDecodeTest(int testMode);
99 virtual void Perform();
100
101 WebRtc_UWord16 _playoutFreq;
102 WebRtc_UWord8 _testMode;
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.orgd7a71d02012-08-01 01:40:02 +0000110};
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000112} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
114#endif