mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Updating echo cancellation and adding MSFactory into Sal structure.
This commit is contained in:
parent
e5632b3ee3
commit
1f624ada80
11 changed files with 39 additions and 37 deletions
|
|
@ -464,13 +464,13 @@ static void process_auth_requested(void *sal, belle_sip_auth_event_t *event) {
|
|||
sal_auth_info_delete(auth_info);
|
||||
}
|
||||
|
||||
Sal * sal_init(){
|
||||
Sal * sal_init(MSFactory *factory){
|
||||
belle_sip_listener_callbacks_t listener_callbacks;
|
||||
Sal * sal=ms_new0(Sal,1);
|
||||
|
||||
/*belle_sip_object_enable_marshal_check(TRUE);*/
|
||||
sal->auto_contacts=TRUE;
|
||||
|
||||
sal->factory = factory;
|
||||
/*first create the stack, which initializes the belle-sip object's pool for this thread*/
|
||||
belle_sip_set_log_handler(_belle_sip_log);
|
||||
sal->stack = belle_sip_stack_new(NULL);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "belle-sip/belle-sdp.h"
|
||||
|
||||
struct Sal{
|
||||
MSFactory *factory;
|
||||
SalCallbacks callbacks;
|
||||
MSList *pending_auths;/*MSList of SalOp */
|
||||
belle_sip_stack_t* stack;
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ static void sdp_process(SalOp *h){
|
|||
|
||||
h->result=sal_media_description_new();
|
||||
if (h->sdp_offering){
|
||||
offer_answer_initiate_outgoing(h->base.local_media,h->base.remote_media,h->result);
|
||||
offer_answer_initiate_outgoing(h->base.root->factory, h->base.local_media,h->base.remote_media,h->result);
|
||||
}else{
|
||||
int i;
|
||||
if (h->sdp_answer){
|
||||
belle_sip_object_unref(h->sdp_answer);
|
||||
}
|
||||
offer_answer_initiate_incoming(h->base.local_media,h->base.remote_media,h->result,h->base.root->one_matching_codec);
|
||||
offer_answer_initiate_incoming(h->base.root->factory, h->base.local_media,h->base.remote_media,h->result,h->base.root->one_matching_codec);
|
||||
/*for backward compatibility purpose*/
|
||||
if(h->cnx_ip_to_0000_if_sendonly_enabled && sal_media_description_has_dir(h->result,SalStreamSendOnly)) {
|
||||
set_addr_to_0000(h->result->addr);
|
||||
|
|
|
|||
|
|
@ -41,26 +41,26 @@ static void ecc_init_filters(EcCalibrator *ecc){
|
|||
ms_filter_call_method(ecc->sndread,MS_FILTER_GET_SAMPLE_RATE,&rate);
|
||||
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_NCHANNELS,&ecc_channels);
|
||||
ms_filter_call_method(ecc->sndread,MS_FILTER_GET_NCHANNELS,&channels);
|
||||
ecc->read_resampler=ms_filter_new(MS_RESAMPLE_ID);
|
||||
ecc->read_resampler=ms_factory_create_filter(ecc->factory, MS_RESAMPLE_ID);
|
||||
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_SAMPLE_RATE,&rate);
|
||||
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&ecc->rate);
|
||||
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_NCHANNELS,&ecc_channels);
|
||||
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_NCHANNELS,&channels);
|
||||
|
||||
|
||||
ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID);
|
||||
ecc->det=ms_factory_create_filter(ecc->factory, MS_TONE_DETECTOR_ID);
|
||||
ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ecc->rec=ms_filter_new(MS_VOID_SINK_ID);
|
||||
ecc->rec=ms_factory_create_filter(ecc->factory, MS_VOID_SINK_ID);
|
||||
|
||||
ms_filter_link(ecc->sndread,0,ecc->read_resampler,0);
|
||||
ms_filter_link(ecc->read_resampler,0,ecc->det,0);
|
||||
ms_filter_link(ecc->det,0,ecc->rec,0);
|
||||
|
||||
ecc->play=ms_filter_new(MS_VOID_SOURCE_ID);
|
||||
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
|
||||
ecc->play=ms_factory_create_filter(ecc->factory, MS_VOID_SOURCE_ID);
|
||||
ecc->gen=ms_factory_create_filter(ecc->factory, MS_DTMF_GEN_ID);
|
||||
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ecc->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
|
||||
ecc->sndwrite=ms_snd_card_create_writer(ecc->play_card);
|
||||
ecc->write_resampler=ms_factory_create_filter(ecc->factory, MS_RESAMPLE_ID);
|
||||
ecc->sndwrite=ms_snd_card_create_writer((void*)ecc->factory, ecc->play_card);
|
||||
|
||||
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
|
||||
|
|
@ -281,7 +281,7 @@ static void * ecc_thread(void *p){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb,
|
||||
EcCalibrator * ec_calibrator_new(MSFactory *factory, MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb,
|
||||
LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data){
|
||||
EcCalibrator *ecc=ms_new0(EcCalibrator,1);
|
||||
|
||||
|
|
@ -292,6 +292,7 @@ EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, uns
|
|||
ecc->audio_uninit_cb=audio_uninit_cb;
|
||||
ecc->capt_card=capt_card;
|
||||
ecc->play_card=play_card;
|
||||
ecc->factory=factory;
|
||||
return ecc;
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +318,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
|
|||
return -1;
|
||||
}
|
||||
rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
|
||||
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,audio_init_cb,audio_uninit_cb,cb_data);
|
||||
lc->ecc=ec_calibrator_new(lc->factory, lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,audio_init_cb,audio_uninit_cb,cb_data);
|
||||
lc->ecc->play_cool_tones = lp_config_get_int(lc->config, "sound", "ec_calibrator_cool_tones", 0);
|
||||
ec_calibrator_start(lc->ecc);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -2437,7 +2437,8 @@ void linphone_call_init_video_stream(LinphoneCall *call){
|
|||
|
||||
call->videostream=video_stream_new2(linphone_call_get_bind_ip_for_stream(call,call->main_video_stream_index),
|
||||
multicast_role == SalMulticastReceiver ? stream_desc->rtp_port : call->media_ports[call->main_video_stream_index].rtp_port,
|
||||
multicast_role == SalMulticastReceiver ? 0 /*disabled for now*/ : call->media_ports[call->main_video_stream_index].rtcp_port);
|
||||
multicast_role == SalMulticastReceiver ? 0 /*disabled for now*/ : call->media_ports[call->main_video_stream_index].rtcp_port,
|
||||
lc->factory);
|
||||
if (multicast_role == SalMulticastReceiver)
|
||||
linphone_call_join_multicast_group(call, call->main_video_stream_index, &call->videostream->ms);
|
||||
rtp_session_enable_network_simulation(call->videostream->ms.sessions.rtp_session, &lc->net_conf.netsim_params);
|
||||
|
|
@ -2448,7 +2449,7 @@ void linphone_call_init_video_stream(LinphoneCall *call){
|
|||
setup_dtls_params(call, &call->videostream->ms);
|
||||
media_stream_reclaim_sessions(&call->videostream->ms, &call->sessions[call->main_video_stream_index]);
|
||||
}else{
|
||||
call->videostream=video_stream_new_with_sessions(&call->sessions[call->main_video_stream_index]);
|
||||
call->videostream=video_stream_new_with_sessions(&call->sessions[call->main_video_stream_index], lc->factory);
|
||||
}
|
||||
|
||||
if (call->media_ports[call->main_video_stream_index].rtp_port==-1){
|
||||
|
|
|
|||
|
|
@ -1679,20 +1679,18 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab
|
|||
|
||||
if (lc->factory == NULL){
|
||||
lc->factory = ms_factory_new();
|
||||
ms_factory_init_voip(lc->factory);
|
||||
ms_factory_init_plugins(lc->factory);
|
||||
|
||||
}
|
||||
//ms_init();
|
||||
|
||||
ms_factory_init_voip(lc->factory);
|
||||
ms_factory_init_plugins(lc->factory);
|
||||
|
||||
linphone_core_register_default_codecs(lc);
|
||||
linphone_core_register_offer_answer_providers(lc);
|
||||
/* Get the mediastreamer2 event queue */
|
||||
/* This allows to run event's callback in linphone_core_iterate() */
|
||||
//lc->msevq=ms_factory_create_event_queue(ms_factory_get_fallback());
|
||||
lc->msevq=ms_factory_create_event_queue(lc->factory);
|
||||
|
||||
lc->sal=sal_init();
|
||||
lc->sal=sal_init(lc->factory);
|
||||
sal_set_http_proxy_host(lc->sal, linphone_core_get_http_proxy_host(lc));
|
||||
sal_set_http_proxy_port(lc->sal, linphone_core_get_http_proxy_port(lc));
|
||||
|
||||
|
|
|
|||
|
|
@ -154,10 +154,10 @@ void linphone_core_register_offer_answer_providers(LinphoneCore *lc){
|
|||
/*
|
||||
* Returns a PayloadType from the local list that matches a PayloadType offered or answered in the remote list
|
||||
*/
|
||||
static PayloadType * find_payload_type_best_match(const MSList *local_payloads, const PayloadType *refpt,
|
||||
static PayloadType * find_payload_type_best_match(MSFactory *factory, const MSList *local_payloads, const PayloadType *refpt,
|
||||
const MSList *remote_payloads, bool_t reading_response){
|
||||
PayloadType *ret = NULL;
|
||||
MSOfferAnswerContext *ctx = ms_factory_create_offer_answer_context(ms_factory_get_fallback(), refpt->mime_type);
|
||||
MSOfferAnswerContext *ctx = ms_factory_create_offer_answer_context(factory, refpt->mime_type);
|
||||
if (ctx){
|
||||
ms_message("Doing offer/answer processing with specific provider for codec [%s]", refpt->mime_type);
|
||||
ret = ms_offer_answer_context_match_payload(ctx, local_payloads, refpt, remote_payloads, reading_response);
|
||||
|
|
@ -168,7 +168,7 @@ static PayloadType * find_payload_type_best_match(const MSList *local_payloads,
|
|||
}
|
||||
|
||||
|
||||
static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t reading_response, bool_t one_matching_codec){
|
||||
static MSList *match_payloads(MSFactory *factory, const MSList *local, const MSList *remote, bool_t reading_response, bool_t one_matching_codec){
|
||||
const MSList *e2,*e1;
|
||||
MSList *res=NULL;
|
||||
PayloadType *matched;
|
||||
|
|
@ -176,7 +176,7 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t
|
|||
|
||||
for(e2=remote;e2!=NULL;e2=e2->next){
|
||||
PayloadType *p2=(PayloadType*)e2->data;
|
||||
matched=find_payload_type_best_match(local, p2, remote, reading_response);
|
||||
matched=find_payload_type_best_match(factory, local, p2, remote, reading_response);
|
||||
if (matched){
|
||||
int local_number=payload_type_get_number(matched);
|
||||
int remote_number=payload_type_get_number(p2);
|
||||
|
|
@ -321,11 +321,11 @@ static SalStreamDir compute_dir_incoming(SalStreamDir local, SalStreamDir offere
|
|||
return res;
|
||||
}
|
||||
|
||||
static void initiate_outgoing(const SalStreamDescription *local_offer,
|
||||
static void initiate_outgoing(MSFactory* factory, const SalStreamDescription *local_offer,
|
||||
const SalStreamDescription *remote_answer,
|
||||
SalStreamDescription *result){
|
||||
if (remote_answer->rtp_port!=0)
|
||||
result->payloads=match_payloads(local_offer->payloads,remote_answer->payloads,TRUE,FALSE);
|
||||
result->payloads=match_payloads(factory, local_offer->payloads,remote_answer->payloads,TRUE,FALSE);
|
||||
else {
|
||||
ms_message("Local stream description [%p] rejected by peer",local_offer);
|
||||
result->rtp_port=0;
|
||||
|
|
@ -438,10 +438,10 @@ static void initiate_outgoing(const SalStreamDescription *local_offer,
|
|||
}
|
||||
|
||||
|
||||
static void initiate_incoming(const SalStreamDescription *local_cap,
|
||||
static void initiate_incoming(MSFactory *factory, const SalStreamDescription *local_cap,
|
||||
const SalStreamDescription *remote_offer,
|
||||
SalStreamDescription *result, bool_t one_matching_codec){
|
||||
result->payloads=match_payloads(local_cap->payloads,remote_offer->payloads, FALSE, one_matching_codec);
|
||||
result->payloads=match_payloads(factory, local_cap->payloads,remote_offer->payloads, FALSE, one_matching_codec);
|
||||
result->proto=remote_offer->proto;
|
||||
result->type=local_cap->type;
|
||||
result->dir=compute_dir_incoming(local_cap->dir,remote_offer->dir);
|
||||
|
|
@ -513,7 +513,7 @@ static void initiate_incoming(const SalStreamDescription *local_cap,
|
|||
* Returns a media description to run the streams with, based on a local offer
|
||||
* and the returned response (remote).
|
||||
**/
|
||||
int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
||||
int offer_answer_initiate_outgoing(MSFactory *factory, const SalMediaDescription *local_offer,
|
||||
const SalMediaDescription *remote_answer,
|
||||
SalMediaDescription *result){
|
||||
int i;
|
||||
|
|
@ -524,7 +524,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
|||
ls=&local_offer->streams[i];
|
||||
rs=&remote_answer->streams[i];
|
||||
if (rs && ls->proto == rs->proto && rs->type == ls->type) {
|
||||
initiate_outgoing(ls,rs,&result->streams[i]);
|
||||
initiate_outgoing(factory, ls,rs,&result->streams[i]);
|
||||
memcpy(&result->streams[i].rtcp_xr, &ls->rtcp_xr, sizeof(result->streams[i].rtcp_xr));
|
||||
if ((ls->rtcp_xr.enabled == TRUE) && (rs->rtcp_xr.enabled == FALSE)) {
|
||||
result->streams[i].rtcp_xr.enabled = FALSE;
|
||||
|
|
@ -552,7 +552,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
|||
* and the received offer.
|
||||
* The returned media description is an answer and should be sent to the offerer.
|
||||
**/
|
||||
int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities,
|
||||
int offer_answer_initiate_incoming(MSFactory *factory, const SalMediaDescription *local_capabilities,
|
||||
const SalMediaDescription *remote_offer,
|
||||
SalMediaDescription *result, bool_t one_matching_codec){
|
||||
int i;
|
||||
|
|
@ -562,7 +562,7 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
|
|||
rs = &remote_offer->streams[i];
|
||||
ls = &local_capabilities->streams[i];
|
||||
if (ls && rs->type == ls->type && rs->proto == ls->proto){
|
||||
initiate_incoming(ls,rs,&result->streams[i],one_matching_codec);
|
||||
initiate_incoming(factory, ls,rs,&result->streams[i],one_matching_codec);
|
||||
// Handle global RTCP FB attributes
|
||||
result->streams[i].rtcp_fb.generic_nack_enabled = rs->rtcp_fb.generic_nack_enabled;
|
||||
result->streams[i].rtcp_fb.tmmbr_enabled = rs->rtcp_fb.tmmbr_enabled;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
* Returns a media description to run the streams with, based on a local offer
|
||||
* and the returned response (remote).
|
||||
**/
|
||||
int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
||||
int offer_answer_initiate_outgoing(MSFactory *factory, const SalMediaDescription *local_offer,
|
||||
const SalMediaDescription *remote_answer,
|
||||
SalMediaDescription *result);
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
|||
* and the received offer.
|
||||
* The returned media description is an answer and should be sent to the offerer.
|
||||
**/
|
||||
int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities,
|
||||
int offer_answer_initiate_incoming(MSFactory* factory, const SalMediaDescription *local_capabilities,
|
||||
const SalMediaDescription *remote_offer,
|
||||
SalMediaDescription *result, bool_t one_matching_codec);
|
||||
|
||||
|
|
|
|||
|
|
@ -1011,6 +1011,7 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, cons
|
|||
void _linphone_core_configure_resolver(void);
|
||||
|
||||
struct _EcCalibrator{
|
||||
MSFactory *factory;
|
||||
ms_thread_t thread;
|
||||
MSSndCard *play_card,*capt_card;
|
||||
MSFilter *sndread,*det,*rec;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void sal_address_set_password(SalAddress *addr, const char *passwd);
|
|||
const char *sal_address_get_password(const SalAddress *addr);
|
||||
void sal_address_set_header(SalAddress *addr, const char *header_name, const char *header_value);
|
||||
|
||||
LINPHONE_PUBLIC Sal * sal_init(void);
|
||||
LINPHONE_PUBLIC Sal * sal_init(MSFactory *factory);
|
||||
LINPHONE_PUBLIC void sal_uninit(Sal* sal);
|
||||
void sal_set_user_pointer(Sal *sal, void *user_data);
|
||||
void *sal_get_user_pointer(const Sal *sal);
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ LinphoneCoreManager *get_manager(LinphoneCore *lc){
|
|||
}
|
||||
|
||||
bool_t transport_supported(LinphoneTransportType transport) {
|
||||
Sal *sal = sal_init();
|
||||
Sal *sal = sal_init(NULL);
|
||||
bool_t supported = sal_transport_available(sal,(SalTransport)transport);
|
||||
if (!supported) ms_message("TLS transport not supported, falling back to TCP if possible otherwise skipping test.");
|
||||
sal_uninit(sal);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue