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/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,
|
2018-12-05 10:30:25 +01:00
|
|
|
std::string in_file_name, int in_sample_rate,
|
|
|
|
|
int payload_type, SdpAudioFormat format);
|
2011-12-16 10:09:04 +00:00
|
|
|
void Teardown();
|
|
|
|
|
void Run();
|
|
|
|
|
bool Add10MsData();
|
|
|
|
|
|
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,
|
2018-12-05 10:30:25 +01:00
|
|
|
std::string out_file_name, size_t channels, int file_num);
|
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
|
|
|
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;
|
2019-02-18 12:00:06 +01:00
|
|
|
RTPHeader _rtpHeader;
|
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
|
|
|
};
|
|
|
|
|
|
2018-10-01 12:31:22 +02:00
|
|
|
class EncodeDecodeTest {
|
2011-12-16 10:09:04 +00:00
|
|
|
public:
|
2018-12-05 10:30:25 +01:00
|
|
|
EncodeDecodeTest();
|
2018-10-01 12:31:22 +02:00
|
|
|
void Perform();
|
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_
|