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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_TEST_ENCODEDECODETEST_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_TEST_ENCODEDECODETEST_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
#include <stdio.h>
|
2014-05-23 15:16:51 +00:00
|
|
|
#include <string.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
|
|
|
|
#include "modules/audio_coding/test/ACMTest.h"
|
|
|
|
|
#include "modules/audio_coding/test/PCMFile.h"
|
|
|
|
|
#include "modules/audio_coding/test/RTPFile.h"
|
2018-04-12 22:44:09 +02:00
|
|
|
#include "modules/include/module_common_types.h"
|
2011-12-16 10:09:04 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
#define MAX_INCOMING_PAYLOAD 8096
|
|
|
|
|
|
|
|
|
|
// TestPacketization callback which writes the encoded payloads to file
|
2013-05-03 07:34:12 +00:00
|
|
|
class TestPacketization : public AudioPacketizationCallback {
|
2011-12-16 10:09:04 +00:00
|
|
|
public:
|
2013-04-09 00:28:06 +00:00
|
|
|
TestPacketization(RTPStream *rtpStream, uint16_t frequency);
|
2011-12-16 10:09:04 +00:00
|
|
|
~TestPacketization();
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t SendData(const FrameType frameType,
|
|
|
|
|
const uint8_t payloadType,
|
|
|
|
|
const uint32_t timeStamp,
|
|
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
const size_t payloadSize,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation) override;
|
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,
|
2013-05-03 07:34:12 +00:00
|
|
|
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();
|
2014-05-23 15:16:51 +00:00
|
|
|
void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
std::string in_file_name, int sample_rate, size_t channels);
|
2011-12-16 10:09:04 +00:00
|
|
|
void Teardown();
|
|
|
|
|
void Run();
|
|
|
|
|
bool Add10MsData();
|
|
|
|
|
|
2013-04-09 00:28:06 +00:00
|
|
|
uint8_t codeId;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-05-23 15:16:51 +00:00
|
|
|
protected:
|
2011-12-16 10:09:04 +00:00
|
|
|
AudioCodingModule* _acm;
|
2014-05-23 15:16:51 +00:00
|
|
|
|
|
|
|
|
private:
|
2011-12-16 10:09:04 +00:00
|
|
|
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();
|
2014-05-23 15:16:51 +00:00
|
|
|
virtual ~Receiver() {};
|
|
|
|
|
void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
std::string out_file_name, size_t channels);
|
2011-12-16 10:09:04 +00:00
|
|
|
void Teardown();
|
|
|
|
|
void Run();
|
2014-05-23 15:16:51 +00:00
|
|
|
virtual bool IncomingPacket();
|
2011-12-16 10:09:04 +00:00
|
|
|
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;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
private:
|
|
|
|
|
PCMFile _pcmFile;
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t* _playoutBuffer;
|
|
|
|
|
uint16_t _playoutLengthSmpls;
|
|
|
|
|
int32_t _frequency;
|
2011-12-16 10:09:04 +00:00
|
|
|
bool _firstTime;
|
2014-05-23 15:16:51 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
AudioCodingModule* _acm;
|
|
|
|
|
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
|
|
|
|
RTPStream* _rtpStream;
|
2011-12-16 10:09:04 +00:00
|
|
|
WebRtcRTPHeader _rtpInfo;
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t _realPayloadSizeBytes;
|
|
|
|
|
size_t _payloadSizeBytes;
|
2013-04-09 00:28:06 +00:00
|
|
|
uint32_t _nextTime;
|
2011-12-16 10:09:04 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class EncodeDecodeTest : public ACMTest {
|
2011-12-16 10:09:04 +00:00
|
|
|
public:
|
2018-06-14 13:12:05 +02:00
|
|
|
explicit EncodeDecodeTest(int test_mode);
|
2015-03-04 12:58:35 +00:00
|
|
|
void Perform() override;
|
2011-12-16 10:09:04 +00:00
|
|
|
|
2013-04-09 00:28:06 +00:00
|
|
|
uint16_t _playoutFreq;
|
2011-12-16 10:09:04 +00:00
|
|
|
|
|
|
|
|
private:
|
2018-06-14 13:12:05 +02:00
|
|
|
std::string EncodeToFile(int fileType, int codeId, int* codePars);
|
2011-12-16 10:09:04 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Sender _sender;
|
|
|
|
|
Receiver _receiver;
|
2012-08-01 01:40:02 +00:00
|
|
|
};
|
2011-12-16 10:09:04 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
} // namespace webrtc
|
2011-12-16 10:09:04 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_TEST_ENCODEDECODETEST_H_
|