From 62b3f9a5aa12d59b37199f13efdcd7c202814538 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Tue, 18 Mar 2008 01:28:59 +0000 Subject: [PATCH] using spandsp PLC (optional) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@806 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmRtpAudio.cpp | 22 +++++++++++++++++++--- core/AmRtpAudio.h | 13 ++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/core/AmRtpAudio.cpp b/core/AmRtpAudio.cpp index 02c47ee9..3477b8a5 100644 --- a/core/AmRtpAudio.cpp +++ b/core/AmRtpAudio.cpp @@ -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) diff --git a/core/AmRtpAudio.h b/core/AmRtpAudio.h index 802540a8..768a0fe2 100644 --- a/core/AmRtpAudio.h +++ b/core/AmRtpAudio.h @@ -32,6 +32,11 @@ #include "AmRtpStream.h" #include "LowcFE.h" +#ifdef USE_SPANDSP_PLC +#include +#include "spandsp/plc.h" +#endif + class AmPlayoutBuffer; enum PlayoutType { @@ -65,7 +70,12 @@ class AmRtpAudio: public AmRtpStream, public AmAudio, public AmPLCBuffer { auto_ptr 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();