Commit 389054bc authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fix to be C89 compliant

parent 1687ceb4
......@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sal.h"
#include "sal/sal.h"
#include "linphonecore.h"
#include "private.h"
......@@ -179,9 +179,9 @@ static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, c
#endif
static bool_t already_a_call_with_remote_address(const LinphoneCore *lc, const LinphoneAddress *remote) {
MSList *elem;
ms_warning(" searching for already_a_call_with_remote_address.");
MSList *elem;
for(elem=lc->calls;elem!=NULL;elem=elem->next){
const LinphoneCall *call=(LinphoneCall*)elem->data;
const LinphoneAddress *cRemote=linphone_call_get_remote_address(call);
......
......@@ -215,6 +215,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){
static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t active){
int err=0;
char *str;
if (!call->current_params.in_conference){
if (call->params.in_conference){
......@@ -227,7 +228,7 @@ static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t a
}
call->params.in_conference=FALSE;
char *str=linphone_call_get_remote_address_as_string(call);
str=linphone_call_get_remote_address_as_string(call);
ms_message("%s will be removed from conference", str);
ms_free(str);
if (active){
......@@ -283,10 +284,11 @@ static int convert_conference_to_call(LinphoneCore *lc){
* @returns 0 if successful, -1 otherwise.
**/
int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
int err;
char * str=linphone_call_get_remote_address_as_string(call);
ms_message("Removing call %s from the conference", str);
ms_free(str);
int err=remove_from_conference(lc,call, FALSE);
err=remove_from_conference(lc,call, FALSE);
if (err){
ms_error("Error removing participant from conference.");
return err;
......@@ -335,13 +337,14 @@ int linphone_core_leave_conference(LinphoneCore *lc){
* @returns 0 if successful, -1 otherwise
**/
int linphone_core_enter_conference(LinphoneCore *lc){
LinphoneConference *conf;
if (linphone_core_sound_resources_locked(lc)) {
return -1;
}
if (lc->current_call != NULL) {
linphone_core_pause_call(lc, lc->current_call);
}
LinphoneConference *conf=&lc->conf_ctx;
conf=&lc->conf_ctx;
if (conf->local_participant==NULL) add_local_endpoint(conf,lc);
return 0;
}
......
......@@ -241,11 +241,13 @@ void ec_calibrator_destroy(EcCalibrator *ecc){
}
int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data){
unsigned int rate;
if (lc->ecc!=NULL){
ms_error("Echo calibration is still on going !");
return -1;
}
unsigned int rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
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,cb_data);
return 0;
}
......
......@@ -152,11 +152,13 @@ LinphoneFriend * linphone_friend_new(){
LinphoneFriend *linphone_friend_new_with_addr(const char *addr){
LinphoneAddress* linphone_address = linphone_address_new(addr);
LinphoneFriend *fr;
if (linphone_address == NULL) {
ms_error("Cannot create friend for address [%s]",addr?addr:"null");
return NULL;
}
LinphoneFriend *fr=linphone_friend_new();
fr=linphone_friend_new();
if (linphone_friend_set_addr(fr,linphone_address)<0){
linphone_friend_destroy(fr);
return NULL;
......@@ -437,6 +439,8 @@ LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, cons
const MSList *elem;
const char *username;
const char *domain;
const char *it_username;
const char *it_host;
LinphoneFriend *lf=NULL;
if (puri==NULL){
......@@ -450,8 +454,8 @@ LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, cons
}
for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){
lf=(LinphoneFriend*)elem->data;
const char *it_username=linphone_address_get_username(lf->uri);
const char *it_host=linphone_address_get_domain(lf->uri);;
it_username=linphone_address_get_username(lf->uri);
it_host=linphone_address_get_domain(lf->uri);;
if (strcasecmp(domain,it_host)==0 && username_match(username,it_username)){
break;
}
......
......@@ -120,9 +120,10 @@ static void linphone_call_videostream_encryption_changed(void *data, bool_t encr
static void linphone_call_audiostream_encryption_changed(void *data, bool_t encrypted) {
char status[255]={0};
LinphoneCall *call;
ms_message("Audio stream is %s ", encrypted ? "encrypted" : "not encrypted");
LinphoneCall *call = (LinphoneCall *)data;
call = (LinphoneCall *)data;
call->audiostream_encrypted=encrypted;
if (encrypted && call->core->vtable.display_status != NULL) {
......@@ -1333,6 +1334,13 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute
float ng_thres=lp_config_get_float(lc->config,"sound","ng_thres",0.05);
float ng_floorgain=lp_config_get_float(lc->config,"sound","ng_floorgain",0);
int dc_removal=lp_config_get_int(lc->config,"sound","dc_removal",0);
float speed;
float force;
int sustain;
float transmit_thres;
MSFilter *f=NULL;
float floorgain;
int spk_agc;
if (!muted)
linphone_core_set_mic_gain_db (lc, mic_gain);
......@@ -1346,12 +1354,11 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute
if (st->volsend){
ms_filter_call_method(st->volsend,MS_VOLUME_REMOVE_DC,&dc_removal);
float speed=lp_config_get_float(lc->config,"sound","el_speed",-1);
speed=lp_config_get_float(lc->config,"sound","el_speed",-1);
thres=lp_config_get_float(lc->config,"sound","el_thres",-1);
float force=lp_config_get_float(lc->config,"sound","el_force",-1);
int sustain=lp_config_get_int(lc->config,"sound","el_sustain",-1);
float transmit_thres=lp_config_get_float(lc->config,"sound","el_transmit_thres",-1);
MSFilter *f=NULL;
force=lp_config_get_float(lc->config,"sound","el_force",-1);
sustain=lp_config_get_int(lc->config,"sound","el_sustain",-1);
transmit_thres=lp_config_get_float(lc->config,"sound","el_transmit_thres",-1);
f=st->volsend;
if (speed==-1) speed=0.03;
if (force==-1) force=25;
......@@ -1369,8 +1376,8 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute
}
if (st->volrecv){
/* parameters for a limited noise-gate effect, using echo limiter threshold */
float floorgain = 1/pow(10,(mic_gain)/10);
int spk_agc=lp_config_get_int(lc->config,"sound","speaker_agc_enabled",0);
floorgain = 1/pow(10,(mic_gain)/10);
spk_agc=lp_config_get_int(lc->config,"sound","speaker_agc_enabled",0);
ms_filter_call_method(st->volrecv, MS_VOLUME_ENABLE_AGC, &spk_agc);
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_THRESHOLD,&ng_thres);
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_FLOORGAIN,&floorgain);
......@@ -1478,9 +1485,19 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
LinphoneCore *lc=call->core;
int used_pt=-1;
char rtcp_tool[128]={0};
const SalStreamDescription *stream;
MSSndCard *playcard;
MSSndCard *captcard;
bool_t use_ec;
bool_t mute;
const char *playfile;
const char *recfile;
const SalStreamDescription *local_st_desc;
int crypto_idx;
snprintf(rtcp_tool,sizeof(rtcp_tool)-1,"%s-%s",linphone_core_get_user_agent_name(),linphone_core_get_user_agent_version());
/* look for savp stream first */
const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc,
stream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpSavp,SalAudio);
/* no savp audio stream, use avp */
if (!stream)
......@@ -1488,13 +1505,12 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
SalProtoRtpAvp,SalAudio);
if (stream && stream->dir!=SalStreamInactive && stream->rtp_port!=0){
MSSndCard *playcard=lc->sound_conf.lsd_card ?
playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
const char *playfile=lc->play_file;
const char *recfile=lc->rec_file;
captcard=lc->sound_conf.capt_sndcard;
playfile=lc->play_file;
recfile=lc->rec_file;
call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt);
bool_t use_ec;
if (used_pt!=-1){
call->current_params.audio_codec = rtp_profile_get_payload(call->audio_profile, used_pt);
......@@ -1570,9 +1586,9 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
/* valid local tags are > 0 */
if (stream->proto == SalProtoRtpSavp) {
const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc,
local_st_desc=sal_media_description_find_stream(call->localdesc,
SalProtoRtpSavp,SalAudio);
int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag);
crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag);
if (crypto_idx >= 0) {
audio_stream_enable_srtp(
......@@ -1588,7 +1604,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
}else call->audiostream_encrypted=FALSE;
if (call->params.in_conference){
/*transform the graph to connect it to the conference filter */
bool_t mute=stream->dir==SalStreamRecvOnly;
mute=stream->dir==SalStreamRecvOnly;
linphone_call_add_to_conf(call, mute);
}
call->current_params.in_conference=call->params.in_conference;
......@@ -1696,13 +1712,15 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna
void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){
LinphoneCore *lc=call->core;
LinphoneAddress *me;
char *cname;
bool_t use_arc;
call->current_params.audio_codec = NULL;
call->current_params.video_codec = NULL;
LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc);
char *cname;
bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc);
me=linphone_core_get_primary_contact_parsed(lc);
use_arc=linphone_core_adaptive_rate_control_enabled(lc);
#ifdef VIDEO_ENABLED
const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalVideo);
......@@ -2370,10 +2388,11 @@ void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx,
VideoStream* vstream = call->videostream;
if (vstream && vstream->output) {
float zoom[3];
float halfsize;
if (zoom_factor < 1)
zoom_factor = 1;
float halfsize = 0.5 * 1.0 / zoom_factor;
halfsize = 0.5 * 1.0 / zoom_factor;
if ((*cx - halfsize) < 0)
*cx = 0 + halfsize;
......
......@@ -2167,7 +2167,7 @@ void linphone_core_iterate(LinphoneCore *lc){
LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url){
enum_lookup_res_t *enumres=NULL;
char *enum_domain=NULL;
LinphoneProxyConfig *proxy=lc->default_proxy;;
LinphoneProxyConfig *proxy=lc->default_proxy;
char *tmpurl;
LinphoneAddress *uri;
......@@ -5265,9 +5265,10 @@ static void linphone_core_uninit(LinphoneCore *lc)
}
static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){
ms_message("Network state is now [%s]",isReachable?"UP":"DOWN");
// second get the list of available proxies
const MSList *elem=linphone_core_get_proxy_config_list(lc);
ms_message("Network state is now [%s]",isReachable?"UP":"DOWN");
for(;elem!=NULL;elem=elem->next){
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
if (linphone_proxy_config_register_enabled(cfg) ) {
......@@ -5582,13 +5583,18 @@ const char *linphone_core_get_zrtp_secrets_file(LinphoneCore *lc){
}
const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri) {
MSList *calls;
const LinphoneCall *c;
const LinphoneAddress *address;
char *current_uri;
if (uri == NULL) return NULL;
MSList *calls=lc->calls;
calls=lc->calls;
while(calls) {
const LinphoneCall *c=(LinphoneCall*)calls->data;
c=(LinphoneCall*)calls->data;
calls=calls->next;
const LinphoneAddress *address = linphone_call_get_remote_address(c);
char *current_uri=linphone_address_as_string_uri_only(address);
address = linphone_call_get_remote_address(c);
current_uri=linphone_address_as_string_uri_only(address);
if (strcmp(uri,current_uri)==0) {
ms_free(current_uri);
return c;
......
......@@ -34,6 +34,9 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#if _MSC_VER
#include <io.h>
#endif
#endif /*_WIN32_WCE*/
......@@ -140,18 +143,20 @@ LpItem *lp_section_find_item(const LpSection *sec, const char *name){
void lp_config_parse(LpConfig *lpconfig, FILE *file){
char tmp[MAX_LEN]= {'\0'};
LpSection *cur=NULL;
char *pos1,*pos2;
int nbs;
char secname[MAX_LEN];
char key[MAX_LEN];
LpItem *item;
if (file==NULL) return;
while(fgets(tmp,MAX_LEN,file)!=NULL){
tmp[sizeof(tmp) -1] = '\0';
char *pos1,*pos2;
pos1=strchr(tmp,'[');
if (pos1!=NULL && is_first_char(tmp,pos1) ){
pos2=strchr(pos1,']');
if (pos2!=NULL){
int nbs;
char secname[MAX_LEN];
secname[0]='\0';
/* found section */
*pos2='\0';
......@@ -171,7 +176,6 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){
}else {
pos1=strchr(tmp,'=');
if (pos1!=NULL){
char key[MAX_LEN];
key[0]='\0';
*pos1='\0';
......@@ -191,7 +195,7 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){
if (pos2-pos1>=0){
/* found a pair key,value */
if (cur!=NULL){
LpItem *item=lp_section_find_item(cur,key);
item=lp_section_find_item(cur,key);
if (item==NULL){
lp_section_add_item(cur,lp_item_new(key,pos1));
}else{
......@@ -211,17 +215,20 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){
LpConfig * lp_config_new(const char *filename){
LpConfig *lpconfig=lp_new0(LpConfig,1);
struct stat fileStat;
if (filename!=NULL){
lpconfig->filename=ortp_strdup(filename);
lpconfig->file=fopen(filename,"rw");
if (lpconfig->file!=NULL){
struct stat fileStat;
lp_config_parse(lpconfig,lpconfig->file);
fclose(lpconfig->file);
#if !defined(_WIN32_WCE)
#ifndef S_ISREG
#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG)
#endif
if ((stat(filename,&fileStat) == 0) && (S_ISREG(fileStat.st_mode))) {
/* make existing configuration files non-group/world-accessible */
if (chmod(filename, S_IRUSR | S_IWUSR) == -1) {
if (_chmod(filename, _S_IREAD | _S_IWRITE) == -1) {
ms_warning("unable to correct permissions on "
"configuration file: %s", strerror(errno));
}
......
......@@ -32,7 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#if _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif
#include <fcntl.h>
#endif /*_WIN32_WCE*/
......@@ -585,9 +589,10 @@ int linphone_core_get_edge_ptime(LinphoneCore *lc){
}
void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params){
int threshold;
if (ping_time_ms>0 && lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){
ms_message("Stun server ping time is %i ms",ping_time_ms);
int threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500);
threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500);
if (ping_time_ms>threshold){
/* we might be in a 2G network*/
......
......@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sal.h"
#include "sal/sal.h"
#include "offeranswer.h"
#include "private.h"
......
......@@ -31,7 +31,7 @@ extern "C" {
#include "linphonefriend.h"
#include "linphone_tunnel.h"
#include "linphonecore_utils.h"
#include "sal.h"
#include "sal/sal.h"
#include "sipsetup.h"
#ifdef HAVE_CONFIG_H
......
......@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
protocols and implementations under linphone, for example SIP, JINGLE...
**/
#include "sal.h"
#include "sal/sal.h"
const char* sal_transport_to_string(SalTransport transport) {
switch (transport) {
case SalTransportUDP:return "udp";
......
......@@ -113,10 +113,9 @@ SipSetup linphone_sip_login={
NULL,
NULL,
NULL,
sip_login_do_logout,
NULL,
NULL,
NULL,
sip_login_do_logout
NULL
};
......
......@@ -21,6 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
#include "linphonecore_utils.h"
#if _MSC_VER
#include <io.h>
#endif
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data){
ms_message("echo calibration finished %s.",status==LinphoneEcCalibratorDone ? "successfully" : "with faillure");
......@@ -30,6 +33,9 @@ static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus st
static char config_file[1024];
void parse_args(int argc, char *argv[]){
#ifndef F_OK
#define F_OK 4
#endif
if (argc != 3 || strncmp("-c",argv[1], 2) || access(argv[2],F_OK)!=0) {
printf("Usage: test_ecc [-c config_file] where config_file will be written with the detected value\n");
exit(-1);
......@@ -38,10 +44,11 @@ void parse_args(int argc, char *argv[]){
}
int main(int argc, char *argv[]){
if (argc>1) parse_args(argc,argv);
int count=0;
LinphoneCoreVTable vtable={0};
LinphoneCore *lc=linphone_core_new(&vtable,config_file,NULL,NULL);
LinphoneCore *lc;
if (argc>1) parse_args(argc,argv);
lc=linphone_core_new(&vtable,config_file,NULL,NULL);
linphone_core_enable_logs(NULL);
......
......@@ -488,7 +488,7 @@ int linphone_upnp_context_send_add_port_binding(UpnpContext *lupnp, UpnpPortBind
mapping.remote_port = port->external_port;
mapping.remote_host = "";
snprintf(description, 128, "%s %s at %s:%d",
PACKAGE_NAME,
LINPHONE_PACKAGE_NAME,
(port->protocol == UPNP_IGD_IP_PROTOCOL_TCP)? "TCP": "UDP",
port->local_addr, port->local_port);
mapping.description = description;
......
......@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/upnp_igd.h"
#include "linphonecore.h"
#include "sal.h"
#include "sal/sal.h"
typedef struct _UpnpSession UpnpSession;
typedef struct _UpnpContext UpnpContext;
......
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