void linphone_conference_show_member_at_index(LinphoneConference *conf,int index){ int i; LinphoneCore *lc = conf->core; int nb_max = conf_stream_video_get_max_input(conf->conf_stream); char *msg=NULL; if(index >= 0){ for(i=0;i<nb_max;i++){ if(i==index) conf_stream_video_unmute_at_index(conf->conf_stream,i); else conf_stream_video_mute_at_index(conf->conf_stream,i); } msg = ms_strdup_printf("Show video index %d",index+1); ms_message(msg); if(lc && lc->vtable.display_status) lc->vtable.display_status(lc,msg); }else{ for(i=0;i<nb_max;i++) conf_stream_video_unmute_at_index(conf->conf_stream,i); msg = ms_strdup_printf("Show all video party"); ms_message(msg); if(lc && lc->vtable.display_status) lc->vtable.display_status(lc,msg); } linphone_conference_send_vfu(conf); if(msg) ms_free(msg); }
static MSSndCard * alsa_card_new(int id) { MSSndCard * obj; char *name=NULL; AlsaData *ad; int err; if (id!=-1){ err=snd_card_get_name(id,&name); if (err<0) { return NULL; } } obj=ms_snd_card_new(&alsa_card_desc); ad=(AlsaData*)obj->data; if (id==-1) { /* the default pcm device */ obj->name=ms_strdup("default device"); ad->pcmdev=ms_strdup("default"); ad->mixdev=ms_strdup("default"); }else{ /* remove trailing spaces from card name */ char *pos1, *pos2; pos1=ms_strdup(name); pos2=pos1+strlen(pos1)-1; for (; pos2>pos1 && *pos2==' '; pos2--) *pos2='\0'; obj->name=pos1; ad->pcmdev=ms_strdup_printf("default:%i",id); ad->mixdev=ms_strdup_printf("default:%i",id); } free(name); /*ms_message("alsa device %s found",obj->name);*/ return obj; }
static void webrtc_aec_init(MSFilter *f) { WebRTCAECState *s = (WebRTCAECState *) ms_new(WebRTCAECState, 1); s->samplerate = 8000; ms_bufferizer_init(&s->delayed_ref); ms_bufferizer_init(&s->echo); ms_bufferizer_init(&s->ref); s->delay_ms = 0; s->aecmInst = NULL; s->framesize = framesize; s->state_str = NULL; s->using_zeroes = FALSE; s->echostarted = FALSE; s->bypass_mode = FALSE; #ifdef EC_DUMP { char *fname = ms_strdup_printf("%s/mswebrtcaec-%p-echo.raw", EC_DUMP_PREFIX, f); s->echofile = fopen(fname, "w"); ms_free(fname); fname = ms_strdup_printf("%s/mswebrtcaec-%p-ref.raw", EC_DUMP_PREFIX, f); s->reffile = fopen(fname, "w"); ms_free(fname); fname = ms_strdup_printf("%s/mswebrtcaec-%p-clean.raw", EC_DUMP_PREFIX, f); s->cleanfile = fopen(fname, "w"); ms_free(fname); } #endif f->data = s; }
const char *ms_snd_card_get_string_id(MSSndCard *obj){ #if 0 if (obj->id==NULL) obj->id=ms_strdup_printf("%s: %s",obj->desc->driver_type,obj->name); #endif // 0 if (obj->id==NULL) obj->id=ms_strdup_printf("%s",obj->name); return obj->id; }
static void speex_ec_init(MSFilter *f){ SpeexECState *s=(SpeexECState *)ms_new(SpeexECState,1); s->samplerate=8000; ms_bufferizer_init(&s->delayed_ref); ms_bufferizer_init(&s->echo); ms_bufferizer_init(&s->ref); s->delay_ms=0; s->tail_length_ms=250; s->ecstate=NULL; s->framesize_at_8000=framesize; s->den = NULL; s->state_str=NULL; s->using_zeroes=FALSE; s->echostarted=FALSE; s->bypass_mode=FALSE; #ifdef EC_DUMP { char *fname=ms_strdup_printf("%s/msspeexec-%p-echo.raw", EC_DUMP_PREFIX,f); s->echofile=fopen(fname,"w"); ms_free(fname); fname=ms_strdup_printf("%s/msspeexec-%p-ref.raw", EC_DUMP_PREFIX,f); s->reffile=fopen(fname,"w"); ms_free(fname); fname=ms_strdup_printf("%s/msspeexec-%p-clean.raw", EC_DUMP_PREFIX,f); s->cleanfile=fopen(fname,"w"); ms_free(fname); } #endif f->data=s; }
FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres) { #if HAVE_SIPP char *dest; char *command; FILE *file; if (linphone_address_get_port(dest_addres)>0) dest = ms_strdup_printf("%s:%i",linphone_address_get_domain(dest_addres),linphone_address_get_port(dest_addres)); else dest = ms_strdup_printf("%s",linphone_address_get_domain(dest_addres)); //until errors logs are handled correctly and stop breaks output, they will be DISABLED command = ms_strdup_printf(SIPP_COMMAND" -sf %s -s %s %s -trace_err -trace_msg -rtp_echo -m 1 -d 1000 -ap %s 2>/dev/null",senario ,dest_username ,dest ,(passwd?passwd:"none")); ms_message("Starting sipp command [%s]",command); file = popen(command, "r"); ms_free(command); ms_free(dest); return file; #else return NULL; #endif }
LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAuthInfo *info; LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); char *identity_str = _get_identity(creator); LinphoneAddress *identity = linphone_address_new(identity_str); char *route = NULL; char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } if (creator->route) { route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); } if (creator->domain) { domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); } linphone_proxy_config_set_identity_address(cfg, identity); linphone_proxy_config_set_server_addr(cfg, domain); linphone_proxy_config_set_route(cfg, route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); if (strcmp(creator->domain, "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { LinphoneAddress *addr = linphone_address_new(linphone_proxy_config_get_server_addr(cfg)); char *tmp; linphone_address_set_transport(addr, LinphoneTransportTls); tmp = linphone_address_as_string(addr); linphone_proxy_config_set_server_addr(cfg, tmp); linphone_proxy_config_set_route(cfg, tmp); ms_free(tmp); linphone_address_destroy(addr); } linphone_core_set_stun_server(creator->core, "stun.linphone.org"); linphone_core_set_firewall_policy(creator->core, LinphonePolicyUseIce); } info = linphone_auth_info_new(linphone_address_get_username(identity), // username NULL, //user id creator->password, // passwd creator->password ? NULL : creator->ha1, // ha1 !creator->password && creator->ha1 ? linphone_address_get_domain(identity) : NULL, // realm - assumed to be domain linphone_address_get_domain(identity) // domain ); linphone_core_add_auth_info(creator->core, info); linphone_address_destroy(identity); if (linphone_core_add_proxy_config(creator->core, cfg) != -1) { linphone_core_set_default_proxy(creator->core, cfg); return cfg; } linphone_core_remove_auth_info(creator->core, info); linphone_proxy_config_unref(cfg); return NULL; }
static MSSndCard * alsa_card_new(int id) { MSSndCard * obj; char *name=NULL; AlsaData *ad; int err; if (id!=-1){ err=snd_card_get_name(id,&name); if (err<0) { return NULL; } } obj=ms_snd_card_new(&alsa_card_desc); ad=(AlsaData*)obj->data; if (id==-1) { /* the default pcm device */ obj->name=ms_strdup("default device"); ad->pcmdev=ms_strdup("default"); ad->mixdev=ms_strdup("default"); }else{ /* remove trailing spaces from card name */ char *pos1, *pos2; pos1=ms_strdup(name); pos2=pos1+strlen(pos1)-1; for (; pos2>pos1 && *pos2==' '; pos2--) *pos2='\0'; obj->name=pos1; ad->pcmdev=ms_strdup_printf("default:%i",id); ad->mixdev=ms_strdup_printf("default:%i",id); { snd_mixer_t *mixer; mixer = alsa_mixer_open(ad->mixdev); if (mixer==NULL) { ms_free(ad->mixdev); ad->mixdev=ms_strdup_printf("hw:%i",id); } else { alsa_mixer_close(mixer); } } } /*check card capabilities: */ obj->capabilities=get_card_capabilities(ad->pcmdev); if (obj->capabilities==0){ ms_warning("Strange, sound card %s does not seems to be capable of anything, retrying with plughw...",obj->name); /*retry with plughw: this workarounds an alsa bug*/ ms_free(ad->pcmdev); ad->pcmdev=ms_strdup_printf("plughw:%i",id); obj->capabilities=get_card_capabilities(ad->pcmdev); if (obj->capabilities==0){ ms_warning("Strange, sound card %s seems totally unusable.",obj->name); } } free(name); /*ms_message("alsa device %s found",obj->name);*/ return obj; }
MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm){ LinphoneCore *lc=linphone_chat_room_get_core(cr); MSList *ret; char *buf,*buf2; char *peer; uint64_t begin,end; int buf_max_size = 512; if (lc->db==NULL) return NULL; peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr)); cr->messages_hist = NULL; /*since we want to append query parameters depending on arguments given, we use malloc instead of sqlite3_mprintf*/ buf=ms_malloc(buf_max_size); buf=sqlite3_snprintf(buf_max_size-1,buf,"SELECT * FROM history WHERE remoteContact = %Q ORDER BY id DESC",peer); if (startm<0) startm=0; if ((endm>0&&endm>=startm) || (startm == 0 && endm == 0) ){ buf2=ms_strdup_printf("%s LIMIT %i ",buf,endm+1-startm); ms_free(buf); buf = buf2; }else if(startm>0){ ms_message("%s(): end is lower than start (%d < %d). Assuming no end limit.",__FUNCTION__,endm,startm); buf2=ms_strdup_printf("%s LIMIT -1",buf); ms_free(buf); buf = buf2; } if (startm>0){ buf2=ms_strdup_printf("%s OFFSET %i ",buf,startm); ms_free(buf); buf = buf2; } begin=ortp_get_cur_time_ms(); linphone_sql_request_message(lc->db,buf,cr); end=ortp_get_cur_time_ms(); if (endm+1-startm > 1) { //display message only if at least 2 messages are loaded ms_message("%s(): completed in %i ms",__FUNCTION__, (int)(end-begin)); } ms_free(buf); ret=cr->messages_hist; cr->messages_hist=NULL; ms_free(peer); return ret; }
const char *ms_fmt_descriptor_to_string(const MSFmtDescriptor *obj){ MSFmtDescriptor *mutable_fmt=(MSFmtDescriptor*)obj; if (!obj) return "null"; if (obj->text==NULL){ if (obj->type==MSAudio){ mutable_fmt->text=ms_strdup_printf("type=audio;encoding=%s;rate=%i;channels=%i;fmtp='%s'", obj->encoding,obj->rate,obj->nchannels,obj->fmtp ? obj->fmtp : ""); }else{ mutable_fmt->text=ms_strdup_printf("type=video;encoding=%s;vsize=%ix%i;fps=%f;fmtp='%s'", obj->encoding,obj->vsize.width,obj->vsize.height,obj->fps,obj->fmtp ? obj->fmtp : ""); } } return obj->text; }
static void refer_received(Sal *sal, SalOp *op, const char *referto){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); if (call){ if (call->refer_to!=NULL){ ms_free(call->refer_to); } call->refer_to=ms_strdup(referto); call->refer_pending=TRUE; linphone_call_set_state(call,LinphoneCallRefered,"Refered"); if (lc->vtable.display_status){ char *msg=ms_strdup_printf(_("We are transferred to %s"),referto); lc->vtable.display_status(lc,msg); ms_free(msg); } if (call->state!=LinphoneCallPaused){ ms_message("Automatically pausing current call to accept transfer."); linphone_core_pause_call(lc,call); } linphone_core_start_refered_call(lc,call); sal_call_accept_refer(op); }else if (lc->vtable.refer_received){ lc->vtable.refer_received(lc,referto); sal_call_accept_refer(op); } }
static void playing_test(void) { char *filename = ms_strdup_printf("%s/sounds/hello_opus_h264.mkv", liblinphone_tester_file_prefix); const char *audio_mime = "opus"; const char *video_mime = "h264"; play_file(filename, !linphone_local_player_matroska_supported(), audio_mime, video_mime); ms_free(filename); }
char * linphone_call_log_to_str(LinphoneCallLog *cl){ char *status; char *tmp; char *from=linphone_address_as_string (cl->from); char *to=linphone_address_as_string (cl->to); switch(cl->status){ case LinphoneCallAborted: status=_("aborted"); break; case LinphoneCallSuccess: status=_("completed"); break; case LinphoneCallMissed: status=_("missed"); break; default: status=_("unknown"); } tmp=ms_strdup_printf(_("%s at %s\nFrom: %s\nTo: %s\nStatus: %s\nDuration: %i mn %i sec\n"), (cl->dir==LinphoneCallIncoming) ? _("Incoming call") : _("Outgoing call"), cl->start_date, from, to, status, cl->duration/60, cl->duration%60); ms_free(from); ms_free(to); return tmp; }
static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){ SipSetupContext *ssc; SipSetup *ss=sip_setup_lookup(cfg->type); LinphoneCore *lc=linphone_proxy_config_get_core(cfg); unsigned int caps; if (!ss) return ; ssc=sip_setup_context_new(ss,cfg); cfg->ssctx=ssc; if (cfg->reg_identity==NULL){ ms_error("Invalid identity for this proxy configuration."); return; } caps=sip_setup_context_get_capabilities(ssc); if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){ if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL)!=0){ if (lc->vtable.display_warning){ char *tmp=ms_strdup_printf(_("Could not login as %s"),cfg->reg_identity); lc->vtable.display_warning(lc,tmp); ms_free(tmp); } return; } } if (caps & SIP_SETUP_CAP_PROXY_PROVIDER){ char proxy[256]; if (sip_setup_context_get_proxy(ssc,NULL,proxy,sizeof(proxy))==0){ linphone_proxy_config_set_server_addr(cfg,proxy); }else{ ms_error("Could not retrieve proxy uri !"); } } }
LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity; if (!creator->username || !creator->domain) { if (creator->callbacks->create_account != NULL) { creator->callbacks->create_account(creator, LinphoneAccountCreatorFailed); } return LinphoneAccountCreatorFailed; } identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); request = linphone_xml_rpc_request_new_with_args("create_account", LinphoneXmlRpcArgInt, LinphoneXmlRpcArgString, identity, LinphoneXmlRpcArgString, creator->password, LinphoneXmlRpcArgString, creator->email, LinphoneXmlRpcArgInt, (creator->subscribe_to_newsletter == TRUE) ? 1 : 0, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _create_account_cb); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOk; }
static PayloadType * red_match(MSOfferAnswerContext *ctx, const MSList *local_payloads, const PayloadType *refpt, const MSList *remote_payloads, bool_t reading_response) { const MSList *elem_local, *elem_remote; PayloadType *red = NULL; for (elem_local = local_payloads; elem_local != NULL; elem_local = elem_local->next) { PayloadType *pt = (PayloadType*)elem_local->data; if (strcasecmp(pt->mime_type, payload_type_t140_red.mime_type) == 0) { red = payload_type_clone(pt); for (elem_remote = remote_payloads; elem_remote != NULL; elem_remote = elem_remote->next) { PayloadType *pt2 = (PayloadType*)elem_remote->data; if (strcasecmp(pt2->mime_type, payload_type_t140.mime_type) == 0) { int t140_payload_number = payload_type_get_number(pt2); char *red_fmtp = ms_strdup_printf("%i/%i/%i", t140_payload_number, t140_payload_number, t140_payload_number); /*modify the local payload and the return value*/ payload_type_set_recv_fmtp(pt, red_fmtp); payload_type_set_recv_fmtp(red, red_fmtp); ms_free(red_fmtp); break; } } break; } } return red; }
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result){ LinphoneAddress *fr=NULL; *result=NULL; fr=linphone_address_new(uri); if (fr==NULL){ char *tmp=NULL; if (strchr(uri,'@')!=NULL){ LinphoneAddress *u; /*try adding sip:*/ tmp=ms_strdup_printf("sip:%s",uri); u=linphone_address_new(tmp); if (u!=NULL){ *result=tmp; } }else if (lc->default_proxy!=NULL){ /*try adding domain part from default current proxy*/ LinphoneAddress * id=linphone_address_new(linphone_core_get_identity(lc)); if ((id!=NULL) && (uri[0] != '\0')){ linphone_address_set_display_name(id,NULL); linphone_address_set_username(id,uri); *result=linphone_address_as_string(id); linphone_address_unref(id); } } if (*result){ /*looks good */ ms_message("%s interpreted as %s",uri,*result); }else{ ms_warning("Fail to interpret friend uri %s",uri); } }else { *result=linphone_address_as_string(fr); linphone_address_unref(fr); } }
/* * Use globals: * * - char *histfile_name (also sets this) * - char *last_in_history (allocates it) */ static int linphonec_initialize_readline() { /*rl_bind_key('\t', rl_insert);*/ /* Allow conditional parsing of ~/.inputrc */ rl_readline_name = "linphonec"; /* Call idle_call() every second */ rl_set_keyboard_input_timeout(LPC_READLINE_TIMEOUT); rl_event_hook=linphonec_idle_call; /* Set history file and read it */ histfile_name = ms_strdup_printf ("%s/.linphonec_history", getenv("HOME")); read_history(histfile_name); /* Initialized last_in_history cache*/ last_in_history[0] = '\0'; /* Register a completion function */ rl_attempted_completion_function = linephonec_readline_completion; /* printf("Readline initialized.\n"); */ setlinebuf(stdout); return 0; }
char* sal_op_get_dialog_id(const SalOp *op) { if (op->dialog != NULL) { return ms_strdup_printf("%s;to-tag=%s;from-tag=%s", ((SalOpBase*)op)->call_id, belle_sip_dialog_get_remote_tag(op->dialog), belle_sip_dialog_get_local_tag(op->dialog)); } return NULL; }
int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename, char *data, size_t max_length) { char *dir; char *filepath; FILE *file; char* realfilepath; if (lpconfig->filename == NULL) return -1; dir = _lp_config_dirname(lpconfig->filename); filepath = ms_strdup_printf("%s/%s", dir, filename); realfilepath = lp_realpath(filepath, NULL); file = fopen(realfilepath, "r"); if(file != NULL) { if(fread(data, 1, max_length, file)<=0) { ms_error("%s could not be loaded. %s", realfilepath, strerror(errno)); goto err; } fclose(file); } else { ms_error("Could not open %s for read. %s", realfilepath, strerror(errno)); goto err; } ms_free(dir); ms_free(filepath); ms_free(realfilepath); return 0; err: ms_free(dir); ms_free(filepath); ms_free(realfilepath); return -1; }
/** * Sets the proxy address * * Examples of valid sip proxy address are: * - IP address: sip:87.98.157.38 * - IP address with port: sip:87.98.157.38:5062 * - hostnames : sip:sip.example.net **/ int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr){ LinphoneAddress *addr=NULL; char *modified=NULL; if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy); obj->reg_proxy=NULL; if (server_addr!=NULL && strlen(server_addr)>0){ if (strstr(server_addr,"sip:")==NULL){ modified=ms_strdup_printf("sip:%s",server_addr); addr=linphone_address_new(modified); ms_free(modified); } if (addr==NULL) addr=linphone_address_new(server_addr); if (addr){ obj->reg_proxy=linphone_address_as_string_uri_only(addr); linphone_address_destroy(addr); }else{ ms_warning("Could not parse %s",server_addr); return -1; } } return 0; }
int linphone_account_creator_test_existence(LinphoneAccountCreator *obj){ SipSetupContext *ssctx=obj->ssctx; char *uri=ms_strdup_printf("%s@%s",obj->username,obj->domain); int err=sip_setup_context_account_exists(ssctx,uri); ms_free(uri); return err; }
/*since printf family functions are LOCALE dependent, float separator may differ depending on the user's locale (LC_NUMERIC environment var).*/ static char * float_to_one_decimal_string(float f) { float rounded_f = floorf(f * 10 + .5f) / 10; int floor_part = (int) rounded_f; int one_decimal_part = (int)floorf(10 * (rounded_f - floor_part) + .5f); return ms_strdup_printf("%d.%d", floor_part, one_decimal_part); }
static void register_success(SalOp *op, bool_t registered){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op); char *msg; cfg->registered=registered; linphone_proxy_config_set_error(cfg,LinphoneReasonNone); linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared , registered ? "Registration sucessful" : "Unregistration done"); if (lc->vtable.display_status){ if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),sal_op_get_proxy(op)); else msg=ms_strdup_printf(_("Unregistration on %s done."),sal_op_get_proxy(op)); lc->vtable.display_status(lc,msg); ms_free(msg); } }
void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { stats* counters = get_stats(lc); char** dst = &counters->dtmf_list_received; *dst = *dst ? ms_strcat_printf(*dst, "%c", dtmf) : ms_strdup_printf("%c", dtmf); counters->dtmf_count++; }
static void simple_analyzer_suggest_action(MSQosAnalyzer *objbase, MSRateControlAction *action){ MSSimpleQosAnalyzer *obj=(MSSimpleQosAnalyzer*)objbase; rtpstats_t *cur=&obj->stats[obj->curindex % STATS_HISTORY]; /*big losses and big jitter */ if (cur->lost_percentage>=unacceptable_loss_rate && cur->int_jitter>=big_jitter){ action->type=MSRateControlActionDecreaseBitrate; action->value=(int)MIN(cur->lost_percentage,50); ms_message("MSSimpleQosAnalyzer: loss rate unacceptable and big jitter"); }else if (simple_rt_prop_increased(obj)){ action->type=MSRateControlActionDecreaseBitrate; action->value=20; ms_message("MSSimpleQosAnalyzer: rt_prop doubled."); }else if (cur->lost_percentage>=unacceptable_loss_rate){ /*big loss rate but no jitter, and no big rtp_prop: pure lossy network*/ action->type=MSRateControlActionDecreaseBitrate; action->value=(int)MIN(cur->lost_percentage,50); ms_message("MSSimpleQosAnalyzer: loss rate unacceptable."); }else{ action->type=MSRateControlActionDoNothing; ms_message("MSSimpleQosAnalyzer: everything is fine."); } if (objbase->on_action_suggested!=NULL){ int i; char *data[4]; int datac = sizeof(data) / sizeof(data[0]); data[0]=ms_strdup("%loss rt_prop_increased int_jitter_ms rt_prop_ms"); data[1]=ms_strdup_printf("%d %d %d %d" , (int)cur->lost_percentage , (simple_rt_prop_increased(obj)==TRUE) , (int)cur->int_jitter , (int)(1000*cur->rt_prop)); data[2]=ms_strdup("action_type action_value"); data[3]=ms_strdup_printf("%s %d" , ms_rate_control_action_type_name(action->type) , action->value); objbase->on_action_suggested(objbase->on_action_suggested_user_pointer, datac, (const char**)data); for (i=0;i<datac;++i){ ms_free(data[i]); } } }
void sipomatic_init(Sipomatic *obj, char *url, bool_t ipv6) { osip_uri_t *uri=NULL; int port=5064; obj->ipv6=ipv6; if (url==NULL){ url=getenv("SIPOMATIC_URL"); if (url==NULL){ if (ipv6) url="sip:robot@[::1]:5064"; else url="sip:[email protected]:5064"; } } if (url!=NULL) { osip_uri_init(&uri); if (osip_uri_parse(uri,url)==0){ if (uri->port!=NULL) port=atoi(uri->port); }else{ ms_warning("Invalid identity uri:%s",url); } } ms_message("Starting using url %s",url); ms_mutex_init(&obj->lock,NULL); obj->calls=NULL; obj->acceptance_time=5; obj->max_call_time=300; obj->file_path8000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE8000HZ); obj->file_path16000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE16000HZ); osip_trace_initialize(OSIP_INFO1,stdout); osip_trace_initialize(OSIP_INFO2,stdout); osip_trace_initialize(OSIP_WARNING,stdout); osip_trace_initialize(OSIP_ERROR,stdout); osip_trace_initialize(OSIP_BUG,stdout); osip_trace_initialize(OSIP_FATAL,stdout); osip_trace_enable_level(OSIP_INFO1); osip_trace_enable_level(OSIP_INFO2); osip_trace_enable_level(OSIP_WARNING); osip_trace_enable_level(OSIP_ERROR); osip_trace_enable_level(OSIP_BUG); osip_trace_enable_level(OSIP_FATAL); eXosip_init(); eXosip_set_user_agent("sipomatic-" LINPHONE_VERSION "/eXosip"); eXosip_listen_addr(IPPROTO_UDP,NULL,port,ipv6 ? AF_INET6 : AF_INET,0); }
void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtmf_seq) { char* expected = NULL; int dtmf_count_prev; marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new( "pauline_rc"); linphone_core_set_use_rfc2833_for_dtmf(marie->lc, use_rfc2833); linphone_core_set_use_info_for_dtmf(marie->lc, use_sipinfo); linphone_core_set_use_rfc2833_for_dtmf(pauline->lc, use_rfc2833); linphone_core_set_use_info_for_dtmf(pauline->lc, use_sipinfo); CU_ASSERT_TRUE(call(pauline,marie)); marie_call = linphone_core_get_current_call(marie->lc); if (dtmf != '\0') { dtmf_count_prev = pauline->stat.dtmf_count; linphone_call_send_dtmf(marie_call, dtmf); /*wait for the DTMF to be received from pauline*/ CU_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev+1, 10000)); expected = ms_strdup_printf("%c", dtmf); } if (dtmf_seq != NULL) { int dtmf_delay_ms = lp_config_get_int(marie_call->core->config,"net","dtmf_delay_ms",200); dtmf_count_prev = pauline->stat.dtmf_count; linphone_call_send_dtmfs(marie_call, dtmf_seq); /*wait for the DTMF sequence to be received from pauline*/ CU_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev + strlen(dtmf_seq), 10000 + dtmf_delay_ms * strlen(dtmf_seq))); expected = (dtmf!='\0')?ms_strdup_printf("%c%s",dtmf,dtmf_seq):ms_strdup(dtmf_seq); } if (expected != NULL) { CU_ASSERT_PTR_NOT_NULL(pauline->stat.dtmf_list_received); if (pauline->stat.dtmf_list_received) { CU_ASSERT_STRING_EQUAL(pauline->stat.dtmf_list_received, expected); } ms_free(expected); } else { CU_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received); } }
static bool_t open_file(JpegWriter *obj, const char *filename) { obj->filename=ms_strdup(filename); obj->tmpFilename=ms_strdup_printf("%s.part",filename); obj->file = fopen(obj->tmpFilename, "wb"); if(!obj->file) { ms_error("Could not open %s for write", obj->tmpFilename); close_file(obj,FALSE); } return TRUE; }
extern "C" jstring Java_com_acsoftware_android_domophone_LibLP_nPayloadTypeToString(JNIEnv* env, jobject thiz, jlong ptr) { PayloadType* pt = (PayloadType*)ptr; char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]" ,payload_type_get_mime(pt) ,payload_type_get_rate(pt) ,payload_type_get_bitrate(pt)); jstring jvalue =env->NewStringUTF(value); ms_free(value); return jvalue; }