Commit 22816808 authored by Simon Morlat's avatar Simon Morlat

conference: many fixes, starts working

parent a8ca8f20
......@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct _MSAudioConference{
MSTicker *ticker;
MSFilter *mixer;
int mixer_rate;
int nmembers;
};
......
......@@ -29,7 +29,9 @@ MSAudioConference * ms_audio_conference_new(void){
int tmp=1;
obj->ticker=ms_ticker_new();
obj->mixer=ms_filter_new(MS_AUDIO_MIXER_ID);
obj->mixer_rate=8000;
ms_filter_call_method(obj->mixer,MS_AUDIO_MIXER_ENABLE_CONFERENCE_MODE,&tmp);
ms_filter_call_method(obj->mixer,MS_FILTER_SET_SAMPLE_RATE,&obj->mixer_rate);
return obj;
}
......@@ -100,13 +102,22 @@ static int find_free_pin(MSFilter *mixer){
static void plumb_to_conf(MSAudioEndpoint *ep){
MSAudioConference *conf=ep->conference;
int in_rate=8000,out_rate=8000;
ep->pin=find_free_pin(conf->mixer);
ms_filter_link(ep->mixer_in.filter,ep->mixer_in.pin,ep->in_resampler,0);
ms_filter_link(ep->in_resampler,0,conf->mixer,ep->pin);
ms_filter_link(conf->mixer,ep->pin,ep->out_resampler,0);
ms_filter_link(ep->out_resampler,0,ep->mixer_out.filter,ep->mixer_out.pin);
/*configure resamplers*/
ms_filter_call_method(ep->mixer_in.filter,MS_FILTER_GET_SAMPLE_RATE,&in_rate);
ms_filter_call_method(ep->mixer_out.filter,MS_FILTER_GET_SAMPLE_RATE,&out_rate);
ms_filter_call_method(ep->in_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&conf->mixer_rate);
ms_filter_call_method(ep->out_resampler,MS_FILTER_SET_SAMPLE_RATE,&conf->mixer_rate);
ms_filter_call_method(ep->in_resampler,MS_FILTER_SET_SAMPLE_RATE,&in_rate);
ms_filter_call_method(ep->out_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&out_rate);
}
void ms_audio_conference_add_member(MSAudioConference *obj, MSAudioEndpoint *ep){
......@@ -146,11 +157,14 @@ void ms_audio_conference_destroy(MSAudioConference *obj){
MSAudioEndpoint *ms_audio_endpoint_new(void){
MSAudioEndpoint *ep=ms_new0(MSAudioEndpoint,1);
ep->in_resampler=ms_filter_new(MS_RESAMPLE_ID);
ep->out_resampler=ms_filter_new(MS_RESAMPLE_ID);
return ep;
}
MSAudioEndpoint * ms_audio_endpoint_get_from_stream(AudioStream *st, bool_t is_remote){
MSAudioEndpoint *ep=ms_audio_endpoint_new();
ep->st=st;
cut_audio_stream_graph(ep,is_remote);
return ep;
}
......
......@@ -74,8 +74,8 @@ static int channel_process_in(Channel *chan, MSQueue *q, int32_t *sum, int nsamp
if (chan->active){
if (chan->gain!=1.0){
apply_gain(chan->input,nsamples,chan->gain);
accumulate(sum,chan->input,nsamples);
}
accumulate(sum,chan->input,nsamples);
}
return nsamples;
}else memset(chan->input,0,nsamples*2);
......@@ -315,7 +315,7 @@ MSFilterDesc ms_audio_mixer_desc={
.text=N_("A filter that mixes down 16 bit sample audio streams"),
.category=MS_FILTER_OTHER,
.ninputs=MIXER_MAX_CHANNELS,
.noutputs=1,
.noutputs=MIXER_MAX_CHANNELS,
.init=mixer_init,
.preprocess=mixer_preprocess,
.process=mixer_process,
......
......@@ -119,9 +119,15 @@ static int enc_add_fmtp(MSFilter *f, void *arg){
return 0;
}
static int get_sr(MSFilter *f, void *arg){
*(int*)arg=16000;
return 0;
}
static MSFilterMethod enc_methods[]={
{ MS_FILTER_ADD_ATTR , enc_add_attr},
{ MS_FILTER_ADD_FMTP , enc_add_fmtp},
{ MS_FILTER_GET_SAMPLE_RATE, get_sr },
{ 0 , NULL }
};
......@@ -201,6 +207,11 @@ static void dec_process(MSFilter *f)
}
};
static MSFilterMethod dec_methods[]={
{ MS_FILTER_GET_SAMPLE_RATE, get_sr },
{ 0 , NULL }
};
#ifdef _MSC_VER
MSFilterDesc ms_g722_dec_desc={
......@@ -216,7 +227,7 @@ MSFilterDesc ms_g722_dec_desc={
dec_process,
NULL,
dec_uninit,
NULL
dec_methods
};
#else
......@@ -231,7 +242,8 @@ MSFilterDesc ms_g722_dec_desc={
.noutputs = 1,
.init = dec_init,
.process = dec_process,
.uninit = dec_uninit
.uninit = dec_uninit,
.methods = dec_methods
};
#endif
......
......@@ -263,11 +263,16 @@ static void enc_postprocess(MSFilter *f){
static int enc_set_sr(MSFilter *f, void *arg){
SpeexEncState *s=(SpeexEncState*)f->data;
/* TODO: should be done with fmtp parameter */
s->rate=((int*)arg)[0];
return 0;
}
static int enc_get_sr(MSFilter *f, void *arg){
SpeexEncState *s=(SpeexEncState*)f->data;
((int*)arg)[0]=s->rate;
return 0;
}
static int enc_set_br(MSFilter *f, void *arg){
SpeexEncState *s=(SpeexEncState*)f->data;
ms_filter_lock(f);
......@@ -378,6 +383,7 @@ static int enc_add_attr(MSFilter *f, void *arg){
static MSFilterMethod enc_methods[]={
{ MS_FILTER_SET_SAMPLE_RATE , enc_set_sr },
{ MS_FILTER_GET_SAMPLE_RATE , enc_get_sr },
{ MS_FILTER_SET_BITRATE , enc_set_br },
{ MS_FILTER_GET_BITRATE , enc_get_br },
{ MS_FILTER_ADD_FMTP , enc_add_fmtp },
......@@ -490,6 +496,12 @@ static void dec_postprocess(MSFilter *f){
s->state=NULL;
}
static int dec_get_sr(MSFilter *f, void *arg){
DecState *s=(DecState*)f->data;
((int*)arg)[0]=s->rate;
return 0;
}
static int dec_set_sr(MSFilter *f, void *arg){
DecState *s=(DecState*)f->data;
s->rate=((int*)arg)[0];
......@@ -569,6 +581,7 @@ static void dec_process(MSFilter *f){
static MSFilterMethod dec_methods[]={
{ MS_FILTER_SET_SAMPLE_RATE , dec_set_sr },
{ MS_FILTER_GET_SAMPLE_RATE , dec_get_sr },
{ MS_FILTER_ADD_FMTP , dec_add_fmtp },
{ 0 , NULL }
};
......
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