Deleting all NetEq3 files

NetEq3 is deprecated and replaced by NetEq4
(webrtc/modules/audio_coding/neteq4/).

BUG=2996
R=turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/14469007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6118 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2014-05-13 10:40:52 +00:00
parent 4d363ae305
commit c3e8abda7c
78 changed files with 0 additions and 26952 deletions

View File

@ -1,704 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "NETEQTEST_CodecClass.h"
#include <stdlib.h> // exit
#include "webrtc_neteq_help_macros.h"
NETEQTEST_Decoder::NETEQTEST_Decoder(enum WebRtcNetEQDecoder type, uint16_t fs, const char * name, uint8_t pt)
:
_decoder(NULL),
_decoderType(type),
_pt(pt),
_fs(fs),
_name(name)
{
}
int NETEQTEST_Decoder::loadToNetEQ(NETEQTEST_NetEQClass & neteq, WebRtcNetEQ_CodecDef & codecInst)
{
SET_CODEC_PAR(codecInst, _decoderType, _pt, _decoder, _fs);
int err = neteq.loadCodec(codecInst);
if (err)
{
printf("Error loading codec %s into NetEQ database\n", _name.c_str());
}
return(err);
}
// iSAC
#ifdef CODEC_ISAC
#include "isac.h"
decoder_iSAC::decoder_iSAC(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderISAC, 16000, "iSAC", pt)
{
int16_t err = WebRtcIsac_Create((ISACStruct **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
WebRtcIsac_EncoderInit((ISACStruct *) _decoder, 0);
WebRtcIsac_SetDecSampRate((ISACStruct *) _decoder, 16000);
}
decoder_iSAC::~decoder_iSAC()
{
if (_decoder)
{
WebRtcIsac_Free((ISACStruct *) _decoder);
_decoder = NULL;
}
}
int decoder_iSAC::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_ISAC_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_ISAC_SWB
decoder_iSACSWB::decoder_iSACSWB(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderISACswb, 32000, "iSAC swb", pt)
{
int16_t err = WebRtcIsac_Create((ISACStruct **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
WebRtcIsac_EncoderInit((ISACStruct *) _decoder, 0);
WebRtcIsac_SetDecSampRate((ISACStruct *) _decoder, 32000);
}
decoder_iSACSWB::~decoder_iSACSWB()
{
if (_decoder)
{
WebRtcIsac_Free((ISACStruct *) _decoder);
_decoder = NULL;
}
}
int decoder_iSACSWB::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_ISACSWB_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_ISAC_FB
decoder_iSACFB::decoder_iSACFB(uint8_t pt)
: NETEQTEST_Decoder(kDecoderISACfb, 32000, "iSAC fb", pt) {
int16_t err = WebRtcIsac_Create((ISACStruct **) &_decoder);
if (err) {
exit(EXIT_FAILURE);
}
WebRtcIsac_EncoderInit((ISACStruct *) _decoder, 0);
WebRtcIsac_SetDecSampRate((ISACStruct *) _decoder, 32000);
}
decoder_iSACFB::~decoder_iSACFB() {
if (_decoder) {
WebRtcIsac_Free((ISACStruct *) _decoder);
_decoder = NULL;
}
}
int decoder_iSACFB::loadToNetEQ(NETEQTEST_NetEQClass & neteq){
WebRtcNetEQ_CodecDef codecInst;
SET_ISACFB_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
// PCM u/A
#ifdef CODEC_G711
#include "g711_interface.h"
decoder_PCMU::decoder_PCMU(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderPCMu, 8000, "G.711-u", pt)
{
// no state to crate or init
}
int decoder_PCMU::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCMU_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
decoder_PCMA::decoder_PCMA(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderPCMa, 8000, "G.711-A", pt)
{
// no state to crate or init
}
int decoder_PCMA::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCMA_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
// Linear PCM16b
#if (defined(CODEC_PCM16B) || defined(CODEC_PCM16B_WB) || \
defined(CODEC_PCM16B_32KHZ) || defined(CODEC_PCM16B_48KHZ))
#include "pcm16b.h"
#endif
#ifdef CODEC_PCM16B
int decoder_PCM16B_NB::loadToNetEQ(NETEQTEST_NetEQClass &neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCM16B_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_PCM16B_WB
int decoder_PCM16B_WB::loadToNetEQ(NETEQTEST_NetEQClass &neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCM16B_WB_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_PCM16B_32KHZ
int decoder_PCM16B_SWB32::loadToNetEQ(NETEQTEST_NetEQClass &neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCM16B_SWB32_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_PCM16B_48KHZ
int decoder_PCM16B_SWB48::loadToNetEQ(NETEQTEST_NetEQClass &neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_PCM16B_SWB48_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_ILBC
#include "ilbc.h"
decoder_ILBC::decoder_ILBC(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderILBC, 8000, "iLBC", pt)
{
int16_t err = WebRtcIlbcfix_DecoderCreate((iLBC_decinst_t **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
}
decoder_ILBC::~decoder_ILBC()
{
WebRtcIlbcfix_DecoderFree((iLBC_decinst_t *) _decoder);
}
int decoder_ILBC::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_ILBC_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G729
#include "G729Interface.h"
decoder_G729::decoder_G729(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG729, 8000, "G.729", pt)
{
int16_t err = WebRtcG729_CreateDec((G729_decinst_t **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
}
decoder_G729::~decoder_G729()
{
WebRtcG729_FreeDec((G729_decinst_t *) _decoder);
}
int decoder_G729::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G729_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G729_1
#include "G729_1Interface.h"
decoder_G729_1::decoder_G729_1(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG729_1, 16000, "G.729.1", pt)
{
int16_t err = WebRtcG7291_Create((G729_1_inst_t **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
}
decoder_G729_1::~decoder_G729_1()
{
WebRtcG7291_Free((G729_1_inst_t *) _decoder);
}
int decoder_G729_1::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G729_1_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722
#include "g722_interface.h"
decoder_G722::decoder_G722(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722, 16000, "G.722", pt)
{
int16_t err = WebRtcG722_CreateDecoder((G722DecInst **) &_decoder);
if (err)
{
exit(EXIT_FAILURE);
}
}
decoder_G722::~decoder_G722()
{
WebRtcG722_FreeDecoder((G722DecInst *) _decoder);
}
int decoder_G722::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#if (defined(CODEC_G722_1_16) || defined(CODEC_G722_1_24) || \
defined(CODEC_G722_1_32) || defined(CODEC_G722_1C_24) || \
defined(CODEC_G722_1C_32) || defined(CODEC_G722_1C_48))
#include "G722_1Interface.h"
#endif
#ifdef CODEC_G722_1_16
decoder_G722_1_16::decoder_G722_1_16(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1_16, 16000, "G.722.1 (16 kbps)", pt)
{
if (WebRtcG7221_CreateDec16((G722_1_16_decinst_t **) &_decoder))
{
exit(EXIT_FAILURE);
}
}
decoder_G722_1_16::~decoder_G722_1_16()
{
WebRtcG7221_FreeDec16((G722_1_16_decinst_t *) _decoder);
}
int decoder_G722_1_16::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1_16_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722_1_24
decoder_G722_1_24::decoder_G722_1_24(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1_24, 16000, "G.722.1 (24 kbps)", pt)
{
if (WebRtcG7221_CreateDec24((G722_1_24_decinst_t **) &_decoder))
{
exit(EXIT_FAILURE);
}
}
decoder_G722_1_24::~decoder_G722_1_24()
{
WebRtcG7221_FreeDec24((G722_1_24_decinst_t *) _decoder);
}
int decoder_G722_1_24::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1_24_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722_1_32
decoder_G722_1_32::decoder_G722_1_32(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1_32, 16000, "G.722.1 (32 kbps)", pt)
{
if (WebRtcG7221_CreateDec32((G722_1_32_decinst_t **) &_decoder))
{
exit(EXIT_FAILURE);
}
}
decoder_G722_1_32::~decoder_G722_1_32()
{
WebRtcG7221_FreeDec32((G722_1_32_decinst_t *) _decoder);
}
int decoder_G722_1_32::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1_32_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722_1C_24
decoder_G722_1C_24::decoder_G722_1C_24(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1C_24, 32000, "G.722.1C (24 kbps)", pt)
{
if (WebRtcG7221C_CreateDec24((G722_1C_24_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
}
decoder_G722_1C_24::~decoder_G722_1C_24()
{
WebRtcG7221C_FreeDec24((G722_1C_24_decinst_t *) _decoder);
}
int decoder_G722_1C_24::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1C_24_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722_1C_32
decoder_G722_1C_32::decoder_G722_1C_32(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1C_32, 32000, "G.722.1C (32 kbps)", pt)
{
if (WebRtcG7221C_CreateDec32((G722_1C_32_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
}
decoder_G722_1C_32::~decoder_G722_1C_32()
{
WebRtcG7221C_FreeDec32((G722_1C_32_decinst_t *) _decoder);
}
int decoder_G722_1C_32::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1C_32_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_G722_1C_48
decoder_G722_1C_48::decoder_G722_1C_48(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderG722_1C_48, 32000, "G.722.1C (48 kbps)", pt)
{
if (WebRtcG7221C_CreateDec48((G722_1C_48_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
}
decoder_G722_1C_48::~decoder_G722_1C_48()
{
WebRtcG7221C_FreeDec48((G722_1C_48_decinst_t *) _decoder);
}
int decoder_G722_1C_48::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_G722_1C_48_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_AMR
#include "AMRInterface.h"
#include "AMRCreation.h"
decoder_AMR::decoder_AMR(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderAMR, 8000, "AMR", pt)
{
if (WebRtcAmr_CreateDec((AMR_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
WebRtcAmr_DecodeBitmode((AMR_decinst_t *) _decoder, AMRBandwidthEfficient);
}
decoder_AMR::~decoder_AMR()
{
WebRtcAmr_FreeDec((AMR_decinst_t *) _decoder);
}
int decoder_AMR::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_AMR_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_AMRWB
#include "AMRWBInterface.h"
#include "AMRWBCreation.h"
decoder_AMRWB::decoder_AMRWB(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderAMRWB, 16000, "AMR wb", pt)
{
if (WebRtcAmrWb_CreateDec((AMRWB_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
WebRtcAmrWb_DecodeBitmode((AMRWB_decinst_t *) _decoder, AMRBandwidthEfficient);
}
decoder_AMRWB::~decoder_AMRWB()
{
WebRtcAmrWb_FreeDec((AMRWB_decinst_t *) _decoder);
}
int decoder_AMRWB::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_AMRWB_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_GSMFR
#include "GSMFRInterface.h"
#include "GSMFRCreation.h"
decoder_GSMFR::decoder_GSMFR(uint8_t pt)
:
NETEQTEST_Decoder(kDecoderGSMFR, 8000, "GSM-FR", pt)
{
if (WebRtcGSMFR_CreateDec((GSMFR_decinst_t **) &_decoder))
exit(EXIT_FAILURE);
}
decoder_GSMFR::~decoder_GSMFR()
{
WebRtcGSMFR_FreeDec((GSMFR_decinst_t *) _decoder);
}
int decoder_GSMFR::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_GSMFR_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#if (defined(CODEC_SPEEX_8) || defined (CODEC_SPEEX_16))
#include "SpeexInterface.h"
decoder_SPEEX::decoder_SPEEX(uint8_t pt, uint16_t fs)
:
NETEQTEST_Decoder(fs == 8000 ? kDecoderSPEEX_8 : kDecoderSPEEX_16,
fs, "SPEEX", pt)
{
if (fs != 8000 && fs != 16000)
throw std::exception("Wrong sample rate for SPEEX");
if (WebRtcSpeex_CreateDec((SPEEX_decinst_t **) &_decoder, fs, 1))
exit(EXIT_FAILURE);
}
decoder_SPEEX::~decoder_SPEEX()
{
WebRtcSpeex_FreeDec((SPEEX_decinst_t *) _decoder);
}
int decoder_SPEEX::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_SPEEX_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_CELT_32
#include "celt_interface.h"
decoder_CELT::decoder_CELT(uint8_t pt, uint16_t fs)
:
NETEQTEST_Decoder(kDecoderCELT_32, fs, "CELT", pt)
{
if (WebRtcCelt_CreateDec((CELT_decinst_t **) &_decoder, 2))
exit(EXIT_FAILURE);
}
decoder_CELT::~decoder_CELT()
{
WebRtcCelt_FreeDec((CELT_decinst_t *) _decoder);
}
int decoder_CELT::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_CELT_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
decoder_CELTslave::decoder_CELTslave(uint8_t pt, uint16_t fs)
:
NETEQTEST_Decoder(kDecoderCELT_32, fs, "CELT", pt)
{
if (WebRtcCelt_CreateDec((CELT_decinst_t **) &_decoder, 2))
exit(EXIT_FAILURE);
}
decoder_CELTslave::~decoder_CELTslave()
{
WebRtcCelt_FreeDec((CELT_decinst_t *) _decoder);
}
int decoder_CELTslave::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_CELTSLAVE_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_RED
int decoder_RED::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_RED_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#ifdef CODEC_ATEVENT_DECODE
int decoder_AVT::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_AVT_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif
#if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \
defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48))
#include "webrtc_cng.h"
decoder_CNG::decoder_CNG(uint8_t pt, uint16_t fs)
:
NETEQTEST_Decoder(kDecoderCNG, fs, "CNG", pt)
{
if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000)
exit(EXIT_FAILURE);
if (WebRtcCng_CreateDec((CNG_dec_inst **) &_decoder))
exit(EXIT_FAILURE);
}
decoder_CNG::~decoder_CNG()
{
WebRtcCng_FreeDec((CNG_dec_inst *) _decoder);
}
int decoder_CNG::loadToNetEQ(NETEQTEST_NetEQClass & neteq)
{
WebRtcNetEQ_CodecDef codecInst;
SET_CNG_FUNCTIONS(codecInst);
return(NETEQTEST_Decoder::loadToNetEQ(neteq, codecInst));
}
#endif

View File

@ -1,316 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef NETEQTEST_CODECCLASS_H
#define NETEQTEST_CODECCLASS_H
#include <string>
#include <string.h>
#include "typedefs.h"
#include "webrtc_neteq.h"
#include "NETEQTEST_NetEQClass.h"
class NETEQTEST_Decoder
{
public:
NETEQTEST_Decoder(enum WebRtcNetEQDecoder type, uint16_t fs, const char * name, uint8_t pt = 0);
virtual ~NETEQTEST_Decoder() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) = 0;
int getName(char * name, int maxLen) const { strncpy( name, _name.c_str(), maxLen ); return 0;};
void setPT(uint8_t pt) { _pt = pt; };
uint16_t getFs() const { return (_fs); };
enum WebRtcNetEQDecoder getType() const { return (_decoderType); };
uint8_t getPT() const { return (_pt); };
protected:
int loadToNetEQ(NETEQTEST_NetEQClass & neteq, WebRtcNetEQ_CodecDef & codecInst);
void * _decoder;
enum WebRtcNetEQDecoder _decoderType;
uint8_t _pt;
uint16_t _fs;
std::string _name;
private:
};
class decoder_iSAC : public NETEQTEST_Decoder
{
public:
decoder_iSAC(uint8_t pt = 0);
virtual ~decoder_iSAC();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_iSACSWB : public NETEQTEST_Decoder
{
public:
decoder_iSACSWB(uint8_t pt = 0);
virtual ~decoder_iSACSWB();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_iSACFB : public NETEQTEST_Decoder {
public:
decoder_iSACFB(uint8_t pt = 0);
virtual ~decoder_iSACFB();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCMU : public NETEQTEST_Decoder
{
public:
decoder_PCMU(uint8_t pt = 0);
virtual ~decoder_PCMU() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCMA : public NETEQTEST_Decoder
{
public:
decoder_PCMA(uint8_t pt = 0);
virtual ~decoder_PCMA() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCM16B_NB : public NETEQTEST_Decoder
{
public:
decoder_PCM16B_NB(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderPCM16B, 8000, "PCM16 nb", pt) {};
virtual ~decoder_PCM16B_NB() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCM16B_WB : public NETEQTEST_Decoder
{
public:
decoder_PCM16B_WB(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderPCM16Bwb, 16000, "PCM16 wb", pt) {};
virtual ~decoder_PCM16B_WB() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCM16B_SWB32 : public NETEQTEST_Decoder
{
public:
decoder_PCM16B_SWB32(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderPCM16Bswb32kHz, 32000, "PCM16 swb32", pt) {};
virtual ~decoder_PCM16B_SWB32() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_PCM16B_SWB48 : public NETEQTEST_Decoder
{
public:
decoder_PCM16B_SWB48(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderPCM16Bswb48kHz, 48000, "PCM16 swb48", pt) {};
virtual ~decoder_PCM16B_SWB48() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_ILBC : public NETEQTEST_Decoder
{
public:
decoder_ILBC(uint8_t pt = 0);
virtual ~decoder_ILBC();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G729 : public NETEQTEST_Decoder
{
public:
decoder_G729(uint8_t pt = 0);
virtual ~decoder_G729();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G729_1 : public NETEQTEST_Decoder
{
public:
decoder_G729_1(uint8_t pt = 0);
virtual ~decoder_G729_1();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722 : public NETEQTEST_Decoder
{
public:
decoder_G722(uint8_t pt = 0);
virtual ~decoder_G722();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1_16 : public NETEQTEST_Decoder
{
public:
decoder_G722_1_16(uint8_t pt = 0);
virtual ~decoder_G722_1_16();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1_24 : public NETEQTEST_Decoder
{
public:
decoder_G722_1_24(uint8_t pt = 0);
virtual ~decoder_G722_1_24();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1_32 : public NETEQTEST_Decoder
{
public:
decoder_G722_1_32(uint8_t pt = 0);
virtual ~decoder_G722_1_32();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1C_24 : public NETEQTEST_Decoder
{
public:
decoder_G722_1C_24(uint8_t pt = 0);
virtual ~decoder_G722_1C_24();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1C_32 : public NETEQTEST_Decoder
{
public:
decoder_G722_1C_32(uint8_t pt = 0);
virtual ~decoder_G722_1C_32();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G722_1C_48 : public NETEQTEST_Decoder
{
public:
decoder_G722_1C_48(uint8_t pt = 0);
virtual ~decoder_G722_1C_48();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_AMR : public NETEQTEST_Decoder
{
public:
decoder_AMR(uint8_t pt = 0);
virtual ~decoder_AMR();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_AMRWB : public NETEQTEST_Decoder
{
public:
decoder_AMRWB(uint8_t pt = 0);
virtual ~decoder_AMRWB();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_GSMFR : public NETEQTEST_Decoder
{
public:
decoder_GSMFR(uint8_t pt = 0);
virtual ~decoder_GSMFR();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G726 : public NETEQTEST_Decoder
{
public:
//virtual decoder_G726(uint8_t pt = 0) = 0;
decoder_G726(enum WebRtcNetEQDecoder type, const char * name, uint8_t pt = 0);
virtual ~decoder_G726();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) = 0;
};
class decoder_G726_16 : public decoder_G726
{
public:
decoder_G726_16(uint8_t pt = 0) : decoder_G726(kDecoderG726_16, "G.726 (16 kbps)", pt) {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G726_24 : public decoder_G726
{
public:
decoder_G726_24(uint8_t pt = 0) : decoder_G726(kDecoderG726_24, "G.726 (24 kbps)", pt) {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G726_32 : public decoder_G726
{
public:
decoder_G726_32(uint8_t pt = 0) : decoder_G726(kDecoderG726_32, "G.726 (32 kbps)", pt) {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_G726_40 : public decoder_G726
{
public:
decoder_G726_40(uint8_t pt = 0) : decoder_G726(kDecoderG726_40, "G.726 (40 kbps)", pt) {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_SPEEX : public NETEQTEST_Decoder
{
public:
decoder_SPEEX(uint8_t pt = 0, uint16_t fs = 8000);
virtual ~decoder_SPEEX();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_CELT : public NETEQTEST_Decoder
{
public:
decoder_CELT(uint8_t pt = 0, uint16_t fs = 32000);
virtual ~decoder_CELT();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_CELTslave : public NETEQTEST_Decoder
{
public:
decoder_CELTslave(uint8_t pt = 0, uint16_t fs = 32000);
virtual ~decoder_CELTslave();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_RED : public NETEQTEST_Decoder
{
public:
decoder_RED(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderRED, 8000, "RED", pt) {};
virtual ~decoder_RED() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_AVT : public NETEQTEST_Decoder
{
public:
decoder_AVT(uint8_t pt = 0) : NETEQTEST_Decoder(kDecoderAVT, 8000, "AVT", pt) {};
virtual ~decoder_AVT() {};
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
class decoder_CNG : public NETEQTEST_Decoder
{
public:
decoder_CNG(uint8_t pt = 0, uint16_t fs = 8000);
virtual ~decoder_CNG();
virtual int loadToNetEQ(NETEQTEST_NetEQClass & neteq) OVERRIDE;
};
#endif //NETEQTEST_CODECCLASS_H

View File

@ -1,210 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "NETEQTEST_DummyRTPpacket.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm> // max
#ifdef WIN32
#include <winsock2.h>
#else
#include <netinet/in.h> // for htons, htonl, etc
#endif
int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
{
if (!fp)
{
return -1;
}
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length, 2, 1, fp) == 0)
{
reset();
return -2;
}
length = ntohs(length);
if (fread(&plen, 2, 1, fp) == 0)
{
reset();
return -1;
}
packetLen = ntohs(plen);
if (fread(&offset, 4, 1, fp) == 0)
{
reset();
return -1;
}
// Store in local variable until we have passed the reset below.
uint32_t receiveTime = ntohl(offset);
// Use length here because a plen of 0 specifies rtcp.
length = (uint16_t) (length - _kRDHeaderLen);
// check buffer size
if (_datagram && _memSize < length + 1)
{
reset();
}
if (!_datagram)
{
// Add one extra byte, to be able to fake a dummy payload of one byte.
_datagram = new uint8_t[length + 1];
_memSize = length + 1;
}
memset(_datagram, 0, length + 1);
if (length == 0)
{
_datagramLen = 0;
return packetLen;
}
// Read basic header
if (fread(_datagram, 1, _kBasicHeaderLen, fp)
!= (size_t)_kBasicHeaderLen)
{
reset();
return -1;
}
_receiveTime = receiveTime;
_datagramLen = _kBasicHeaderLen;
int header_length = _kBasicHeaderLen;
// Parse the basic header
WebRtcNetEQ_RTPInfo tempRTPinfo;
int P, X, CC;
parseBasicHeader(&tempRTPinfo, &P, &X, &CC);
// Check if we have to extend the header
if (X != 0 || CC != 0)
{
int newLen = _kBasicHeaderLen + CC * 4 + X * 4;
assert(_memSize >= newLen + 1);
// Read extension from file
size_t readLen = newLen - _kBasicHeaderLen;
if (fread(_datagram + _kBasicHeaderLen, 1, readLen,
fp) != readLen)
{
reset();
return -1;
}
_datagramLen = newLen;
header_length = newLen;
if (X != 0)
{
int totHdrLen = calcHeaderLength(X, CC);
assert(_memSize >= totHdrLen);
// Read extension from file
size_t readLen = totHdrLen - newLen;
if (fread(_datagram + newLen, 1, readLen, fp)
!= readLen)
{
reset();
return -1;
}
_datagramLen = totHdrLen;
header_length = totHdrLen;
}
}
// Make sure that we have at least one byte of dummy payload.
_datagramLen = std::max(static_cast<int>(length), header_length + 1);
assert(_datagramLen <= _memSize);
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
readNextPacket = true;
}
if (_filterSSRC && _selectSSRC != SSRC())
{
// Discard this payload.
readNextPacket = true;
}
}
return packetLen;
}
int NETEQTEST_DummyRTPpacket::writeToFile(FILE *fp)
{
if (!fp)
{
return -1;
}
uint16_t length, plen;
uint32_t offset;
// length including RTPplay header
length = htons(_datagramLen + _kRDHeaderLen);
if (fwrite(&length, 2, 1, fp) != 1)
{
return -1;
}
// payload length
plen = htons(_datagramLen);
if (fwrite(&plen, 2, 1, fp) != 1)
{
return -1;
}
// offset (=receive time)
offset = htonl(_receiveTime);
if (fwrite(&offset, 4, 1, fp) != 1)
{
return -1;
}
// Figure out the length of the RTP header.
int headerLen;
if (_datagramLen == 0)
{
// No payload at all; we are done writing to file.
headerLen = 0;
}
else
{
parseHeader();
headerLen = _payloadPtr - _datagram;
assert(headerLen >= 0);
}
// write RTP header
if (fwrite((unsigned short *) _datagram, 1, headerLen, fp) !=
static_cast<size_t>(headerLen))
{
return -1;
}
return (headerLen + _kRDHeaderLen); // total number of bytes written
}

View File

@ -1,22 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef NETEQTEST_DUMMYRTPPACKET_H
#define NETEQTEST_DUMMYRTPPACKET_H
#include "NETEQTEST_RTPpacket.h"
class NETEQTEST_DummyRTPpacket : public NETEQTEST_RTPpacket {
public:
virtual int readFromFile(FILE* fp) OVERRIDE;
virtual int writeToFile(FILE* fp) OVERRIDE;
};
#endif // NETEQTEST_DUMMYRTPPACKET_H

View File

@ -1,395 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include <memory.h>
#include "NETEQTEST_NetEQClass.h"
NETEQTEST_NetEQClass::NETEQTEST_NetEQClass()
:
_inst(NULL),
_instMem(NULL),
_bufferMem(NULL),
_preparseRTP(false),
_fsmult(1),
_isMaster(true),
_noDecode(false)
{
#ifdef WINDOWS_TIMING
_totTimeRecIn.QuadPart = 0;
_totTimeRecOut.QuadPart = 0;
#endif
}
NETEQTEST_NetEQClass::NETEQTEST_NetEQClass(enum WebRtcNetEQDecoder *usedCodec, int noOfCodecs,
uint16_t fs, WebRtcNetEQNetworkType nwType)
:
_inst(NULL),
_instMem(NULL),
_bufferMem(NULL),
_preparseRTP(false),
_fsmult(1),
_isMaster(true),
_noDecode(false)
{
#ifdef WINDOWS_TIMING
_totTimeRecIn.QuadPart = 0;
_totTimeRecOut.QuadPart = 0;
#endif
if (assign() == 0)
{
if (init(fs) == 0)
{
assignBuffer(usedCodec, noOfCodecs, nwType);
}
}
}
NETEQTEST_NetEQClass::~NETEQTEST_NetEQClass()
{
if (_instMem)
{
delete [] _instMem;
_instMem = NULL;
}
if (_bufferMem)
{
delete [] _bufferMem;
_bufferMem = NULL;
}
_inst = NULL;
}
int NETEQTEST_NetEQClass::assign()
{
int memSize;
WebRtcNetEQ_AssignSize(&memSize);
if (_instMem)
{
delete [] _instMem;
_instMem = NULL;
}
_instMem = new int8_t[memSize];
int ret = WebRtcNetEQ_Assign(&_inst, _instMem);
if (ret)
{
printError();
}
return (ret);
}
int NETEQTEST_NetEQClass::init(uint16_t fs)
{
int ret;
if (!_inst)
{
// not assigned
ret = assign();
if (ret != 0)
{
printError();
return (ret);
}
}
ret = WebRtcNetEQ_Init(_inst, fs);
if (ret != 0)
{
printError();
}
return (ret);
}
int NETEQTEST_NetEQClass::assignBuffer(enum WebRtcNetEQDecoder *usedCodec, int noOfCodecs, WebRtcNetEQNetworkType nwType)
{
int numPackets, memSize, ret, overhead_bytes;
if (!_inst)
{
// not assigned
ret = assign();
if (ret != 0)
{
printError();
return (ret);
}
ret = init();
if (ret != 0)
{
printError();
return (ret);
}
}
ret = WebRtcNetEQ_GetRecommendedBufferSize(_inst, usedCodec, noOfCodecs,
nwType, &numPackets, &memSize,
&overhead_bytes);
if (ret != 0)
{
printError();
return (ret);
}
if (_bufferMem)
{
delete [] _bufferMem;
_bufferMem = NULL;
}
_bufferMem = new int8_t[memSize];
memset(_bufferMem, -1, memSize);
ret = WebRtcNetEQ_AssignBuffer(_inst, numPackets, _bufferMem, memSize);
if (ret != 0)
{
printError();
}
return (ret);
}
int NETEQTEST_NetEQClass::loadCodec(WebRtcNetEQ_CodecDef &codecInst)
{
int err = WebRtcNetEQ_CodecDbAdd(_inst, &codecInst);
if (err)
{
printError();
}
return (err);
}
void NETEQTEST_NetEQClass::printError()
{
if (_inst)
{
int errorCode = WebRtcNetEQ_GetErrorCode(_inst);
if (errorCode)
{
char errorName[WEBRTC_NETEQ_MAX_ERROR_NAME];
WebRtcNetEQ_GetErrorName(errorCode, errorName, WEBRTC_NETEQ_MAX_ERROR_NAME);
printf("Error %i: %s\n", errorCode, errorName);
}
}
}
void NETEQTEST_NetEQClass::printError(NETEQTEST_RTPpacket &rtp)
{
// print regular error info
printError();
// print extra info from packet
printf("\tRTP: TS=%u, SN=%u, PT=%u, M=%i, len=%i\n",
rtp.timeStamp(), rtp.sequenceNumber(), rtp.payloadType(),
rtp.markerBit(), rtp.payloadLen());
}
int NETEQTEST_NetEQClass::recIn(NETEQTEST_RTPpacket &rtp)
{
int err;
#ifdef WINDOWS_TIMING
LARGE_INTEGER countA, countB;
#endif
if (_preparseRTP)
{
WebRtcNetEQ_RTPInfo rtpInfo;
// parse RTP header
rtp.parseHeader(rtpInfo);
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countA); // get start count for processor
#endif
err = WebRtcNetEQ_RecInRTPStruct(_inst, &rtpInfo, rtp.payload(), rtp.payloadLen(), rtp.time() * _fsmult * 8);
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countB); // get stop count for processor
_totTimeRecIn.QuadPart += (countB.QuadPart - countA.QuadPart);
#endif
}
else
{
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countA); // get start count for processor
#endif
err = WebRtcNetEQ_RecIn(_inst, (int16_t *) rtp.datagram(), rtp.dataLen(), rtp.time() * _fsmult * 8);
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countB); // get stop count for processor
_totTimeRecIn.QuadPart += (countB.QuadPart - countA.QuadPart);
#endif
}
if (err)
{
printError(rtp);
}
return (err);
}
int16_t NETEQTEST_NetEQClass::recOut(int16_t *outData, void *msInfo, enum WebRtcNetEQOutputType *outputType)
{
int err;
int16_t outLen = 0;
#ifdef WINDOWS_TIMING
LARGE_INTEGER countA, countB;
#endif
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countA); // get start count for processor
#endif
if (!msInfo)
{
// no msInfo given, do mono mode
if (_noDecode)
{
err = WebRtcNetEQ_RecOutNoDecode(_inst, outData, &outLen);
}
else
{
err = WebRtcNetEQ_RecOut(_inst, outData, &outLen);
}
}
else
{
// master/slave mode
err = WebRtcNetEQ_RecOutMasterSlave(_inst, outData, &outLen, msInfo, static_cast<int16_t>(_isMaster));
}
#ifdef WINDOWS_TIMING
QueryPerformanceCounter(&countB); // get stop count for processor
_totTimeRecOut.QuadPart += (countB.QuadPart - countA.QuadPart);
#endif
if (err)
{
printError();
}
else
{
int newfsmult = static_cast<int>(outLen / 80);
if (newfsmult != _fsmult)
{
#ifdef NETEQTEST_PRINT_WARNINGS
printf("Warning: output sample rate changed\n");
#endif // NETEQTEST_PRINT_WARNINGS
_fsmult = newfsmult;
}
}
if (outputType != NULL)
{
err = WebRtcNetEQ_GetSpeechOutputType(_inst, outputType);
if (err)
{
printError();
}
}
return (outLen);
}
uint32_t NETEQTEST_NetEQClass::getSpeechTimeStamp()
{
uint32_t ts = 0;
int err;
err = WebRtcNetEQ_GetSpeechTimeStamp(_inst, &ts);
if (err)
{
printError();
ts = 0;
}
return (ts);
}
WebRtcNetEQOutputType NETEQTEST_NetEQClass::getOutputType() {
WebRtcNetEQOutputType type;
int err = WebRtcNetEQ_GetSpeechOutputType(_inst, &type);
if (err)
{
printError();
type = kOutputNormal;
}
return (type);
}
//NETEQTEST_NetEQVector::NETEQTEST_NetEQVector(int numChannels)
//:
//channels(numChannels, new NETEQTEST_NetEQClass())
//{
// //for (int i = 0; i < numChannels; i++)
// //{
// // channels.push_back(new NETEQTEST_NetEQClass());
// //}
//}
//
//NETEQTEST_NetEQVector::NETEQTEST_NetEQVector(int numChannels, enum WebRtcNetEQDecoder *usedCodec, int noOfCodecs,
// uint16_t fs, WebRtcNetEQNetworkType nwType)
// :
//channels(numChannels, new NETEQTEST_NetEQClass(usedCodec, noOfCodecs, fs, nwType))
//{
// //for (int i = 0; i < numChannels; i++)
// //{
// // channels.push_back(new NETEQTEST_NetEQClass(usedCodec, noOfCodecs, fs, nwType));
// //}
//}
//
//NETEQTEST_NetEQVector::~NETEQTEST_NetEQVector()
//{
//}

View File

@ -1,81 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef NETEQTEST_NETEQCLASS_H
#define NETEQTEST_NETEQCLASS_H
#include <stdio.h>
#include <vector>
#include "webrtc_neteq.h"
#include "webrtc_neteq_internal.h"
#include "NETEQTEST_RTPpacket.h"
#ifdef WIN32
#define WINDOWS_TIMING // complexity measurement only implemented for windows
//TODO(hlundin):Add complexity testing for Linux.
#include <windows.h>
#endif
class NETEQTEST_NetEQClass
{
public:
NETEQTEST_NetEQClass();
NETEQTEST_NetEQClass(enum WebRtcNetEQDecoder *usedCodec, int noOfCodecs,
uint16_t fs = 8000, WebRtcNetEQNetworkType nwType = kTCPLargeJitter);
~NETEQTEST_NetEQClass();
int assign();
int init(uint16_t fs = 8000);
int assignBuffer(enum WebRtcNetEQDecoder *usedCodec, int noOfCodecs, WebRtcNetEQNetworkType nwType = kTCPLargeJitter);
int loadCodec(WebRtcNetEQ_CodecDef & codecInst);
int recIn(NETEQTEST_RTPpacket & rtp);
int16_t recOut(int16_t *outData, void *msInfo = NULL, enum WebRtcNetEQOutputType *outputType = NULL);
uint32_t getSpeechTimeStamp();
WebRtcNetEQOutputType getOutputType();
void * instance() { return (_inst); };
void usePreparseRTP( bool useIt = true ) { _preparseRTP = useIt; };
bool usingPreparseRTP() { return (_preparseRTP); };
void setMaster( bool isMaster = true ) { _isMaster = isMaster; };
void setSlave() { _isMaster = false; };
void setNoDecode(bool noDecode = true) { _noDecode = noDecode; };
bool isMaster() { return (_isMaster); };
bool isSlave() { return (!_isMaster); };
bool isNoDecode() { return _noDecode; };
#ifdef WINDOWS_TIMING
double getRecInTime() { return (static_cast<double>( _totTimeRecIn.QuadPart )); };
double getRecOutTime() { return (static_cast<double>( _totTimeRecOut.QuadPart )); };
#else
double getRecInTime() { return (0.0); };
double getRecOutTime() { return (0.0); };
#endif
void printError();
void printError(NETEQTEST_RTPpacket & rtp);
private:
void * _inst;
int8_t * _instMem;
int8_t * _bufferMem;
bool _preparseRTP;
int _fsmult;
bool _isMaster;
bool _noDecode;
#ifdef WINDOWS_TIMING
LARGE_INTEGER _totTimeRecIn;
LARGE_INTEGER _totTimeRecOut;
#endif
};
#endif //NETEQTEST_NETEQCLASS_H

View File

@ -1,882 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "NETEQTEST_RTPpacket.h"
#include <assert.h>
#include <stdlib.h> // rand
#include <string.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <netinet/in.h> // for htons, htonl, etc
#endif
const int NETEQTEST_RTPpacket::_kRDHeaderLen = 8;
const int NETEQTEST_RTPpacket::_kBasicHeaderLen = 12;
NETEQTEST_RTPpacket::NETEQTEST_RTPpacket()
:
_datagram(NULL),
_payloadPtr(NULL),
_memSize(0),
_datagramLen(-1),
_payloadLen(0),
_rtpParsed(false),
_receiveTime(0),
_lost(false),
_selectSSRC(0),
_filterSSRC(false)
{
memset(&_rtpInfo, 0, sizeof(_rtpInfo));
_blockList.clear();
}
NETEQTEST_RTPpacket::~NETEQTEST_RTPpacket()
{
if(_datagram)
{
delete [] _datagram;
}
}
void NETEQTEST_RTPpacket::reset()
{
if(_datagram) {
delete [] _datagram;
}
_datagram = NULL;
_memSize = 0;
_datagramLen = -1;
_payloadLen = 0;
_payloadPtr = NULL;
_receiveTime = 0;
memset(&_rtpInfo, 0, sizeof(_rtpInfo));
_rtpParsed = false;
}
int NETEQTEST_RTPpacket::skipFileHeader(FILE *fp)
{
if (!fp) {
return -1;
}
const int kFirstLineLength = 40;
char firstline[kFirstLineLength];
if (fgets(firstline, kFirstLineLength, fp) == NULL) {
return -1;
}
if (strncmp(firstline, "#!rtpplay", 9) == 0) {
if (strncmp(firstline, "#!rtpplay1.0", 12) != 0) {
return -1;
}
}
else if (strncmp(firstline, "#!RTPencode", 11) == 0) {
if (strncmp(firstline, "#!RTPencode1.0", 14) != 0) {
return -1;
}
}
else
{
return -1;
}
const int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
if (fseek(fp, kRtpDumpHeaderSize, SEEK_CUR) != 0)
{
return -1;
}
return 0;
}
int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
{
if(!fp)
{
return(-1);
}
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length,2,1,fp)==0)
{
reset();
return(-2);
}
length = ntohs(length);
if (fread(&plen,2,1,fp)==0)
{
reset();
return(-1);
}
packetLen = ntohs(plen);
if (fread(&offset,4,1,fp)==0)
{
reset();
return(-1);
}
// store in local variable until we have passed the reset below
uint32_t receiveTime = ntohl(offset);
// Use length here because a plen of 0 specifies rtcp
length = (uint16_t) (length - _kRDHeaderLen);
// check buffer size
if (_datagram && _memSize < length)
{
reset();
}
if (!_datagram)
{
_datagram = new uint8_t[length];
_memSize = length;
}
if (fread((unsigned short *) _datagram,1,length,fp) != length)
{
reset();
return(-1);
}
_datagramLen = length;
_receiveTime = receiveTime;
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
readNextPacket = true;
}
if (_filterSSRC && _selectSSRC != SSRC())
{
readNextPacket = true;
}
}
return(packetLen);
}
int NETEQTEST_RTPpacket::readFixedFromFile(FILE *fp, size_t length)
{
if (!fp)
{
return -1;
}
// check buffer size
if (_datagram && _memSize < static_cast<int>(length))
{
reset();
}
if (!_datagram)
{
_datagram = new uint8_t[length];
_memSize = length;
}
if (fread(_datagram, 1, length, fp) != length)
{
reset();
return -1;
}
_datagramLen = length;
_receiveTime = 0;
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
return readFromFile(fp);
}
return length;
}
int NETEQTEST_RTPpacket::writeToFile(FILE *fp)
{
if (!fp)
{
return -1;
}
uint16_t length, plen;
uint32_t offset;
// length including RTPplay header
length = htons(_datagramLen + _kRDHeaderLen);
if (fwrite(&length, 2, 1, fp) != 1)
{
return -1;
}
// payload length
plen = htons(_datagramLen);
if (fwrite(&plen, 2, 1, fp) != 1)
{
return -1;
}
// offset (=receive time)
offset = htonl(_receiveTime);
if (fwrite(&offset, 4, 1, fp) != 1)
{
return -1;
}
// write packet data
if (fwrite(_datagram, 1, _datagramLen, fp) !=
static_cast<size_t>(_datagramLen))
{
return -1;
}
return _datagramLen + _kRDHeaderLen; // total number of bytes written
}
void NETEQTEST_RTPpacket::blockPT(uint8_t pt)
{
_blockList[pt] = true;
}
void NETEQTEST_RTPpacket::selectSSRC(uint32_t ssrc)
{
_selectSSRC = ssrc;
_filterSSRC = true;
}
void NETEQTEST_RTPpacket::parseHeader()
{
if (_rtpParsed)
{
// nothing to do
return;
}
if (_datagramLen < _kBasicHeaderLen)
{
// corrupt packet?
return;
}
_payloadLen = parseRTPheader(&_payloadPtr);
_rtpParsed = true;
return;
}
void NETEQTEST_RTPpacket::parseHeader(WebRtcNetEQ_RTPInfo & rtpInfo)
{
if (!_rtpParsed)
{
// parse the header
parseHeader();
}
memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcNetEQ_RTPInfo));
}
WebRtcNetEQ_RTPInfo const * NETEQTEST_RTPpacket::RTPinfo() const
{
if (_rtpParsed)
{
return &_rtpInfo;
}
else
{
return NULL;
}
}
uint8_t * NETEQTEST_RTPpacket::datagram() const
{
if (_datagramLen > 0)
{
return _datagram;
}
else
{
return NULL;
}
}
uint8_t * NETEQTEST_RTPpacket::payload() const
{
if (_payloadLen > 0)
{
return _payloadPtr;
}
else
{
return NULL;
}
}
int16_t NETEQTEST_RTPpacket::payloadLen()
{
parseHeader();
return _payloadLen;
}
int16_t NETEQTEST_RTPpacket::dataLen() const
{
return _datagramLen;
}
bool NETEQTEST_RTPpacket::isParsed() const
{
return _rtpParsed;
}
bool NETEQTEST_RTPpacket::isLost() const
{
return _lost;
}
uint8_t NETEQTEST_RTPpacket::payloadType() const
{
WebRtcNetEQ_RTPInfo tempRTPinfo;
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
parseRTPheader(&tempRTPinfo);
}
else
{
return 0;
}
return tempRTPinfo.payloadType;
}
uint16_t NETEQTEST_RTPpacket::sequenceNumber() const
{
WebRtcNetEQ_RTPInfo tempRTPinfo;
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
parseRTPheader(&tempRTPinfo);
}
else
{
return 0;
}
return tempRTPinfo.sequenceNumber;
}
uint32_t NETEQTEST_RTPpacket::timeStamp() const
{
WebRtcNetEQ_RTPInfo tempRTPinfo;
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
parseRTPheader(&tempRTPinfo);
}
else
{
return 0;
}
return tempRTPinfo.timeStamp;
}
uint32_t NETEQTEST_RTPpacket::SSRC() const
{
WebRtcNetEQ_RTPInfo tempRTPinfo;
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
parseRTPheader(&tempRTPinfo);
}
else
{
return 0;
}
return tempRTPinfo.SSRC;
}
uint8_t NETEQTEST_RTPpacket::markerBit() const
{
WebRtcNetEQ_RTPInfo tempRTPinfo;
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
parseRTPheader(&tempRTPinfo);
}
else
{
return 0;
}
return tempRTPinfo.markerBit;
}
int NETEQTEST_RTPpacket::setPayloadType(uint8_t pt)
{
if (_datagramLen < 12)
{
return -1;
}
if (!_rtpParsed)
{
_rtpInfo.payloadType = pt;
}
_datagram[1]=(unsigned char)(pt & 0xFF);
return 0;
}
int NETEQTEST_RTPpacket::setSequenceNumber(uint16_t sn)
{
if (_datagramLen < 12)
{
return -1;
}
if (!_rtpParsed)
{
_rtpInfo.sequenceNumber = sn;
}
_datagram[2]=(unsigned char)((sn>>8)&0xFF);
_datagram[3]=(unsigned char)((sn)&0xFF);
return 0;
}
int NETEQTEST_RTPpacket::setTimeStamp(uint32_t ts)
{
if (_datagramLen < 12)
{
return -1;
}
if (!_rtpParsed)
{
_rtpInfo.timeStamp = ts;
}
_datagram[4]=(unsigned char)((ts>>24)&0xFF);
_datagram[5]=(unsigned char)((ts>>16)&0xFF);
_datagram[6]=(unsigned char)((ts>>8)&0xFF);
_datagram[7]=(unsigned char)(ts & 0xFF);
return 0;
}
int NETEQTEST_RTPpacket::setSSRC(uint32_t ssrc)
{
if (_datagramLen < 12)
{
return -1;
}
if (!_rtpParsed)
{
_rtpInfo.SSRC = ssrc;
}
_datagram[8]=(unsigned char)((ssrc>>24)&0xFF);
_datagram[9]=(unsigned char)((ssrc>>16)&0xFF);
_datagram[10]=(unsigned char)((ssrc>>8)&0xFF);
_datagram[11]=(unsigned char)(ssrc & 0xFF);
return 0;
}
int NETEQTEST_RTPpacket::setMarkerBit(uint8_t mb)
{
if (_datagramLen < 12)
{
return -1;
}
if (_rtpParsed)
{
_rtpInfo.markerBit = mb;
}
if (mb)
{
_datagram[0] |= 0x01;
}
else
{
_datagram[0] &= 0xFE;
}
return 0;
}
int NETEQTEST_RTPpacket::setRTPheader(const WebRtcNetEQ_RTPInfo *RTPinfo)
{
if (_datagramLen < 12)
{
// this packet is not ok
return -1;
}
makeRTPheader(_datagram,
RTPinfo->payloadType,
RTPinfo->sequenceNumber,
RTPinfo->timeStamp,
RTPinfo->SSRC,
RTPinfo->markerBit);
return 0;
}
int NETEQTEST_RTPpacket::splitStereo(NETEQTEST_RTPpacket* slaveRtp,
enum stereoModes mode)
{
// if mono, do nothing
if (mode == stereoModeMono)
{
return 0;
}
// check that the RTP header info is parsed
parseHeader();
// start by copying the main rtp packet
*slaveRtp = *this;
if(_payloadLen == 0)
{
// do no more
return 0;
}
if(_payloadLen%2 != 0)
{
// length must be a factor of 2
return -1;
}
switch(mode)
{
case stereoModeSample1:
{
// sample based codec with 1-byte samples
splitStereoSample(slaveRtp, 1 /* 1 byte/sample */);
break;
}
case stereoModeSample2:
{
// sample based codec with 2-byte samples
splitStereoSample(slaveRtp, 2 /* 2 bytes/sample */);
break;
}
case stereoModeFrame:
{
// frame based codec
splitStereoFrame(slaveRtp);
break;
}
case stereoModeDuplicate:
{
// frame based codec, send the whole packet to both master and slave
splitStereoDouble(slaveRtp);
break;
}
case stereoModeMono:
{
assert(false);
return -1;
}
}
return 0;
}
void NETEQTEST_RTPpacket::makeRTPheader(unsigned char* rtp_data, uint8_t payloadType, uint16_t seqNo, uint32_t timestamp, uint32_t ssrc, uint8_t markerBit) const
{
rtp_data[0]=(unsigned char)0x80;
if (markerBit)
{
rtp_data[0] |= 0x01;
}
else
{
rtp_data[0] &= 0xFE;
}
rtp_data[1]=(unsigned char)(payloadType & 0xFF);
rtp_data[2]=(unsigned char)((seqNo>>8)&0xFF);
rtp_data[3]=(unsigned char)((seqNo)&0xFF);
rtp_data[4]=(unsigned char)((timestamp>>24)&0xFF);
rtp_data[5]=(unsigned char)((timestamp>>16)&0xFF);
rtp_data[6]=(unsigned char)((timestamp>>8)&0xFF);
rtp_data[7]=(unsigned char)(timestamp & 0xFF);
rtp_data[8]=(unsigned char)((ssrc>>24)&0xFF);
rtp_data[9]=(unsigned char)((ssrc>>16)&0xFF);
rtp_data[10]=(unsigned char)((ssrc>>8)&0xFF);
rtp_data[11]=(unsigned char)(ssrc & 0xFF);
}
uint16_t
NETEQTEST_RTPpacket::parseRTPheader(WebRtcNetEQ_RTPInfo *RTPinfo,
uint8_t **payloadPtr) const
{
int16_t *rtp_data = (int16_t *) _datagram;
int i_P, i_X, i_CC;
assert(_datagramLen >= 12);
parseBasicHeader(RTPinfo, &i_P, &i_X, &i_CC);
int i_startPosition = calcHeaderLength(i_X, i_CC);
int i_padlength = calcPadLength(i_P);
if (payloadPtr)
{
*payloadPtr = (uint8_t*) &rtp_data[i_startPosition >> 1];
}
return (uint16_t) (_datagramLen - i_startPosition - i_padlength);
}
void NETEQTEST_RTPpacket::parseBasicHeader(WebRtcNetEQ_RTPInfo *RTPinfo,
int *i_P, int *i_X, int *i_CC) const
{
int16_t *rtp_data = (int16_t *) _datagram;
if (_datagramLen < 12)
{
assert(false);
return;
}
*i_P=(((uint16_t)(rtp_data[0] & 0x20))>>5); /* Extract the P bit */
*i_X=(((uint16_t)(rtp_data[0] & 0x10))>>4); /* Extract the X bit */
*i_CC=(uint16_t)(rtp_data[0] & 0xF); /* Get the CC number */
/* Get the marker bit */
RTPinfo->markerBit = (uint8_t) ((rtp_data[0] >> 15) & 0x01);
/* Get the coder type */
RTPinfo->payloadType = (uint8_t) ((rtp_data[0] >> 8) & 0x7F);
/* Get the packet number */
RTPinfo->sequenceNumber = ((( ((uint16_t)rtp_data[1]) >> 8) & 0xFF) |
( ((uint16_t)(rtp_data[1] & 0xFF)) << 8));
/* Get timestamp */
RTPinfo->timeStamp = ((((uint16_t)rtp_data[2]) & 0xFF) << 24) |
((((uint16_t)rtp_data[2]) & 0xFF00) << 8) |
((((uint16_t)rtp_data[3]) >> 8) & 0xFF) |
((((uint16_t)rtp_data[3]) & 0xFF) << 8);
/* Get the SSRC */
RTPinfo->SSRC=((((uint16_t)rtp_data[4]) & 0xFF) << 24) |
((((uint16_t)rtp_data[4]) & 0xFF00) << 8) |
((((uint16_t)rtp_data[5]) >> 8) & 0xFF) |
((((uint16_t)rtp_data[5]) & 0xFF) << 8);
}
int NETEQTEST_RTPpacket::calcHeaderLength(int i_X, int i_CC) const
{
int i_extlength = 0;
int16_t *rtp_data = (int16_t *) _datagram;
if (i_X == 1)
{
// Extension header exists.
// Find out how many int32_t it consists of.
assert(_datagramLen > 2 * (7 + 2 * i_CC));
if (_datagramLen > 2 * (7 + 2 * i_CC))
{
i_extlength = (((((uint16_t) rtp_data[7 + 2 * i_CC]) >> 8)
& 0xFF) | (((uint16_t) (rtp_data[7 + 2 * i_CC] & 0xFF))
<< 8)) + 1;
}
}
return 12 + 4 * i_extlength + 4 * i_CC;
}
int NETEQTEST_RTPpacket::calcPadLength(int i_P) const
{
int16_t *rtp_data = (int16_t *) _datagram;
if (i_P == 1)
{
/* Padding exists. Find out how many bytes the padding consists of. */
if (_datagramLen & 0x1)
{
/* odd number of bytes => last byte in higher byte */
return rtp_data[_datagramLen >> 1] & 0xFF;
}
else
{
/* even number of bytes => last byte in lower byte */
return ((uint16_t) rtp_data[(_datagramLen >> 1) - 1]) >> 8;
}
}
return 0;
}
void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp,
int stride)
{
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
{
return;
}
uint8_t *readDataPtr = _payloadPtr;
uint8_t *writeDataPtr = _payloadPtr;
uint8_t *slaveData = slaveRtp->_payloadPtr;
while (readDataPtr - _payloadPtr < _payloadLen)
{
// master data
for (int ix = 0; ix < stride; ix++) {
*writeDataPtr = *readDataPtr;
writeDataPtr++;
readDataPtr++;
}
// slave data
for (int ix = 0; ix < stride; ix++) {
*slaveData = *readDataPtr;
slaveData++;
readDataPtr++;
}
}
_payloadLen /= 2;
slaveRtp->_payloadLen = _payloadLen;
}
void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp)
{
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
{
return;
}
memmove(slaveRtp->_payloadPtr, _payloadPtr + _payloadLen/2, _payloadLen/2);
_payloadLen /= 2;
slaveRtp->_payloadLen = _payloadLen;
}
void NETEQTEST_RTPpacket::splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp)
{
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
{
return;
}
memcpy(slaveRtp->_payloadPtr, _payloadPtr, _payloadLen);
slaveRtp->_payloadLen = _payloadLen;
}
// Get the RTP header for the RED payload indicated by argument index.
// The first RED payload is index = 0.
int NETEQTEST_RTPpacket::extractRED(int index, WebRtcNetEQ_RTPInfo& red)
{
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |1| block PT | timestamp offset | block length |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |1| ... |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |0| block PT |
// +-+-+-+-+-+-+-+-+
//
parseHeader();
uint8_t* ptr = payload();
uint8_t* payloadEndPtr = ptr + payloadLen();
int num_encodings = 0;
int total_len = 0;
while ((ptr < payloadEndPtr) && (*ptr & 0x80))
{
int len = ((ptr[2] & 0x03) << 8) + ptr[3];
if (num_encodings == index)
{
// Header found.
red.payloadType = ptr[0] & 0x7F;
uint32_t offset = (ptr[1] << 6) + ((ptr[2] & 0xFC) >> 2);
red.sequenceNumber = sequenceNumber();
red.timeStamp = timeStamp() - offset;
red.markerBit = markerBit();
red.SSRC = SSRC();
return len;
}
++num_encodings;
total_len += len;
ptr += 4;
}
if ((ptr < payloadEndPtr) && (num_encodings == index))
{
// Last header.
red.payloadType = ptr[0] & 0x7F;
red.sequenceNumber = sequenceNumber();
red.timeStamp = timeStamp();
red.markerBit = markerBit();
red.SSRC = SSRC();
++ptr;
return payloadLen() - (ptr - payload()) - total_len;
}
return -1;
}
// Randomize the payload, not the RTP header.
void NETEQTEST_RTPpacket::scramblePayload(void)
{
parseHeader();
for (int i = 0; i < _payloadLen; ++i)
{
_payloadPtr[i] = static_cast<uint8_t>(rand());
}
}

View File

@ -1,108 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef NETEQTEST_RTPPACKET_H
#define NETEQTEST_RTPPACKET_H
#include <map>
#include <stdio.h>
#include "typedefs.h"
#include "webrtc_neteq_internal.h"
enum stereoModes {
stereoModeMono,
stereoModeSample1,
stereoModeSample2,
stereoModeFrame,
stereoModeDuplicate
};
class NETEQTEST_RTPpacket
{
public:
NETEQTEST_RTPpacket();
bool operator !() const { return (dataLen() < 0); };
virtual ~NETEQTEST_RTPpacket();
void reset();
static int skipFileHeader(FILE *fp);
virtual int readFromFile(FILE *fp);
int readFixedFromFile(FILE *fp, size_t len);
virtual int writeToFile(FILE *fp);
void blockPT(uint8_t pt);
void selectSSRC(uint32_t ssrc);
//int16_t payloadType();
void parseHeader();
void parseHeader(WebRtcNetEQ_RTPInfo & rtpInfo);
WebRtcNetEQ_RTPInfo const * RTPinfo() const;
uint8_t * datagram() const;
uint8_t * payload() const;
int16_t payloadLen();
int16_t dataLen() const;
bool isParsed() const;
bool isLost() const;
uint32_t time() const { return _receiveTime; };
uint8_t payloadType() const;
uint16_t sequenceNumber() const;
uint32_t timeStamp() const;
uint32_t SSRC() const;
uint8_t markerBit() const;
int setPayloadType(uint8_t pt);
int setSequenceNumber(uint16_t sn);
int setTimeStamp(uint32_t ts);
int setSSRC(uint32_t ssrc);
int setMarkerBit(uint8_t mb);
void setTime(uint32_t receiveTime) { _receiveTime = receiveTime; };
int setRTPheader(const WebRtcNetEQ_RTPInfo *RTPinfo);
int splitStereo(NETEQTEST_RTPpacket* slaveRtp, enum stereoModes mode);
int extractRED(int index, WebRtcNetEQ_RTPInfo& red);
void scramblePayload(void);
uint8_t * _datagram;
uint8_t * _payloadPtr;
int _memSize;
int16_t _datagramLen;
int16_t _payloadLen;
WebRtcNetEQ_RTPInfo _rtpInfo;
bool _rtpParsed;
uint32_t _receiveTime;
bool _lost;
std::map<uint8_t, bool> _blockList;
uint32_t _selectSSRC;
bool _filterSSRC;
protected:
static const int _kRDHeaderLen;
static const int _kBasicHeaderLen;
void parseBasicHeader(WebRtcNetEQ_RTPInfo *RTPinfo, int *i_P, int *i_X,
int *i_CC) const;
int calcHeaderLength(int i_X, int i_CC) const;
private:
void makeRTPheader(unsigned char* rtp_data, uint8_t payloadType,
uint16_t seqNo, uint32_t timestamp,
uint32_t ssrc, uint8_t markerBit) const;
uint16_t parseRTPheader(WebRtcNetEQ_RTPInfo *RTPinfo,
uint8_t **payloadPtr = NULL) const;
uint16_t parseRTPheader(uint8_t **payloadPtr = NULL)
{ return parseRTPheader(&_rtpInfo, payloadPtr);};
int calcPadLength(int i_P) const;
void splitStereoSample(NETEQTEST_RTPpacket* slaveRtp, int stride);
void splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp);
void splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp);
};
#endif //NETEQTEST_RTPPACKET_H

File diff suppressed because it is too large Load Diff

View File

@ -1,78 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
/* PayloadTypes.h */
/* Used by NetEqRTPplay application */
/* RTP defined codepoints */
#define NETEQ_CODEC_PCMU_PT 0
#define NETEQ_CODEC_GSMFR_PT 3
#define NETEQ_CODEC_G723_PT 4
#define NETEQ_CODEC_DVI4_PT 125 // 8 kHz version
//#define NETEQ_CODEC_DVI4_16_PT 6 // 16 kHz version
#define NETEQ_CODEC_PCMA_PT 8
#define NETEQ_CODEC_G722_PT 9
#define NETEQ_CODEC_CN_PT 13
//#define NETEQ_CODEC_G728_PT 15
//#define NETEQ_CODEC_DVI4_11_PT 16 // 11.025 kHz version
//#define NETEQ_CODEC_DVI4_22_PT 17 // 22.050 kHz version
#define NETEQ_CODEC_G729_PT 18
/* Dynamic RTP codepoints as defined in VoiceEngine (file VEAPI.cpp) */
#define NETEQ_CODEC_IPCMWB_PT 97
#define NETEQ_CODEC_SPEEX8_PT 98
#define NETEQ_CODEC_SPEEX16_PT 99
#define NETEQ_CODEC_EG711U_PT 100
#define NETEQ_CODEC_EG711A_PT 101
#define NETEQ_CODEC_ILBC_PT 102
#define NETEQ_CODEC_ISAC_PT 103
#define NETEQ_CODEC_ISACLC_PT 119
#define NETEQ_CODEC_ISACSWB_PT 104
#define NETEQ_CODEC_ISACFB_PT 124
#define NETEQ_CODEC_AVT_PT 106
#define NETEQ_CODEC_G722_1_16_PT 108
#define NETEQ_CODEC_G722_1_24_PT 109
#define NETEQ_CODEC_G722_1_32_PT 110
#define NETEQ_CODEC_SC3_PT 111
#define NETEQ_CODEC_AMR_PT 112
#define NETEQ_CODEC_GSMEFR_PT 113
//#define NETEQ_CODEC_ILBCRCU_PT 114
#define NETEQ_CODEC_G726_16_PT 115
#define NETEQ_CODEC_G726_24_PT 116
#define NETEQ_CODEC_G726_32_PT 121
#define NETEQ_CODEC_RED_PT 117
#define NETEQ_CODEC_G726_40_PT 118
//#define NETEQ_CODEC_ENERGY_PT 120
#define NETEQ_CODEC_CN_WB_PT 105
#define NETEQ_CODEC_CN_SWB_PT 126
#define NETEQ_CODEC_G729_1_PT 107
#define NETEQ_CODEC_G729D_PT 123
//#define NETEQ_CODEC_MELPE_PT 124
#define NETEQ_CODEC_CELT32_PT 114
/* Extra dynamic codepoints */
#define NETEQ_CODEC_AMRWB_PT 120
#define NETEQ_CODEC_PCM16B_PT 93
#define NETEQ_CODEC_PCM16B_WB_PT 94
#define NETEQ_CODEC_PCM16B_SWB32KHZ_PT 95
#define NETEQ_CODEC_PCM16B_SWB48KHZ_PT 96
#define NETEQ_CODEC_MPEG4AAC_PT 122
/* Not default in VoiceEngine */
#define NETEQ_CODEC_G722_1C_24_PT 84
#define NETEQ_CODEC_G722_1C_32_PT 85
#define NETEQ_CODEC_G722_1C_48_PT 86
#define NETEQ_CODEC_SILK_8_PT 80
#define NETEQ_CODEC_SILK_12_PT 81
#define NETEQ_CODEC_SILK_16_PT 82
#define NETEQ_CODEC_SILK_24_PT 83

View File

@ -1,75 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include <stdio.h>
#include <algorithm>
#include <vector>
#include "gtest/gtest.h"
#include "modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h"
#define FIRSTLINELEN 40
int main(int argc, char* argv[]) {
if (argc < 3) {
printf("Usage: RTPcat in1.rtp int2.rtp [...] out.rtp\n");
exit(1);
}
FILE* in_file = fopen(argv[1], "rb");
if (!in_file) {
printf("Cannot open input file %s\n", argv[1]);
return -1;
}
FILE* out_file = fopen(argv[argc - 1], "wb"); // Last parameter is out file.
if (!out_file) {
printf("Cannot open output file %s\n", argv[argc - 1]);
return -1;
}
printf("Output RTP file: %s\n\n", argv[argc - 1]);
// Read file header and write directly to output file.
char firstline[FIRSTLINELEN];
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, in_file) != NULL);
EXPECT_GT(fputs(firstline, out_file), 0);
EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize,
in_file));
EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize,
out_file));
// Close input file and re-open it later (easier to write the loop below).
fclose(in_file);
for (int i = 1; i < argc - 1; i++) {
in_file = fopen(argv[i], "rb");
if (!in_file) {
printf("Cannot open input file %s\n", argv[i]);
return -1;
}
printf("Input RTP file: %s\n", argv[i]);
NETEQTEST_RTPpacket::skipFileHeader(in_file);
NETEQTEST_RTPpacket packet;
int pack_len = packet.readFromFile(in_file);
if (pack_len < 0) {
exit(1);
}
while (pack_len >= 0) {
packet.writeToFile(out_file);
pack_len = packet.readFromFile(in_file);
}
fclose(in_file);
}
fclose(out_file);
return 0;
}

View File

@ -1,133 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include <stdio.h>
#include <algorithm>
#include <vector>
#include "modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h"
#include "modules/audio_coding/neteq/test/NETEQTEST_DummyRTPpacket.h"
#define FIRSTLINELEN 40
//#define WEBRTC_DUMMY_RTP
static bool pktCmp(NETEQTEST_RTPpacket *a, NETEQTEST_RTPpacket *b) {
return (a->time() < b->time());
}
int main(int argc, char* argv[]) {
FILE* in_file = fopen(argv[1], "rb");
if (!in_file) {
printf("Cannot open input file %s\n", argv[1]);
return -1;
}
printf("Input RTP file: %s\n", argv[1]);
FILE* stat_file = fopen(argv[2], "rt");
if (!stat_file) {
printf("Cannot open timing file %s\n", argv[2]);
return -1;
}
printf("Timing file: %s\n", argv[2]);
FILE* out_file = fopen(argv[3], "wb");
if (!out_file) {
printf("Cannot open output file %s\n", argv[3]);
return -1;
}
printf("Output RTP file: %s\n\n", argv[3]);
// Read all statistics and insert into map.
// Read first line.
char temp_str[100];
if (fgets(temp_str, 100, stat_file) == NULL) {
printf("Failed to read timing file %s\n", argv[2]);
return -1;
}
// Define map.
std::map<std::pair<uint16_t, uint32_t>, uint32_t> packet_stats;
uint16_t seq_no;
uint32_t ts;
uint32_t send_time;
while (fscanf(stat_file,
"%hu %u %u %*i %*i %*i %*x\n", &seq_no, &ts, &send_time) == 3) {
std::pair<uint16_t, uint32_t>
temp_pair = std::pair<uint16_t, uint32_t>(seq_no, ts);
packet_stats[temp_pair] = send_time;
}
fclose(stat_file);
// Read file header and write directly to output file.
char first_line[FIRSTLINELEN];
if (fgets(first_line, FIRSTLINELEN, in_file) == NULL) {
printf("Failed to read first line of input file %s\n", argv[1]);
return -1;
}
fputs(first_line, out_file);
// start_sec + start_usec + source + port + padding
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
if (fread(first_line, 1, kRtpDumpHeaderSize, in_file)
!= kRtpDumpHeaderSize) {
printf("Failed to read RTP dump header from input file %s\n", argv[1]);
return -1;
}
if (fwrite(first_line, 1, kRtpDumpHeaderSize, out_file)
!= kRtpDumpHeaderSize) {
printf("Failed to write RTP dump header to output file %s\n", argv[3]);
return -1;
}
std::vector<NETEQTEST_RTPpacket *> packet_vec;
while (1) {
// Insert in vector.
#ifdef WEBRTC_DUMMY_RTP
NETEQTEST_RTPpacket *new_packet = new NETEQTEST_DummyRTPpacket();
#else
NETEQTEST_RTPpacket *new_packet = new NETEQTEST_RTPpacket();
#endif
if (new_packet->readFromFile(in_file) < 0) {
// End of file.
break;
}
// Look for new send time in statistics vector.
std::pair<uint16_t, uint32_t> temp_pair =
std::pair<uint16_t, uint32_t>(new_packet->sequenceNumber(),
new_packet->timeStamp());
uint32_t new_send_time = packet_stats[temp_pair];
new_packet->setTime(new_send_time); // Set new send time.
packet_vec.push_back(new_packet); // Insert in vector.
}
// Sort the vector according to send times.
std::sort(packet_vec.begin(), packet_vec.end(), pktCmp);
std::vector<NETEQTEST_RTPpacket *>::iterator it;
for (it = packet_vec.begin(); it != packet_vec.end(); it++) {
// Write to out file.
if ((*it)->writeToFile(out_file) < 0) {
printf("Error writing to file\n");
return -1;
}
// Delete packet.
delete *it;
}
fclose(in_file);
fclose(out_file);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
//TODO(hlundin): Reformat file to meet style guide.
/* header includes */
#include "typedefs.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <winsock2.h>
#include <io.h>
#endif
#ifdef WEBRTC_LINUX
#include <netinet/in.h>
#endif
#include <float.h>
#include "gtest/gtest.h"
/*********************/
/* Misc. definitions */
/*********************/
#define FIRSTLINELEN 40
#define CHECK_ZERO(a) {int errCode = a; if((errCode)!=0){fprintf(stderr,"\n %s \n line: %d \n error at %s\n Error Code = %d\n",__FILE__,__LINE__,#a, WebRtcNetEQ_GetErrorCode(inst)); exit(0);}}
#define CHECK_NOT_NULL(a) if((a)==NULL){fprintf(stderr,"\n %s \n line: %d \nerror at %s\n",__FILE__,__LINE__,#a );return(-1);}
struct arr_time {
float time;
uint32_t ix;
};
int filelen(FILE *fid)
{
fpos_t cur_pos;
int len;
if (!fid || fgetpos(fid, &cur_pos)) {
return(-1);
}
fseek(fid, 0, SEEK_END);
len = ftell(fid);
fsetpos(fid, &cur_pos);
return (len);
}
int compare_arr_time(const void *x, const void *y);
int main(int argc, char* argv[])
{
unsigned int dat_len, rtp_len, Npack, k;
arr_time *time_vec;
char firstline[FIRSTLINELEN];
unsigned char *rtp_vec = NULL, **packet_ptr, *temp_packet;
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
uint16_t len;
uint32_t *offset;
/* check number of parameters */
if (argc != 4) {
/* print help text and exit */
printf("Apply jitter on RTP stream.\n");
printf("The program reads an RTP stream and packet timing from two files.\n");
printf("The RTP stream is modified to have the same jitter as described in the timing files.\n");
printf("The format of the RTP stream file should be the same as for rtpplay,\n");
printf("and can be obtained e.g., from Ethereal by using\n");
printf("Statistics -> RTP -> Show All Streams -> [select a stream] -> Save As\n\n");
printf("Usage:\n\n");
printf("%s RTP_infile dat_file RTP_outfile\n", argv[0]);
printf("where:\n");
printf("RTP_infile : RTP stream input file\n\n");
printf("dat_file : file with packet arrival times in ms\n\n");
printf("RTP_outfile : RTP stream output file\n\n");
return(0);
}
FILE* in_file=fopen(argv[1],"rb");
CHECK_NOT_NULL(in_file);
printf("Input file: %s\n",argv[1]);
FILE* dat_file=fopen(argv[2],"rb");
CHECK_NOT_NULL(dat_file);
printf("Dat-file: %s\n",argv[2]);
FILE* out_file=fopen(argv[3],"wb");
CHECK_NOT_NULL(out_file);
printf("Output file: %s\n\n",argv[3]);
time_vec = (arr_time *) malloc(sizeof(arr_time)*(filelen(dat_file)/sizeof(float)) + 1000); // add 1000 bytes to avoid (rare) strange error
if (time_vec==NULL) {
fprintf(stderr, "Error: could not allocate memory for reading dat file\n");
goto closing;
}
dat_len=0;
while(fread(&(time_vec[dat_len].time),sizeof(float),1,dat_file)>0) {
time_vec[dat_len].ix=dat_len;
dat_len++;
}
qsort(time_vec,dat_len,sizeof(arr_time),compare_arr_time);
rtp_vec = (unsigned char *) malloc(sizeof(unsigned char)*filelen(in_file));
if (rtp_vec==NULL) {
fprintf(stderr,"Error: could not allocate memory for reading rtp file\n");
goto closing;
}
// read file header and write directly to output file
EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, in_file) != NULL);
EXPECT_GT(fputs(firstline, out_file), 0);
EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize,
in_file));
EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize,
out_file));
// read all RTP packets into vector
rtp_len=0;
Npack=0;
len=(uint16_t) fread(&rtp_vec[rtp_len], sizeof(unsigned char), 2, in_file); // read length of first packet
while(len==2) {
len = ntohs(*((uint16_t *)(rtp_vec + rtp_len)));
rtp_len += 2;
if(fread(&rtp_vec[rtp_len], sizeof(unsigned char), len-2, in_file)!=(unsigned) (len-2)) {
fprintf(stderr,"Error: currupt packet length\n");
goto closing;
}
rtp_len += len-2;
Npack++;
len=(uint16_t) fread(&rtp_vec[rtp_len], sizeof(unsigned char), 2, in_file); // read length of next packet
}
packet_ptr = (unsigned char **) malloc(Npack*sizeof(unsigned char*));
packet_ptr[0]=rtp_vec;
k=1;
while(k<Npack) {
len = ntohs(*((uint16_t *) packet_ptr[k-1]));
packet_ptr[k]=packet_ptr[k-1]+len;
k++;
}
for(k=0; k<dat_len && k<Npack; k++) {
if(time_vec[k].time < FLT_MAX && time_vec[k].ix < Npack){
temp_packet = packet_ptr[time_vec[k].ix];
offset = (uint32_t *) (temp_packet+4);
if ( time_vec[k].time >= 0 ) {
*offset = htonl((uint32_t) time_vec[k].time);
}
else {
*offset = htonl((uint32_t) 0);
fprintf(stderr, "Warning: negative receive time in dat file transformed to 0.\n");
}
// write packet to file
if (fwrite(temp_packet, sizeof(unsigned char),
ntohs(*((uint16_t*) temp_packet)),
out_file) !=
ntohs(*((uint16_t*) temp_packet))) {
return -1;
}
}
}
closing:
free(time_vec);
free(rtp_vec);
fclose(in_file);
fclose(dat_file);
fclose(out_file);
return(0);
}
int compare_arr_time(const void *xp, const void *yp) {
if(((arr_time *)xp)->time == ((arr_time *)yp)->time)
return(0);
else if(((arr_time *)xp)->time > ((arr_time *)yp)->time)
return(1);
return(-1);
}

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include <algorithm>
#include <stdio.h>
#include <vector>
#include "NETEQTEST_RTPpacket.h"
#include "gtest/gtest.h"
/*********************/
/* Misc. definitions */
/*********************/
#define FIRSTLINELEN 40
int main(int argc, char* argv[]) {
if (argc < 4 || argc > 6) {
printf(
"Usage: RTPtimeshift in.rtp out.rtp newStartTS "
"[newStartSN [newStartArrTime]]\n");
exit(1);
}
FILE *inFile = fopen(argv[1], "rb");
if (!inFile) {
printf("Cannot open input file %s\n", argv[1]);
return (-1);
}
printf("Input RTP file: %s\n", argv[1]);
FILE *outFile = fopen(argv[2], "wb");
if (!outFile) {
printf("Cannot open output file %s\n", argv[2]);
return (-1);
}
printf("Output RTP file: %s\n\n", argv[2]);
// read file header and write directly to output file
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
char firstline[FIRSTLINELEN];
EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL);
EXPECT_GT(fputs(firstline, outFile), 0);
EXPECT_EQ(kRtpDumpHeaderSize,
fread(firstline, 1, kRtpDumpHeaderSize, inFile));
EXPECT_EQ(kRtpDumpHeaderSize,
fwrite(firstline, 1, kRtpDumpHeaderSize, outFile));
NETEQTEST_RTPpacket packet;
int packLen = packet.readFromFile(inFile);
if (packLen < 0) {
exit(1);
}
// get new start TS and start SeqNo from arguments
uint32_t TSdiff = atoi(argv[3]) - packet.timeStamp();
uint16_t SNdiff = 0;
uint32_t ATdiff = 0;
if (argc > 4) {
SNdiff = atoi(argv[4]) - packet.sequenceNumber();
if (argc > 5) {
ATdiff = atoi(argv[5]) - packet.time();
}
}
while (packLen >= 0) {
packet.setTimeStamp(packet.timeStamp() + TSdiff);
packet.setSequenceNumber(packet.sequenceNumber() + SNdiff);
packet.setTime(packet.time() + ATdiff);
packet.writeToFile(outFile);
packLen = packet.readFromFile(inFile);
}
fclose(inFile);
fclose(outFile);
return 0;
}

View File

@ -1,191 +0,0 @@
function outStruct = parse_delay_file(file)
fid = fopen(file, 'rb');
if fid == -1
error('Cannot open file %s', file);
end
textline = fgetl(fid);
if ~strncmp(textline, '#!NetEQ_Delay_Logging', 21)
error('Wrong file format');
end
ver = sscanf(textline, '#!NetEQ_Delay_Logging%d.%d');
if ~all(ver == [2; 0])
error('Wrong version of delay logging function')
end
start_pos = ftell(fid);
fseek(fid, -12, 'eof');
textline = fgetl(fid);
if ~strncmp(textline, 'End of file', 21)
error('File ending is not correct. Seems like the simulation ended abnormally.');
end
fseek(fid,-12-4, 'eof');
Npackets = fread(fid, 1, 'int32');
fseek(fid, start_pos, 'bof');
rtpts = zeros(Npackets, 1);
seqno = zeros(Npackets, 1);
pt = zeros(Npackets, 1);
plen = zeros(Npackets, 1);
recin_t = nan*ones(Npackets, 1);
decode_t = nan*ones(Npackets, 1);
playout_delay = zeros(Npackets, 1);
optbuf = zeros(Npackets, 1);
fs_ix = 1;
clock = 0;
ts_ix = 1;
ended = 0;
late_packets = 0;
fs_now = 8000;
last_decode_k = 0;
tot_expand = 0;
tot_accelerate = 0;
tot_preemptive = 0;
while not(ended)
signal = fread(fid, 1, '*int32');
switch signal
case 3 % NETEQ_DELAY_LOGGING_SIGNAL_CLOCK
clock = fread(fid, 1, '*float32');
% keep on reading batches of M until the signal is no longer "3"
% read int32 + float32 in one go
% this is to save execution time
temp = [3; 0];
M = 120;
while all(temp(1,:) == 3)
fp = ftell(fid);
temp = fread(fid, [2 M], '*int32');
end
% back up to last clock event
fseek(fid, fp - ftell(fid) + ...
(find(temp(1,:) ~= 3, 1 ) - 2) * 2 * 4 + 4, 'cof');
% read the last clock value
clock = fread(fid, 1, '*float32');
case 1 % NETEQ_DELAY_LOGGING_SIGNAL_RECIN
temp_ts = fread(fid, 1, 'uint32');
if late_packets > 0
temp_ix = ts_ix - 1;
while (temp_ix >= 1) && (rtpts(temp_ix) ~= temp_ts)
% TODO(hlundin): use matlab vector search instead?
temp_ix = temp_ix - 1;
end
if temp_ix >= 1
% the ts was found in the vector
late_packets = late_packets - 1;
else
temp_ix = ts_ix;
ts_ix = ts_ix + 1;
end
else
temp_ix = ts_ix;
ts_ix = ts_ix + 1;
end
rtpts(temp_ix) = temp_ts;
seqno(temp_ix) = fread(fid, 1, 'uint16');
pt(temp_ix) = fread(fid, 1, 'int32');
plen(temp_ix) = fread(fid, 1, 'int16');
recin_t(temp_ix) = clock;
case 2 % NETEQ_DELAY_LOGGING_SIGNAL_FLUSH
% do nothing
case 4 % NETEQ_DELAY_LOGGING_SIGNAL_EOF
ended = 1;
case 5 % NETEQ_DELAY_LOGGING_SIGNAL_DECODE
last_decode_ts = fread(fid, 1, 'uint32');
temp_delay = fread(fid, 1, 'uint16');
k = find(rtpts(1:(ts_ix - 1))==last_decode_ts,1,'last');
if ~isempty(k)
decode_t(k) = clock;
playout_delay(k) = temp_delay + ...
5 * fs_now / 8000; % add overlap length
last_decode_k = k;
end
case 6 % NETEQ_DELAY_LOGGING_SIGNAL_CHANGE_FS
fsvec(fs_ix) = fread(fid, 1, 'uint16');
fschange_ts(fs_ix) = last_decode_ts;
fs_now = fsvec(fs_ix);
fs_ix = fs_ix + 1;
case 7 % NETEQ_DELAY_LOGGING_SIGNAL_MERGE_INFO
playout_delay(last_decode_k) = playout_delay(last_decode_k) ...
+ fread(fid, 1, 'int32');
case 8 % NETEQ_DELAY_LOGGING_SIGNAL_EXPAND_INFO
temp = fread(fid, 1, 'int32');
if last_decode_k ~= 0
tot_expand = tot_expand + temp / (fs_now / 1000);
end
case 9 % NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO
temp = fread(fid, 1, 'int32');
if last_decode_k ~= 0
tot_accelerate = tot_accelerate + temp / (fs_now / 1000);
end
case 10 % NETEQ_DELAY_LOGGING_SIGNAL_PREEMPTIVE_INFO
temp = fread(fid, 1, 'int32');
if last_decode_k ~= 0
tot_preemptive = tot_preemptive + temp / (fs_now / 1000);
end
case 11 % NETEQ_DELAY_LOGGING_SIGNAL_OPTBUF
optbuf(last_decode_k) = fread(fid, 1, 'int32');
case 12 % NETEQ_DELAY_LOGGING_SIGNAL_DECODE_ONE_DESC
last_decode_ts = fread(fid, 1, 'uint32');
k = ts_ix - 1;
while (k >= 1) && (rtpts(k) ~= last_decode_ts)
% TODO(hlundin): use matlab vector search instead?
k = k - 1;
end
if k < 1
% packet not received yet
k = ts_ix;
rtpts(ts_ix) = last_decode_ts;
late_packets = late_packets + 1;
end
decode_t(k) = clock;
playout_delay(k) = fread(fid, 1, 'uint16') + ...
5 * fs_now / 8000; % add overlap length
last_decode_k = k;
end
end
fclose(fid);
outStruct = struct(...
'ts', rtpts, ...
'sn', seqno, ...
'pt', pt,...
'plen', plen,...
'arrival', recin_t,...
'decode', decode_t,...
'fs', fsvec(:),...
'fschange_ts', fschange_ts(:),...
'playout_delay', playout_delay,...
'tot_expand', tot_expand,...
'tot_accelerate', tot_accelerate,...
'tot_preemptive', tot_preemptive,...
'optbuf', optbuf);

View File

@ -1,207 +0,0 @@
function [delay_struct, delayvalues] = plot_neteq_delay(delayfile, varargin)
% InfoStruct = plot_neteq_delay(delayfile)
% InfoStruct = plot_neteq_delay(delayfile, 'skipdelay', skip_seconds)
%
% Henrik Lundin, 2006-11-17
% Henrik Lundin, 2011-05-17
%
try
s = parse_delay_file(delayfile);
catch
error(lasterr);
end
delayskip=0;
noplot=0;
arg_ptr=1;
delaypoints=[];
s.sn=unwrap_seqno(s.sn);
while arg_ptr+1 <= nargin
switch lower(varargin{arg_ptr})
case {'skipdelay', 'delayskip'}
% skip a number of seconds in the beginning when calculating delays
delayskip = varargin{arg_ptr+1};
arg_ptr = arg_ptr + 2;
case 'noplot'
noplot=1;
arg_ptr = arg_ptr + 1;
case {'get_delay', 'getdelay'}
% return a vector of delay values for the points in the given vector
delaypoints = varargin{arg_ptr+1};
arg_ptr = arg_ptr + 2;
otherwise
warning('Unknown switch %s\n', varargin{arg_ptr});
arg_ptr = arg_ptr + 1;
end
end
% find lost frames that were covered by one-descriptor decoding
one_desc_ix=find(isnan(s.arrival));
for k=1:length(one_desc_ix)
ix=find(s.ts==max(s.ts(s.ts(one_desc_ix(k))>s.ts)));
s.sn(one_desc_ix(k))=s.sn(ix)+1;
s.pt(one_desc_ix(k))=s.pt(ix);
s.arrival(one_desc_ix(k))=s.arrival(ix)+s.decode(one_desc_ix(k))-s.decode(ix);
end
% remove duplicate received frames that were never decoded (RED codec)
if length(unique(s.ts(isfinite(s.ts)))) < length(s.ts(isfinite(s.ts)))
ix=find(isfinite(s.decode));
s.sn=s.sn(ix);
s.ts=s.ts(ix);
s.arrival=s.arrival(ix);
s.playout_delay=s.playout_delay(ix);
s.pt=s.pt(ix);
s.optbuf=s.optbuf(ix);
s.decode=s.decode(ix);
end
% find non-unique sequence numbers
[~,un_ix]=unique(s.sn);
nonun_ix=setdiff(1:length(s.sn),un_ix);
if ~isempty(nonun_ix)
warning('RTP sequence numbers are in error');
end
% sort vectors
[s.sn,sort_ix]=sort(s.sn);
s.ts=s.ts(sort_ix);
s.arrival=s.arrival(sort_ix);
s.decode=s.decode(sort_ix);
s.playout_delay=s.playout_delay(sort_ix);
s.pt=s.pt(sort_ix);
ts_unw = unwrap_ts(s.ts);
unwrapped = any(ts_unw ~= s.ts);
send_t = ts_unw - ts_unw(1);
if length(s.fs)<1
warning('No info about sample rate found in file. Using default 8000.');
s.fs(1)=8000;
s.fschange_ts(1)=min(s.ts);
elseif s.fschange_ts(1) ~= s.ts(1)
if ~unwrapped
s.fschange_ts(1) = s.ts(1);
else
error('TS wrapped, and sample rate change info is not found at the start of file => problem...')
end
end
end_ix=length(send_t);
for k=length(s.fs):-1:1
if (k < length(s.fs) && s.fschange_ts(k) > s.fschange_ts(k+1))
% The sample rate changes are out of order, probably due to
% packet re-ordering.
warning('fschange_ts is out of order')
continue % Skip to the next one.
end
start_ix=find(s.ts==s.fschange_ts(k));
send_t(start_ix:end_ix)=send_t(start_ix:end_ix)/s.fs(k)*1000;
s.playout_delay(start_ix:end_ix)=s.playout_delay(start_ix:end_ix)/s.fs(k)*1000;
s.optbuf(start_ix:end_ix)=s.optbuf(start_ix:end_ix)/s.fs(k)*1000;
end_ix=start_ix-1;
end
tot_time=max(send_t)-min(send_t);
seq_ix=s.sn-min(s.sn)+1;
send_t=send_t+max(min(s.arrival-send_t),0);
plot_send_t=nan*ones(max(seq_ix),1);
plot_send_t(seq_ix)=send_t;
plot_nw_delay=nan*ones(max(seq_ix),1);
plot_nw_delay(seq_ix)=s.arrival-send_t;
cng_ix=find(s.pt~=13); % find those packets that are not CNG/SID
if noplot==0
h=plot(plot_send_t/1000,plot_nw_delay);
set(h,'color',0.75*[1 1 1]);
hold on
if any(s.optbuf~=0)
peak_ix=find(s.optbuf(cng_ix)<0); % peak mode is labeled with negative values
no_peak_ix=find(s.optbuf(cng_ix)>0); %setdiff(1:length(cng_ix),peak_ix);
h1=plot(send_t(cng_ix(peak_ix))/1000,...
s.arrival(cng_ix(peak_ix))+abs(s.optbuf(cng_ix(peak_ix)))-send_t(cng_ix(peak_ix)),...
'r.');
h2=plot(send_t(cng_ix(no_peak_ix))/1000,...
s.arrival(cng_ix(no_peak_ix))+abs(s.optbuf(cng_ix(no_peak_ix)))-send_t(cng_ix(no_peak_ix)),...
'g.');
set([h1, h2],'markersize',1)
end
%h=plot(send_t(seq_ix)/1000,s.decode+s.playout_delay-send_t(seq_ix));
h=plot(send_t(cng_ix)/1000,s.decode(cng_ix)+s.playout_delay(cng_ix)-send_t(cng_ix));
set(h,'linew',1.5);
hold off
ax1=axis;
axis tight
ax2=axis;
axis([ax2(1:3) ax1(4)])
end
% calculate delays and other parameters
delayskip_ix = find(send_t-send_t(1)>=delayskip*1000, 1 );
use_ix = intersect(cng_ix,... % use those that are not CNG/SID frames...
intersect(find(isfinite(s.decode)),... % ... that did arrive ...
(delayskip_ix:length(s.decode))')); % ... and are sent after delayskip seconds
mean_delay = mean(s.decode(use_ix)+s.playout_delay(use_ix)-send_t(use_ix));
neteq_delay = mean(s.decode(use_ix)+s.playout_delay(use_ix)-s.arrival(use_ix));
max_neteq_delay = max(s.decode(use_ix)+s.playout_delay(use_ix)-s.arrival(use_ix));
Npack=max(s.sn(delayskip_ix:end))-min(s.sn(delayskip_ix:end))+1;
nw_lossrate=(Npack-length(s.sn(delayskip_ix:end)))/Npack;
neteq_lossrate=(length(s.sn(delayskip_ix:end))-length(use_ix))/Npack;
delay_struct=struct('mean_delay',mean_delay,'neteq_delay',neteq_delay,...
'max_neteq_delay', max_neteq_delay,...
'nw_lossrate',nw_lossrate,'neteq_lossrate',neteq_lossrate,...
'tot_expand',round(s.tot_expand),'tot_accelerate',round(s.tot_accelerate),...
'tot_preemptive',round(s.tot_preemptive),'tot_time',tot_time,...
'filename',delayfile,'units','ms','fs',unique(s.fs));
if not(isempty(delaypoints))
delayvalues=interp1(send_t(cng_ix),...
s.decode(cng_ix)+s.playout_delay(cng_ix)-send_t(cng_ix),...
delaypoints,'nearest',NaN);
else
delayvalues=[];
end
end
% SUBFUNCTIONS %
function y=unwrap_seqno(x)
jumps=find(abs((diff(x)-1))>65000);
while ~isempty(jumps)
n=jumps(1);
if x(n+1)-x(n) < 0
% negative jump
x(n+1:end)=x(n+1:end)+65536;
else
% positive jump
x(n+1:end)=x(n+1:end)-65536;
end
jumps=find(abs((diff(x)-1))>65000);
end
y=x;
end
function y = unwrap_ts(x)
max_u32 = 4294967295; % 0xFFFFFFFF
% Use the unwrap function made for unrwapping phase angle in radians.
y = round(max_u32 / (2*pi) * unwrap(x * 2*pi / max_u32));
end

View File

@ -1,233 +0,0 @@
/*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include <stdio.h>
#include <iostream>
#include "gflags/gflags.h"
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_internal.h"
#include "webrtc/modules/audio_coding/neteq4/tools/audio_loop.h"
#include "webrtc/modules/audio_coding/neteq4/tools/rtp_generator.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/typedefs.h"
using webrtc::test::AudioLoop;
using webrtc::test::RtpGenerator;
using webrtc::WebRtcRTPHeader;
// Flag validators.
static bool ValidateRuntime(const char* flagname, int value) {
if (value > 0) // Value is ok.
return true;
printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value));
return false;
}
static bool ValidateLossrate(const char* flagname, int value) {
if (value >= 0) // Value is ok.
return true;
printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value));
return false;
}
static bool ValidateDriftfactor(const char* flagname, double value) {
if (value >= 0.0 && value < 1.0) // Value is ok.
return true;
printf("Invalid value for --%s: %f\n", flagname, value);
return false;
}
// Define command line flags.
DEFINE_int32(runtime_ms, 10000, "Simulated runtime in ms.");
static const bool runtime_ms_dummy =
google::RegisterFlagValidator(&FLAGS_runtime_ms, &ValidateRuntime);
DEFINE_int32(lossrate, 10,
"Packet lossrate; drop every N packets.");
static const bool lossrate_dummy =
google::RegisterFlagValidator(&FLAGS_lossrate, &ValidateLossrate);
DEFINE_double(drift, 0.1,
"Clockdrift factor.");
static const bool drift_dummy =
google::RegisterFlagValidator(&FLAGS_drift, &ValidateDriftfactor);
int main(int argc, char* argv[]) {
static const int kMaxChannels = 1;
static const int kMaxSamplesPerMs = 48000 / 1000;
static const int kOutputBlockSizeMs = 10;
const std::string kInputFileName =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
const int kSampRateHz = 32000;
const WebRtcNetEQDecoder kDecoderType = kDecoderPCM16Bswb32kHz;
const int kPayloadType = 95;
std::string program_name = argv[0];
std::string usage = "Tool for measuring the speed of NetEq.\n"
"Usage: " + program_name + " [options]\n\n"
" --runtime_ms=N runtime in ms; default is 10000 ms\n"
" --lossrate=N drop every N packets; default is 10\n"
" --drift=F clockdrift factor between 0.0 and 1.0; "
"default is 0.1\n";
google::SetUsageMessage(usage);
google::ParseCommandLineFlags(&argc, &argv, true);
if (argc != 1) {
// Print usage information.
std::cout << google::ProgramUsage();
return 0;
}
// Initialize NetEq instance.
int error;
int inst_size_bytes;
error = WebRtcNetEQ_AssignSize(&inst_size_bytes);
if (error) {
std::cerr << "Error returned from WebRtcNetEQ_AssignSize." << std::endl;
exit(1);
}
char* inst_mem = new char[inst_size_bytes];
void* neteq_inst;
error = WebRtcNetEQ_Assign(&neteq_inst, inst_mem);
if (error) {
std::cerr << "Error returned from WebRtcNetEQ_Assign." << std::endl;
exit(1);
}
// Select decoders.
WebRtcNetEQDecoder decoder_list[] = {kDecoderType};
int max_number_of_packets;
int buffer_size_bytes;
int overhead_bytes_dummy;
error = WebRtcNetEQ_GetRecommendedBufferSize(
neteq_inst, decoder_list, sizeof(decoder_list) / sizeof(decoder_list[1]),
kTCPLargeJitter, &max_number_of_packets, &buffer_size_bytes,
&overhead_bytes_dummy);
if (error) {
std::cerr << "Error returned from WebRtcNetEQ_GetRecommendedBufferSize."
<< std::endl;
exit(1);
}
char* buffer_mem = new char[buffer_size_bytes];
error = WebRtcNetEQ_AssignBuffer(neteq_inst, max_number_of_packets,
buffer_mem, buffer_size_bytes);
if (error) {
std::cerr << "Error returned from WebRtcNetEQ_AssignBuffer." << std::endl;
exit(1);
}
error = WebRtcNetEQ_Init(neteq_inst, kSampRateHz);
if (error) {
std::cerr << "Error returned from WebRtcNetEQ_Init." << std::endl;
exit(1);
}
// Register decoder.
WebRtcNetEQ_CodecDef codec_definition;
SET_CODEC_PAR(codec_definition, kDecoderType, kPayloadType, NULL,
kSampRateHz);
SET_PCM16B_SWB32_FUNCTIONS(codec_definition);
error = WebRtcNetEQ_CodecDbAdd(neteq_inst, &codec_definition);
if (error) {
std::cerr << "Cannot register decoder." << std::endl;
exit(1);
}
// Set up AudioLoop object.
AudioLoop audio_loop;
const size_t kMaxLoopLengthSamples = kSampRateHz * 10; // 10 second loop.
const size_t kInputBlockSizeSamples = 60 * kSampRateHz / 1000; // 60 ms.
if (!audio_loop.Init(kInputFileName, kMaxLoopLengthSamples,
kInputBlockSizeSamples)) {
std::cerr << "Cannot initialize AudioLoop object." << std::endl;
exit(1);
}
int32_t time_now_ms = 0;
// Get first input packet.
WebRtcRTPHeader rtp_header;
RtpGenerator rtp_gen(kSampRateHz / 1000);
// Start with positive drift first half of simulation.
double drift_factor = 0.1;
rtp_gen.set_drift_factor(drift_factor);
bool drift_flipped = false;
int32_t packet_input_time_ms =
rtp_gen.GetRtpHeader(kPayloadType, kInputBlockSizeSamples, &rtp_header);
const int16_t* input_samples = audio_loop.GetNextBlock();
if (!input_samples) exit(1);
uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
int payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
kInputBlockSizeSamples,
input_payload);
assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
// Main loop.
while (time_now_ms < FLAGS_runtime_ms) {
while (packet_input_time_ms <= time_now_ms) {
// Drop every N packets, where N = FLAGS_lossrate.
bool lost = false;
if (FLAGS_lossrate > 0) {
lost = ((rtp_header.header.sequenceNumber - 1) % FLAGS_lossrate) == 0;
}
if (!lost) {
WebRtcNetEQ_RTPInfo rtp_info;
rtp_info.payloadType = rtp_header.header.payloadType;
rtp_info.sequenceNumber = rtp_header.header.sequenceNumber;
rtp_info.timeStamp = rtp_header.header.timestamp;
rtp_info.SSRC = rtp_header.header.ssrc;
rtp_info.markerBit = rtp_header.header.markerBit;
// Insert packet.
error = WebRtcNetEQ_RecInRTPStruct(
neteq_inst, &rtp_info, input_payload, payload_len,
packet_input_time_ms * kSampRateHz / 1000);
if (error != 0) {
std::cerr << "WebRtcNetEQ_RecInRTPStruct returned error code " <<
WebRtcNetEQ_GetErrorCode(neteq_inst) << std::endl;
exit(1);
}
}
// Get next packet.
packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType,
kInputBlockSizeSamples,
&rtp_header);
input_samples = audio_loop.GetNextBlock();
if (!input_samples) exit(1);
payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
kInputBlockSizeSamples,
input_payload);
assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
}
// Get output audio, but don't do anything with it.
static const int kOutDataLen = kOutputBlockSizeMs * kMaxSamplesPerMs *
kMaxChannels;
int16_t out_data[kOutDataLen];
int16_t samples_per_channel;
error = WebRtcNetEQ_RecOut(neteq_inst, out_data, &samples_per_channel);
if (error != 0) {
std::cerr << "WebRtcNetEQ_RecOut returned error code " <<
WebRtcNetEQ_GetErrorCode(neteq_inst) << std::endl;
exit(1);
}
assert(samples_per_channel == kSampRateHz * 10 / 1000);
time_now_ms += kOutputBlockSizeMs;
if (time_now_ms >= FLAGS_runtime_ms / 2 && !drift_flipped) {
// Apply negative drift second half of simulation.
rtp_gen.set_drift_factor(-drift_factor);
drift_flipped = true;
}
}
std::cout << "Simulation done" << std::endl;
delete [] buffer_mem;
delete [] inst_mem;
return 0;
}

View File

@ -1,15 +0,0 @@
pcmu 0
pcma 8
cn 13
ilbc 102
isac 103
isacswb 104
isacfb 124
avt 106
red 117
cn_wb 98
cn_swb32 99
pcm16b 93
pcm16b_wb 94
pcm16b_swb32khz 95
g722 9

View File

@ -1,124 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
/*
* Parses an rtpdump file and outputs a text table parsable by parseLog.m.
* The output file will have .txt appended to the specified base name.
* $ rtp_to_text [-d] <input_rtp_file> <output_base_name>
*
* -d RTP headers only
*
*/
#include "data_log.h"
#include "NETEQTEST_DummyRTPpacket.h"
#include "NETEQTEST_RTPpacket.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
/*********************/
/* Misc. definitions */
/*********************/
#define FIRSTLINELEN 40
using ::webrtc::DataLog;
int main(int argc, char* argv[])
{
int arg_count = 1;
NETEQTEST_RTPpacket* packet;
if (argc < 3)
{
printf("Usage: %s [-d] <input_rtp_file> <output_base_name>\n", argv[0]);
return -1;
}
// Parse dummy option
if (argc >= 3 && strcmp(argv[arg_count], "-d") == 0)
{
packet = new NETEQTEST_DummyRTPpacket;
++arg_count;
}
else
{
packet = new NETEQTEST_RTPpacket;
}
std::string input_filename = argv[arg_count++];
std::string table_name = argv[arg_count];
std::cout << "Input file: " << input_filename << std::endl;
std::cout << "Output file: " << table_name << ".txt" << std::endl;
FILE *inFile=fopen(input_filename.c_str(),"rb");
if (!inFile)
{
std::cout << "Cannot open input file " << input_filename << std::endl;
return -1;
}
// Set up the DataLog and define the table
DataLog::CreateLog();
if (DataLog::AddTable(table_name) < 0)
{
std::cout << "Error adding table " << table_name << ".txt" << std::endl;
return -1;
}
DataLog::AddColumn(table_name, "seq", 1);
DataLog::AddColumn(table_name, "ssrc", 1);
DataLog::AddColumn(table_name, "payload type", 1);
DataLog::AddColumn(table_name, "length", 1);
DataLog::AddColumn(table_name, "timestamp", 1);
DataLog::AddColumn(table_name, "marker bit", 1);
DataLog::AddColumn(table_name, "arrival", 1);
// read file header
char firstline[FIRSTLINELEN];
if (fgets(firstline, FIRSTLINELEN, inFile) == NULL)
{
std::cout << "Error reading file " << input_filename << std::endl;
return -1;
}
// start_sec + start_usec + source + port + padding
if (fread(firstline, 4+4+4+2+2, 1, inFile) != 1)
{
std::cout << "Error reading file " << input_filename << std::endl;
return -1;
}
while (packet->readFromFile(inFile) >= 0)
{
// write packet headers to
DataLog::InsertCell(table_name, "seq", packet->sequenceNumber());
DataLog::InsertCell(table_name, "ssrc", packet->SSRC());
DataLog::InsertCell(table_name, "payload type", packet->payloadType());
DataLog::InsertCell(table_name, "length", packet->dataLen());
DataLog::InsertCell(table_name, "timestamp", packet->timeStamp());
DataLog::InsertCell(table_name, "marker bit", packet->markerBit());
DataLog::InsertCell(table_name, "arrival", packet->time());
DataLog::NextRow(table_name);
return -1;
}
DataLog::ReturnLog();
fclose(inFile);
return 0;
}