Commit 735dc084 authored by Simon Morlat's avatar Simon Morlat

support for conference in wideband and narrowband

parent 0a67d554
......@@ -27,11 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mediastream.h"
typedef struct _MSAudioConferenceParams{
int samplerate;
}MSAudioConferenceParams;
struct _MSAudioConference{
MSTicker *ticker;
MSFilter *mixer;
int mixer_rate;
MSAudioConferenceParams params;
int nmembers;
};
......@@ -47,22 +50,25 @@ struct _MSAudioEndpoint{
MSCPoint mixer_out;
MSAudioConference *conference;
int pin;
int samplerate;
};
typedef struct _MSAudioEndpoint MSAudioEndpoint;
#ifdef __cplusplus
extern "C" {
#endif
MSAudioConference * ms_audio_conference_new(void);
MSAudioConference * ms_audio_conference_new(const MSAudioConferenceParams *params);
const MSAudioConferenceParams *ms_audio_conference_get_params(MSAudioConference *obj);
void ms_audio_conference_add_member(MSAudioConference *obj, MSAudioEndpoint *ep);
void ms_audio_conference_remove_member(MSAudioConference *obj, MSAudioEndpoint *ep);
void ms_audio_conference_mute_member(MSAudioConference *obj, MSAudioEndpoint *ep, bool_t muted);
void ms_audio_conference_destroy(MSAudioConference *obj);
int ms_audio_conference_size(MSAudioConference *obj);
void ms_audio_conference_destroy(MSAudioConference *obj);
MSAudioEndpoint * ms_audio_endpoint_get_from_stream(AudioStream *st, bool_t is_remote);
void ms_audio_endpoint_release_from_stream(MSAudioEndpoint *obj);
......
......@@ -24,17 +24,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void ms_audio_endpoint_destroy(MSAudioEndpoint *ep);
MSAudioConference * ms_audio_conference_new(void){
MSAudioConference * ms_audio_conference_new(const MSAudioConferenceParams *params){
MSAudioConference *obj=ms_new0(MSAudioConference,1);
int tmp=1;
obj->ticker=ms_ticker_new();
obj->mixer=ms_filter_new(MS_AUDIO_MIXER_ID);
obj->mixer_rate=8000;
obj->params=*params;
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);
ms_filter_call_method(obj->mixer,MS_FILTER_SET_SAMPLE_RATE,&obj->params.samplerate);
return obj;
}
const MSAudioConferenceParams *ms_audio_conference_get_params(MSAudioConference *obj){
return &obj->params;
}
static MSCPoint just_before(MSFilter *f){
MSQueue *q;
MSCPoint pnull={0};
......@@ -75,6 +79,8 @@ static void cut_audio_stream_graph(MSAudioEndpoint *ep, bool_t is_remote){
ep->out_cut_point=just_before(st->encoder);
ms_filter_unlink(ep->out_cut_point.filter,ep->out_cut_point.pin,st->encoder,0);
ms_filter_call_method(st->rtpsend,MS_FILTER_GET_SAMPLE_RATE,&ep->samplerate);
if (is_remote){
ep->mixer_in.filter=ep->in_cut_point_prev.filter;
ep->mixer_in.pin=ep->in_cut_point_prev.pin;
......@@ -109,7 +115,7 @@ 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;
int in_rate=ep->samplerate,out_rate=ep->samplerate;
ep->pin=find_free_pin(conf->mixer);
ms_filter_link(ep->mixer_in.filter,ep->mixer_in.pin,ep->in_resampler,0);
......@@ -118,10 +124,8 @@ static void plumb_to_conf(MSAudioEndpoint *ep){
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_OUTPUT_SAMPLE_RATE,&conf->params.samplerate);
ms_filter_call_method(ep->out_resampler,MS_FILTER_SET_SAMPLE_RATE,&conf->params.samplerate);
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);
......@@ -166,6 +170,7 @@ 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);
ep->samplerate=8000;
return ep;
}
......
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