Commit 68a0887b authored by Simon Morlat's avatar Simon Morlat

experiment usage of oslec echo canceller (as a plugin)

parent e4596609
......@@ -223,6 +223,16 @@ MS2_PUBLIC MSFilterDesc * ms_filter_get_encoder(const char *mime);
*/
MS2_PUBLIC MSFilterDesc * ms_filter_get_decoder(const char *mime);
/**
* Lookup a mediastreamer2 filter using its name.
* If found, the descriptor (MSFilterDesc) is returned.
* This descriptor can be used to instanciate the filter using ms_filter_new_from_desc()
* This function can be useful to query the presence of a filter loaded as a plugin, for example.
*
* @param name The filter name.
**/
MS2_PUBLIC MSFilterDesc *ms_filter_lookup_by_name(const char *filter_name);
/**
* Create encoder filter according to codec name.
*
......
......@@ -299,7 +299,11 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
/*configure the echo canceller if required */
if (use_ec) {
stream->ec=ms_filter_new(MS_SPEEX_EC_ID);
MSFilterDesc *ec_desc=ms_filter_lookup_by_name("MSOslec");
if (ec_desc!=NULL)
stream->ec=ms_filter_new_from_desc(ec_desc);
else
stream->ec=ms_filter_new(MS_SPEEX_EC_ID);
ms_filter_call_method(stream->ec,MS_FILTER_SET_SAMPLE_RATE,&sample_rate);
if (stream->ec_tail_len!=0)
ms_filter_call_method(stream->ec,MS_ECHO_CANCELLER_SET_TAIL_LENGTH,&stream->ec_tail_len);
......@@ -309,7 +313,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
/*configure from latency of sound card in case it is availlable */
int latency=0;
ms_filter_call_method(stream->soundread,MS_FILTER_GET_LATENCY,&latency);
latency-=30; /*keep 30 milliseconds security margin*/
latency-=20; /*keep 30 milliseconds security margin*/
if (latency<0) latency=0;
ms_filter_call_method(stream->ec,MS_ECHO_CANCELLER_SET_DELAY,&latency);
}
......
......@@ -133,18 +133,23 @@ MSFilter *ms_filter_new(MSFilterId id){
return NULL;
}
MSFilter *ms_filter_new_from_name(const char *filter_name){
MSFilterDesc *ms_filter_lookup_by_name(const char *filter_name){
MSList *elem;
for (elem=desc_list;elem!=NULL;elem=ms_list_next(elem)){
MSFilterDesc *desc=(MSFilterDesc*)elem->data;
if (strcmp(desc->name,filter_name)==0){
return ms_filter_new_from_desc(desc);
return desc;
}
}
ms_error("No such filter with name %s",filter_name);
return NULL;
}
MSFilter *ms_filter_new_from_name(const char *filter_name){
MSFilterDesc *desc=ms_filter_lookup_by_name(filter_name);
if (desc==NULL) return NULL;
return ms_filter_new_from_desc(desc);
}
MSFilterId ms_filter_get_id(MSFilter *f){
return f->desc->id;
......
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