using spandsp PLC (optional)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@806 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent fa714ad55a
commit 62b3f9a5aa

@ -37,6 +37,15 @@ AmRtpAudio::AmRtpAudio(AmSession* _s)
send_only(false), playout_buffer(new AmPlayoutBuffer(this)),
last_check(0),last_check_i(false),send_int(false)
{
#ifdef USE_SPANDSP_PLC
plc_state = plc_init(NULL);
#endif // USE_SPANDSP_PLC
}
AmRtpAudio::~AmRtpAudio() {
#ifdef USE_SPANDSP_PLC
plc_release(plc_state);
#endif // USE_SPANDSP_PLC
}
bool AmRtpAudio::checkInterval(unsigned int ts, unsigned int frame_size)
@ -179,27 +188,34 @@ unsigned int AmRtpAudio::default_plc(unsigned char* out_buf,
{
short* buf_offset = (short*)out_buf;
#ifdef USE_SPANDSP_PLC
plc_fillin(plc_state, buf_offset, PCM16_B2S(size));
#else
for(unsigned int i=0; i<(PCM16_B2S(size)/FRAMESZ); i++){
fec.dofe(buf_offset);
buf_offset += FRAMESZ;
}
#endif // USE_SPANDSP_PLC
return PCM16_S2B(buf_offset - (short*)out_buf);
}
void AmRtpAudio::add_to_history(int16_t *buffer, unsigned int size)
{
int16_t* buf_offset = buffer;
if (!use_default_plc)
return;
for(unsigned int i=0; i<(PCM16_B2S(size)/FRAMESZ); i++){
#ifdef USE_SPANDSP_PLC
plc_rx(plc_state, buffer, PCM16_B2S(size));
#else // USE_SPANDSP_PLC
int16_t* buf_offset = buffer;
for(unsigned int i=0; i<(PCM16_B2S(size)/FRAMESZ); i++){
fec.addtohistory(buf_offset);
buf_offset += FRAMESZ;
}
#endif // USE_SPANDSP_PLC
}
void AmRtpAudio::setPlayoutType(PlayoutType type)

@ -32,6 +32,11 @@
#include "AmRtpStream.h"
#include "LowcFE.h"
#ifdef USE_SPANDSP_PLC
#include <math.h>
#include "spandsp/plc.h"
#endif
class AmPlayoutBuffer;
enum PlayoutType {
@ -65,7 +70,12 @@ class AmRtpAudio: public AmRtpStream, public AmAudio, public AmPLCBuffer
{
auto_ptr<AmPlayoutBuffer> playout_buffer;
LowcFE fec;
#ifdef USE_SPANDSP_PLC
plc_state_t* plc_state;
#else
LowcFE fec;
#endif
bool use_default_plc;
unsigned int last_check;
@ -84,6 +94,7 @@ class AmRtpAudio: public AmRtpStream, public AmAudio, public AmPLCBuffer
public:
AmRtpAudio(AmSession* _s=0);
~AmRtpAudio();
bool checkInterval(unsigned int ts, unsigned int frame_size);
bool sendIntReached();

Loading…
Cancel
Save