Commit e9c8fddc authored by Ghislain MARY's avatar Ghislain MARY

Flow controller is now a public API.

parent b921f138
......@@ -23,23 +23,23 @@
typedef struct _AudioFlowController {
typedef struct _MSAudioFlowController {
int target_samples;
int total_samples;
int current_pos;
int current_dropped;
} AudioFlowController;
} MSAudioFlowController;
#ifdef __cplusplus
extern "C"{
#endif
void audio_flow_controller_init(AudioFlowController *ctl);
void ms_audio_flow_controller_init(MSAudioFlowController *ctl);
void audio_flow_controller_set_target(AudioFlowController *ctl, int samples_to_drop, int total_samples);
void ms_audio_flow_controller_set_target(MSAudioFlowController *ctl, int samples_to_drop, int total_samples);
mblk_t *audio_flow_controller_process(AudioFlowController *ctl, mblk_t *m);
mblk_t *ms_audio_flow_controller_process(MSAudioFlowController *ctl, mblk_t *m);
#ifdef __cplusplus
......@@ -47,4 +47,3 @@ mblk_t *audio_flow_controller_process(AudioFlowController *ctl, mblk_t *m);
#endif
#endif
......@@ -160,7 +160,6 @@ set(VOIP_SOURCE_FILES
audiofilters/dtmfgen.c
audiofilters/equalizer.c
audiofilters/flowcontrol.c
audiofilters/flowcontrol.h
audiofilters/g711.c
audiofilters/g711.h
audiofilters/genericplc.c
......
......@@ -104,7 +104,7 @@ libmediastreamer_voip_la_SOURCES+= audiofilters/alaw.c \
audiofilters/msfileplayer.c \
audiofilters/msfilerec.c \
audiofilters/waveheader.h \
audiofilters/flowcontrol.c audiofilters/flowcontrol.h
audiofilters/flowcontrol.c
if BUILD_SPEEX
libmediastreamer_voip_la_SOURCES+= audiofilters/msspeex.c audiofilters/speexec.c
......
......@@ -19,9 +19,9 @@
*/
#include "mediastreamer2/mscommon.h"
#include "flowcontrol.h"
#include "mediastreamer2/flowcontrol.h"
void audio_flow_controller_init(AudioFlowController *ctl)
void ms_audio_flow_controller_init(MSAudioFlowController *ctl)
{
ctl->target_samples = 0;
ctl->total_samples = 0;
......@@ -29,7 +29,7 @@ void audio_flow_controller_init(AudioFlowController *ctl)
ctl->current_dropped = 0;
}
void audio_flow_controller_set_target(AudioFlowController *ctl, int samples_to_drop, int total_samples)
void ms_audio_flow_controller_set_target(MSAudioFlowController *ctl, int samples_to_drop, int total_samples)
{
ctl->target_samples = samples_to_drop;
ctl->total_samples = total_samples;
......@@ -73,7 +73,7 @@ static void discard_well_choosed_samples(mblk_t *m, int nsamples, int todrop)
}
}
mblk_t *audio_flow_controller_process(AudioFlowController *ctl, mblk_t *m)
mblk_t *ms_audio_flow_controller_process(MSAudioFlowController *ctl, mblk_t *m)
{
if (ctl->total_samples > 0 && ctl->target_samples > 0) {
int nsamples = (m->b_wptr - m->b_rptr) / 2;
......
......@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <malloc.h> /* for alloca */
#endif
#include "flowcontrol.h"
#include "mediastreamer2/flowcontrol.h"
//#define EC_DUMP 1
......@@ -64,7 +64,7 @@ typedef struct SpeexECState{
int tail_length_ms;
int nominal_ref_samples;
int min_ref_samples;
AudioFlowController afc;
MSAudioFlowController afc;
uint64_t flow_control_time;
char *state_str;
#ifdef EC_DUMP
......@@ -207,7 +207,7 @@ static void speex_ec_preprocess(MSFilter *f){
ms_bufferizer_put (&s->delayed_ref,m);
s->min_ref_samples=-1;
s->nominal_ref_samples=delay_samples;
audio_flow_controller_init(&s->afc);
ms_audio_flow_controller_init(&s->afc);
s->flow_control_time = f->ticker->time;
#ifdef SPEEX_ECHO_GET_BLOB
apply_config(s);
......@@ -240,7 +240,7 @@ static void speex_ec_process(MSFilter *f){
if (f->inputs[0]!=NULL){
if (s->echostarted){
while((refm=ms_queue_get(f->inputs[0]))!=NULL){
refm=audio_flow_controller_process(&s->afc,refm);
refm=ms_audio_flow_controller_process(&s->afc,refm);
if (refm){
mblk_t *cp=dupmsg(refm);
ms_bufferizer_put(&s->delayed_ref,cp);
......@@ -322,7 +322,7 @@ static void speex_ec_process(MSFilter *f){
if (diff>(nbytes/2)){
int purge=diff-(nbytes/2);
ms_warning("echo canceller: we are accumulating too much reference signal, need to throw out %i samples",purge);
audio_flow_controller_set_target(&s->afc,purge,(flow_control_interval_ms*s->samplerate)/1000);
ms_audio_flow_controller_set_target(&s->afc,purge,(flow_control_interval_ms*s->samplerate)/1000);
}
s->min_ref_samples=-1;
s->flow_control_time = f->ticker->time;
......
......@@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EC_DUMP_PREFIX "/dynamic/tests"
#endif
#include "flowcontrol.h"
#include "mediastreamer2/flowcontrol.h"
static const float smooth_factor = 0.05;
static const int framesize = 80;
......@@ -58,7 +58,7 @@ typedef struct WebRTCAECState {
int delay_ms;
int nominal_ref_samples;
int min_ref_samples;
AudioFlowController afc;
MSAudioFlowController afc;
uint64_t flow_control_time;
char *state_str;
#ifdef EC_DUMP
......@@ -155,7 +155,7 @@ static void webrtc_aec_preprocess(MSFilter *f)
ms_bufferizer_put(&s->delayed_ref, m);
s->min_ref_samples = -1;
s->nominal_ref_samples = delay_samples;
audio_flow_controller_init(&s->afc);
ms_audio_flow_controller_init(&s->afc);
s->flow_control_time = f->ticker->time;
}
......@@ -184,7 +184,7 @@ static void webrtc_aec_process(MSFilter *f)
if (f->inputs[0] != NULL) {
if (s->echostarted) {
while ((refm = ms_queue_get(f->inputs[0])) != NULL) {
refm=audio_flow_controller_process(&s->afc,refm);
refm=ms_audio_flow_controller_process(&s->afc,refm);
if (refm){
mblk_t *cp=dupmsg(refm);
ms_bufferizer_put(&s->delayed_ref,cp);
......@@ -266,7 +266,7 @@ static void webrtc_aec_process(MSFilter *f)
if (diff > (nbytes / 2)) {
int purge = diff - (nbytes / 2);
ms_warning("echo canceller: we are accumulating too much reference signal, need to throw out %i samples", purge);
audio_flow_controller_set_target(&s->afc, purge, (flow_control_interval_ms * s->samplerate) / 1000);
ms_audio_flow_controller_set_target(&s->afc, purge, (flow_control_interval_ms * s->samplerate) / 1000);
}
s->min_ref_samples = -1;
s->flow_control_time = f->ticker->time;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment