2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-04-12 11:02:38 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
|
|
|
|
|
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
#include <stdio.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
#include "ACMTest.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
#include "audio_coding_module.h"
|
2011-12-16 10:09:04 +00:00
|
|
|
#include "RTPFile.h"
|
|
|
|
|
#include "PCMFile.h"
|
|
|
|
|
#include "typedefs.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
#define MAX_INCOMING_PAYLOAD 8096
|
|
|
|
|
|
|
|
|
|
// TestPacketization callback which writes the encoded payloads to file
|
|
|
|
|
class TestPacketization: public AudioPacketizationCallback {
|
|
|
|
|
public:
|
2013-04-09 00:28:06 +00:00
|
|
|
TestPacketization(RTPStream *rtpStream, uint16_t frequency);
|
2011-12-16 10:09:04 +00:00
|
|
|
~TestPacketization();
|
2013-04-09 00:28:06 +00:00
|
|
|
virtual int32_t SendData(const FrameType frameType,
|
|
|
|
|
const uint8_t payloadType,
|
|
|
|
|
const uint32_t timeStamp,
|
|
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
const uint16_t payloadSize,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
private:
|
2013-04-09 00:28:06 +00:00
|
|
|
static void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
|
|
|
|
|
int16_t seqNo, uint32_t timeStamp,
|
|
|
|
|
uint32_t ssrc);
|
2011-12-16 10:09:04 +00:00
|
|
|
RTPStream* _rtpStream;
|
2013-04-09 00:28:06 +00:00
|
|
|
int32_t _frequency;
|
|
|
|
|
int16_t _seqNo;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
class Sender {
|
|
|
|
|
public:
|
|
|
|
|
Sender();
|
|
|
|
|
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
|
|
|
|
|
void Teardown();
|
|
|
|
|
void Run();
|
|
|
|
|
bool Add10MsData();
|
|
|
|
|
bool Process();
|
|
|
|
|
|
|
|
|
|
//for auto_test and logging
|
2013-04-09 00:28:06 +00:00
|
|
|
uint8_t testMode;
|
|
|
|
|
uint8_t codeId;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
private:
|
|
|
|
|
AudioCodingModule* _acm;
|
|
|
|
|
PCMFile _pcmFile;
|
|
|
|
|
AudioFrame _audioFrame;
|
|
|
|
|
TestPacketization* _packetization;
|
|
|
|
|
};
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
class Receiver {
|
|
|
|
|
public:
|
|
|
|
|
Receiver();
|
|
|
|
|
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
|
|
|
|
|
void Teardown();
|
|
|
|
|
void Run();
|
|
|
|
|
bool IncomingPacket();
|
|
|
|
|
bool PlayoutData();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
//for auto_test and logging
|
2013-04-09 00:28:06 +00:00
|
|
|
uint8_t codeId;
|
|
|
|
|
uint8_t testMode;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
private:
|
|
|
|
|
AudioCodingModule* _acm;
|
|
|
|
|
RTPStream* _rtpStream;
|
|
|
|
|
PCMFile _pcmFile;
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t* _playoutBuffer;
|
|
|
|
|
uint16_t _playoutLengthSmpls;
|
|
|
|
|
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
|
|
|
|
uint16_t _payloadSizeBytes;
|
|
|
|
|
uint16_t _realPayloadSizeBytes;
|
|
|
|
|
int32_t _frequency;
|
2011-12-16 10:09:04 +00:00
|
|
|
bool _firstTime;
|
|
|
|
|
WebRtcRTPHeader _rtpInfo;
|
2013-04-09 00:28:06 +00:00
|
|
|
uint32_t _nextTime;
|
2011-12-16 10:09:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class EncodeDecodeTest: public ACMTest {
|
|
|
|
|
public:
|
|
|
|
|
EncodeDecodeTest();
|
|
|
|
|
EncodeDecodeTest(int testMode);
|
|
|
|
|
virtual void Perform();
|
|
|
|
|
|
2013-04-09 00:28:06 +00:00
|
|
|
uint16_t _playoutFreq;
|
|
|
|
|
uint8_t _testMode;
|
2011-12-16 10:09:04 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void EncodeToFile(int fileType, int codeId, int* codePars, int testMode);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Sender _sender;
|
|
|
|
|
Receiver _receiver;
|
2012-08-01 01:40:02 +00:00
|
|
|
};
|
2011-12-16 10:09:04 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif
|