Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
ceb8533c
Commit
ceb8533c
authored
Apr 22, 2014
by
Gautier Pelloux-Prayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'quality_reporting'
Conflicts: coreapi/linphonecall.c mediastreamer2 tester/call_tester.c
parents
b74aa1f5
0470d052
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1069 additions
and
197 deletions
+1069
-197
build/android/Android.mk
build/android/Android.mk
+2
-1
build/vsx/LibLinphone/LibLinphone.vcxproj
build/vsx/LibLinphone/LibLinphone.vcxproj
+2
-1
coreapi/CMakeLists.txt
coreapi/CMakeLists.txt
+1
-0
coreapi/Makefile.am
coreapi/Makefile.am
+1
-0
coreapi/linphonecall.c
coreapi/linphonecall.c
+30
-13
coreapi/linphonecore.c
coreapi/linphonecore.c
+90
-83
coreapi/linphonecore.h
coreapi/linphonecore.h
+11
-0
coreapi/presence.c
coreapi/presence.c
+4
-4
coreapi/private.h
coreapi/private.h
+15
-1
coreapi/proxy.c
coreapi/proxy.c
+74
-31
coreapi/quality_reporting.c
coreapi/quality_reporting.c
+524
-0
coreapi/quality_reporting.h
coreapi/quality_reporting.h
+149
-0
coreapi/sal.c
coreapi/sal.c
+16
-8
include/sal/sal.h
include/sal/sal.h
+3
-2
tester/call_tester.c
tester/call_tester.c
+145
-53
tester/rcfiles/marie_rc
tester/rcfiles/marie_rc
+2
-0
No files found.
build/android/Android.mk
View file @
ceb8533c
...
...
@@ -64,7 +64,8 @@ LOCAL_SRC_FILES := \
xml.c
\
xml2lpc.c
\
lpc2xml.c
\
remote_provisioning.c
remote_provisioning.c
\
quality_reporting.c
ifndef
LINPHONE_VERSION
LINPHONE_VERSION
=
"Devel"
...
...
build/vsx/LibLinphone/LibLinphone.vcxproj
View file @
ceb8533c
...
...
@@ -203,6 +203,7 @@
<ClCompile
Include=
"..\..\..\coreapi\offeranswer.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\presence.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\proxy.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\quality_reporting.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\sal.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\siplogin.c"
/>
<ClCompile
Include=
"..\..\..\coreapi\sipsetup.c"
/>
...
...
@@ -275,4 +276,4 @@
<Import
Project=
"$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets"
Condition=
"'$(Platform)'=='ARM'"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
coreapi/CMakeLists.txt
View file @
ceb8533c
...
...
@@ -74,6 +74,7 @@ set(SOURCE_FILES
offeranswer.c
presence.c
proxy.c
quality_reporting.c
remote_provisioning.c
sal.c
siplogin.c
...
...
coreapi/Makefile.am
View file @
ceb8533c
...
...
@@ -56,6 +56,7 @@ liblinphone_la_SOURCES=\
xml2lpc.c
\
lpc2xml.c
\
remote_provisioning.c
\
quality_reporting.c
\
$(GITVERSION_FILE)
if
BUILD_UPNP
...
...
coreapi/linphonecall.c
View file @
ceb8533c
...
...
@@ -393,7 +393,7 @@ static int find_port_offset(LinphoneCore *lc, int stream_index, int base_port){
int
tried_port
;
int
existing_port
;
bool_t
already_used
=
FALSE
;
for
(
offset
=
0
;
offset
<
100
;
offset
+=
2
){
tried_port
=
base_port
+
offset
;
already_used
=
FALSE
;
...
...
@@ -480,10 +480,10 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
linphone_core_get_audio_port_range
(
call
->
core
,
&
min_port
,
&
max_port
);
port_config_set
(
call
,
0
,
min_port
,
max_port
);
linphone_core_get_video_port_range
(
call
->
core
,
&
min_port
,
&
max_port
);
port_config_set
(
call
,
1
,
min_port
,
max_port
);
linphone_call_init_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
],
LINPHONE_CALL_STATS_AUDIO
);
linphone_call_init_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
],
LINPHONE_CALL_STATS_VIDEO
);
}
...
...
@@ -768,7 +768,6 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
return
;
}
}
ms_message
(
"Call %p: moving from state %s to %s"
,
call
,
linphone_call_state_to_string
(
call
->
state
),
linphone_call_state_to_string
(
cstate
));
...
...
@@ -777,6 +776,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
Indeed it does not change the state of the call (still paused or running)*/
call
->
state
=
cstate
;
}
if
(
cstate
==
LinphoneCallEnd
||
cstate
==
LinphoneCallError
){
switch
(
call
->
non_op_error
.
reason
){
case
SalReasonDeclined
:
...
...
@@ -795,9 +795,17 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
call
->
media_start_time
=
time
(
NULL
);
}
if
(
cstate
==
LinphoneCallStreamsRunning
)
{
linphone_reporting_update_ip
(
call
);
}
if
(
lc
->
vtable
.
call_state_changed
)
lc
->
vtable
.
call_state_changed
(
lc
,
call
,
cstate
,
message
);
if
(
cstate
==
LinphoneCallReleased
){
if
(
call
->
log
->
status
==
LinphoneCallSuccess
)
linphone_reporting_publish
(
call
);
if
(
call
->
op
!=
NULL
)
{
/*transfer the last error so that it can be obtained even in Released state*/
if
(
call
->
non_op_error
.
reason
==
SalReasonNone
){
...
...
@@ -1301,7 +1309,7 @@ const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp){
/**
* Set the session name of the media session (ie in SDP). Subject from the SIP message (which is different) can be set using linphone_call_params_set_custom_header().
* @param cp the call parameters.
* @param name the session name
* @param name the session name
**/
void
linphone_call_params_set_session_name
(
LinphoneCallParams
*
cp
,
const
char
*
name
){
if
(
cp
->
session_name
){
...
...
@@ -1451,17 +1459,17 @@ static void _linphone_call_prepare_ice_for_stream(LinphoneCall *call, int stream
int
linphone_call_prepare_ice
(
LinphoneCall
*
call
,
bool_t
incoming_offer
){
SalMediaDescription
*
remote
;
bool_t
has_video
=
FALSE
;
if
((
linphone_core_get_firewall_policy
(
call
->
core
)
==
LinphonePolicyUseIce
)
&&
(
call
->
ice_session
!=
NULL
)){
if
(
incoming_offer
){
remote
=
sal_call_get_remote_media_description
(
call
->
op
);
has_video
=
linphone_core_media_description_contains_video_stream
(
remote
);
}
else
has_video
=
call
->
params
.
has_video
;
_linphone_call_prepare_ice_for_stream
(
call
,
0
,
TRUE
);
if
(
has_video
)
_linphone_call_prepare_ice_for_stream
(
call
,
1
,
TRUE
);
/*start ICE gathering*/
if
(
incoming_offer
)
if
(
incoming_offer
)
linphone_core_update_ice_from_remote_media_description
(
call
,
remote
);
/*this may delete the ice session*/
if
(
call
->
ice_session
&&
!
ice_session_candidates_gathered
(
call
->
ice_session
)){
if
(
call
->
audiostream
->
ms
.
state
==
MSStreamInitialized
)
...
...
@@ -1536,7 +1544,7 @@ void linphone_call_init_audio_stream(LinphoneCall *call){
call
->
audiostream_app_evq
=
ortp_ev_queue_new
();
rtp_session_register_event_queue
(
audiostream
->
ms
.
sessions
.
rtp_session
,
call
->
audiostream_app_evq
);
_linphone_call_prepare_ice_for_stream
(
call
,
0
,
FALSE
);
}
...
...
@@ -1548,7 +1556,7 @@ void linphone_call_init_video_stream(LinphoneCall *call){
int
video_recv_buf_size
=
lp_config_get_int
(
lc
->
config
,
"video"
,
"recv_buf_size"
,
0
);
int
dscp
=
linphone_core_get_video_dscp
(
lc
);
const
char
*
display_filter
=
linphone_core_get_video_display_filter
(
lc
);
if
(
call
->
sessions
[
1
].
rtp_session
==
NULL
){
call
->
videostream
=
video_stream_new
(
call
->
media_ports
[
1
].
rtp_port
,
call
->
media_ports
[
1
].
rtcp_port
,
call
->
af
==
AF_INET6
);
}
else
{
...
...
@@ -1956,7 +1964,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna
#ifdef VIDEO_ENABLED
LinphoneCore
*
lc
=
call
->
core
;
int
used_pt
=-
1
;
/* look for savp stream first */
const
SalStreamDescription
*
vstream
=
sal_media_description_find_stream
(
call
->
resultdesc
,
SalProtoRtpSavp
,
SalVideo
);
...
...
@@ -1978,8 +1986,9 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna
const
char
*
rtp_addr
=
vstream
->
rtp_addr
[
0
]
!=
'\0'
?
vstream
->
rtp_addr
:
call
->
resultdesc
->
addr
;
const
char
*
rtcp_addr
=
vstream
->
rtcp_addr
[
0
]
!=
'\0'
?
vstream
->
rtcp_addr
:
call
->
resultdesc
->
addr
;
const
SalStreamDescription
*
local_st_desc
=
sal_media_description_find_stream
(
call
->
localdesc
,
vstream
->
proto
,
SalVideo
);
call
->
video_profile
=
make_profile
(
call
,
call
->
resultdesc
,
vstream
,
&
used_pt
);
if
(
used_pt
!=-
1
){
VideoStreamDir
dir
=
VideoStreamSendRecv
;
MSWebCam
*
cam
=
lc
->
video_conf
.
device
;
...
...
@@ -2143,7 +2152,7 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript
SalStreamDescription
*
old_stream
;
SalStreamDescription
*
new_stream
;
const
SalStreamDescription
*
local_st_desc
;
local_st_desc
=
sal_media_description_find_stream
(
call
->
localdesc
,
SalProtoRtpSavp
,
SalAudio
);
old_stream
=
sal_media_description_find_stream
(
old_md
,
SalProtoRtpSavp
,
SalAudio
);
new_stream
=
sal_media_description_find_stream
(
new_md
,
SalProtoRtpSavp
,
SalAudio
);
...
...
@@ -2202,6 +2211,7 @@ static void linphone_call_log_fill_stats(LinphoneCallLog *log, MediaStream *st){
void
linphone_call_stop_audio_stream
(
LinphoneCall
*
call
)
{
if
(
call
->
audiostream
!=
NULL
)
{
linphone_reporting_update
(
call
,
LINPHONE_CALL_STATS_AUDIO
);
media_stream_reclaim_sessions
(
&
call
->
audiostream
->
ms
,
&
call
->
sessions
[
0
]);
rtp_session_unregister_event_queue
(
call
->
audiostream
->
ms
.
sessions
.
rtp_session
,
call
->
audiostream_app_evq
);
ortp_ev_queue_flush
(
call
->
audiostream_app_evq
);
...
...
@@ -2230,6 +2240,7 @@ void linphone_call_stop_audio_stream(LinphoneCall *call) {
void
linphone_call_stop_video_stream
(
LinphoneCall
*
call
)
{
#ifdef VIDEO_ENABLED
if
(
call
->
videostream
!=
NULL
){
linphone_reporting_update
(
call
,
LINPHONE_CALL_STATS_VIDEO
);
media_stream_reclaim_sessions
(
&
call
->
videostream
->
ms
,
&
call
->
sessions
[
1
]);
rtp_session_unregister_event_queue
(
call
->
videostream
->
ms
.
sessions
.
rtp_session
,
call
->
videostream_app_evq
);
ortp_ev_queue_flush
(
call
->
videostream_app_evq
);
...
...
@@ -2756,6 +2767,8 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
evd
->
packet
=
NULL
;
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
].
updated
=
LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE
;
update_local_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
],(
MediaStream
*
)
call
->
videostream
);
if
(
linphone_call_params_video_enabled
(
linphone_call_get_current_params
(
call
)))
linphone_reporting_call_stats_updated
(
call
,
LINPHONE_CALL_STATS_VIDEO
);
if
(
lc
->
vtable
.
call_stats_updated
)
lc
->
vtable
.
call_stats_updated
(
lc
,
call
,
&
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
]);
}
else
if
(
evt
==
ORTP_EVENT_RTCP_PACKET_EMITTED
)
{
...
...
@@ -2766,6 +2779,8 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
evd
->
packet
=
NULL
;
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
].
updated
=
LINPHONE_CALL_STATS_SENT_RTCP_UPDATE
;
update_local_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
],(
MediaStream
*
)
call
->
videostream
);
if
(
linphone_call_params_video_enabled
(
linphone_call_get_current_params
(
call
)))
linphone_reporting_call_stats_updated
(
call
,
LINPHONE_CALL_STATS_VIDEO
);
if
(
lc
->
vtable
.
call_stats_updated
)
lc
->
vtable
.
call_stats_updated
(
lc
,
call
,
&
call
->
stats
[
LINPHONE_CALL_STATS_VIDEO
]);
}
else
if
((
evt
==
ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED
)
||
(
evt
==
ORTP_EVENT_ICE_GATHERING_FINISHED
)
...
...
@@ -2801,6 +2816,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
evd
->
packet
=
NULL
;
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
].
updated
=
LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE
;
update_local_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
],(
MediaStream
*
)
call
->
audiostream
);
linphone_reporting_call_stats_updated
(
call
,
LINPHONE_CALL_STATS_AUDIO
);
if
(
lc
->
vtable
.
call_stats_updated
)
lc
->
vtable
.
call_stats_updated
(
lc
,
call
,
&
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
]);
}
else
if
(
evt
==
ORTP_EVENT_RTCP_PACKET_EMITTED
)
{
...
...
@@ -2811,6 +2827,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
evd
->
packet
=
NULL
;
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
].
updated
=
LINPHONE_CALL_STATS_SENT_RTCP_UPDATE
;
update_local_stats
(
&
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
],(
MediaStream
*
)
call
->
audiostream
);
linphone_reporting_call_stats_updated
(
call
,
LINPHONE_CALL_STATS_AUDIO
);
if
(
lc
->
vtable
.
call_stats_updated
)
lc
->
vtable
.
call_stats_updated
(
lc
,
call
,
&
call
->
stats
[
LINPHONE_CALL_STATS_AUDIO
]);
}
else
if
((
evt
==
ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED
)
||
(
evt
==
ORTP_EVENT_ICE_GATHERING_FINISHED
)
...
...
coreapi/linphonecore.c
View file @
ceb8533c
This diff is collapsed.
Click to expand it.
coreapi/linphonecore.h
View file @
ceb8533c
...
...
@@ -812,6 +812,17 @@ LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *o
LINPHONE_PUBLIC
void
linphone_proxy_config_set_dial_escape_plus
(
LinphoneProxyConfig
*
cfg
,
bool_t
val
);
LINPHONE_PUBLIC
void
linphone_proxy_config_set_dial_prefix
(
LinphoneProxyConfig
*
cfg
,
const
char
*
prefix
);
/**
* Indicates either or not, quality statistics during call should be stored and sent to a collector at termination.
* @param cfg #LinphoneProxyConfig object
* @param val if true, quality statistics publish will be stored and sent to the collector
*
*/
LINPHONE_PUBLIC
void
linphone_proxy_config_enable_statistics
(
LinphoneProxyConfig
*
cfg
,
bool_t
val
);
LINPHONE_PUBLIC
bool_t
linphone_proxy_config_send_statistics_enabled
(
LinphoneProxyConfig
*
cfg
);
LINPHONE_PUBLIC
void
linphone_proxy_config_set_statistics_collector
(
LinphoneProxyConfig
*
cfg
,
const
char
*
collector
);
LINPHONE_PUBLIC
const
char
*
linphone_proxy_config_get_statistics_collector
(
const
LinphoneProxyConfig
*
obj
);
/**
* Get the registration state of the given proxy config.
* @param[in] obj #LinphoneProxyConfig object.
...
...
coreapi/presence.c
View file @
ceb8533c
...
...
@@ -170,7 +170,7 @@ static time_t parse_timestamp(const char *timestamp) {
return
seconds
-
timezone
;
}
static
char
*
timestamp_to_string
(
time_t
timestamp
)
{
char
*
linphone_
timestamp_to_
rfc3339_
string
(
time_t
timestamp
)
{
char
timestamp_str
[
22
];
struct
tm
*
ret
;
#ifndef WIN32
...
...
@@ -1467,7 +1467,7 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
char
*
tmp
;
LinphoneAddress
*
uri
;
LinphoneProxyConfig
*
cfg
;
uri
=
linphone_address_new
(
from
);
linphone_address_clean
(
uri
);
tmp
=
linphone_address_as_string
(
uri
);
...
...
@@ -1482,7 +1482,7 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
}
}
}
/* check if we answer to this subscription */
if
(
linphone_find_friend_by_address
(
lc
->
friends
,
uri
,
&
lf
)
!=
NULL
){
lf
->
insub
=
op
;
...
...
@@ -1604,7 +1604,7 @@ static void write_xml_presence_note_obj(LinphonePresenceNote *note, struct _pres
static
int
write_xml_presence_timestamp
(
xmlTextWriterPtr
writer
,
time_t
timestamp
)
{
int
err
;
char
*
timestamp_str
=
timestamp_to_string
(
timestamp
);
char
*
timestamp_str
=
linphone_
timestamp_to_
rfc3339_
string
(
timestamp
);
err
=
xmlTextWriterWriteElement
(
writer
,
(
const
xmlChar
*
)
"timestamp"
,
(
const
xmlChar
*
)
timestamp_str
);
if
(
timestamp_str
)
ms_free
(
timestamp_str
);
return
err
;
...
...
coreapi/private.h
View file @
ceb8533c
...
...
@@ -34,6 +34,7 @@ extern "C" {
#include "linphonecore_utils.h"
#include "sal/sal.h"
#include "sipsetup.h"
#include "quality_reporting.h"
#include <belle-sip/object.h>
#include <belle-sip/dict.h>
...
...
@@ -115,6 +116,8 @@ struct _LinphoneCallLog{
float
quality
;
time_t
start_date_time
;
/**Start date of the call in seconds as expressed in a time_t */
char
*
call_id
;
/**unique id of a call*/
reporting_session_report_t
*
reports
[
2
];
/**<Quality statistics of the call (rfc6035) */
bool_t
video_enabled
;
};
...
...
@@ -191,6 +194,7 @@ struct _LinphoneCall
StunCandidate
ac
,
vc
;
/*audio video ip/port discovered by STUN*/
struct
_AudioStream
*
audiostream
;
/**/
struct
_VideoStream
*
videostream
;
MSAudioEndpoint
*
endpoint
;
/*used for conferencing*/
char
*
refer_to
;
LinphoneCallParams
params
;
...
...
@@ -399,6 +403,7 @@ struct _LinphoneProxyConfig
char
*
reg_proxy
;
char
*
reg_identity
;
char
*
reg_route
;
char
*
reg_statistics_collector
;
char
*
realm
;
char
*
contact_params
;
char
*
contact_uri_params
;
...
...
@@ -415,6 +420,7 @@ struct _LinphoneProxyConfig
bool_t
publish
;
bool_t
dial_escape_plus
;
bool_t
send_publish
;
bool_t
send_statistics
;
bool_t
pad
[
3
];
void
*
user_data
;
time_t
deletion_date
;
...
...
@@ -669,7 +675,7 @@ struct _LinphoneCore
bool_t
use_preview_window
;
time_t
network_last_check
;
bool_t
network_last_status
;
bool_t
ringstream_autorelease
;
bool_t
pad
[
2
];
...
...
@@ -804,6 +810,7 @@ void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *d
void
linphone_call_create_op
(
LinphoneCall
*
call
);
int
linphone_call_prepare_ice
(
LinphoneCall
*
call
,
bool_t
incoming_offer
);
void
linphone_core_notify_info_message
(
LinphoneCore
*
lc
,
SalOp
*
op
,
const
SalBody
*
body
);
void
linphone_content_uninit
(
LinphoneContent
*
obj
);
LinphoneContent
*
linphone_content_copy_from_sal_body
(
LinphoneContent
*
obj
,
const
SalBody
*
ref
);
SalBody
*
sal_body_from_content
(
SalBody
*
body
,
const
LinphoneContent
*
lc
);
SalReason
linphone_reason_to_sal
(
LinphoneReason
reason
);
...
...
@@ -852,11 +859,18 @@ char * linphone_get_xml_text_content(xmlparsing_context_t *xml_ctx, const char *
void
linphone_free_xml_text_content
(
const
char
*
text
);
xmlXPathObjectPtr
linphone_get_xml_xpath_object_for_node_list
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
);
/*****************************************************************************
* OTHER UTILITY FUNCTIONS *
****************************************************************************/
char
*
linphone_timestamp_to_rfc3339_string
(
time_t
timestamp
);
static
inline
const
LinphoneErrorInfo
*
linphone_error_info_from_sal_op
(
const
SalOp
*
op
){
if
(
op
==
NULL
)
return
(
LinphoneErrorInfo
*
)
sal_error_info_none
();
return
(
const
LinphoneErrorInfo
*
)
sal_op_get_error_info
(
op
);
}
/** Belle Sip-based objects need unique ids
*/
...
...
coreapi/proxy.c
View file @
ceb8533c
...
...
@@ -17,7 +17,7 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphonecore.h"
#include "sipsetup.h"
#include "lpconfig.h"
...
...
@@ -31,7 +31,7 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){
MSList
*
elem
;
int
i
;
if
(
!
linphone_core_ready
(
lc
))
return
;
for
(
elem
=
lc
->
sip_conf
.
proxies
,
i
=
0
;
elem
!=
NULL
;
elem
=
ms_list_next
(
elem
),
i
++
){
LinphoneProxyConfig
*
cfg
=
(
LinphoneProxyConfig
*
)
elem
->
data
;
linphone_proxy_config_write_to_config_file
(
lc
->
config
,
cfg
,
i
);
...
...
@@ -46,9 +46,10 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob
const
char
*
identity
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"reg_identity"
,
NULL
)
:
NULL
;
const
char
*
proxy
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"reg_proxy"
,
NULL
)
:
NULL
;
const
char
*
route
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"reg_route"
,
NULL
)
:
NULL
;
const
char
*
statistics_collector
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"reg_statistics_collector"
,
NULL
)
:
NULL
;
const
char
*
contact_params
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"contact_parameters"
,
NULL
)
:
NULL
;
const
char
*
contact_uri_params
=
lc
?
lp_config_get_default_string
(
lc
->
config
,
"proxy"
,
"contact_uri_parameters"
,
NULL
)
:
NULL
;
memset
(
obj
,
0
,
sizeof
(
LinphoneProxyConfig
));
obj
->
magic
=
linphone_proxy_config_magic
;
obj
->
expires
=
lc
?
lp_config_get_default_int
(
lc
->
config
,
"proxy"
,
"reg_expires"
,
3600
)
:
3600
;
...
...
@@ -59,6 +60,8 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob
obj
->
reg_identity
=
identity
?
ms_strdup
(
identity
)
:
NULL
;
obj
->
reg_proxy
=
proxy
?
ms_strdup
(
proxy
)
:
NULL
;
obj
->
reg_route
=
route
?
ms_strdup
(
route
)
:
NULL
;
obj
->
reg_statistics_collector
=
statistics_collector
?
ms_strdup
(
statistics_collector
)
:
NULL
;
obj
->
send_statistics
=
lc
?
lp_config_get_default_int
(
lc
->
config
,
"proxy"
,
"send_statistics"
,
0
)
:
0
;
obj
->
contact_params
=
contact_params
?
ms_strdup
(
contact_params
)
:
NULL
;
obj
->
contact_uri_params
=
contact_uri_params
?
ms_strdup
(
contact_uri_params
)
:
NULL
;
}
...
...
@@ -85,7 +88,7 @@ LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) {
/**
* Destroys a proxy config.
*
*
* @note: LinphoneProxyConfig that have been removed from LinphoneCore with
* linphone_core_remove_proxy_config() must not be freed.
**/
...
...
@@ -93,6 +96,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){
if
(
obj
->
reg_proxy
!=
NULL
)
ms_free
(
obj
->
reg_proxy
);
if
(
obj
->
reg_identity
!=
NULL
)
ms_free
(
obj
->
reg_identity
);
if
(
obj
->
reg_route
!=
NULL
)
ms_free
(
obj
->
reg_route
);
if
(
obj
->
reg_statistics_collector
!=
NULL
)
ms_free
(
obj
->
reg_statistics_collector
);
if
(
obj
->
ssctx
!=
NULL
)
sip_setup_context_free
(
obj
->
ssctx
);
if
(
obj
->
realm
!=
NULL
)
ms_free
(
obj
->
realm
);
if
(
obj
->
type
!=
NULL
)
ms_free
(
obj
->
type
);
...
...
@@ -123,10 +127,10 @@ bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj){
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
&&
strstr
(
server_addr
,
"sips:"
)
==
NULL
){
modified
=
ms_strdup_printf
(
"sip:%s"
,
server_addr
);
...
...
@@ -149,7 +153,7 @@ int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *
/**
* Sets the user identity as a SIP address.
*
* This identity is normally formed with display name, username and domain, such
* This identity is normally formed with display name, username and domain, such
* as:
* Alice <sip:alice@example.net>
* The REGISTER messages will have from and to set to this identity.
...
...
@@ -297,14 +301,14 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
LinphoneAddress
*
ret
=
NULL
;
LinphoneAddress
*
proxy
=
linphone_address_new
(
obj
->
reg_proxy
);
const
char
*
host
;
if
(
proxy
==
NULL
)
return
NULL
;
host
=
linphone_address_get_domain
(
proxy
);
if
(
host
!=
NULL
){
int
localport
=
-
1
;
const
char
*
localip
=
NULL
;
LinphoneAddress
*
contact
=
linphone_address_new
(
obj
->
reg_identity
);
linphone_address_clean
(
contact
);
if
(
obj
->
contact_params
)
{
...
...
@@ -374,7 +378,7 @@ void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){
/**
* Sets a dialing prefix to be automatically prepended when inviting a number with
* Sets a dialing prefix to be automatically prepended when inviting a number with
* linphone_core_invite();
* This dialing prefix shall usually be the country code of the country where the user is living.
*
...
...
@@ -390,7 +394,7 @@ void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char
/**
* Returns dialing prefix.
*
*
*
**/
const
char
*
linphone_proxy_config_get_dial_prefix
(
const
LinphoneProxyConfig
*
cfg
){
return
cfg
->
dial_prefix
;
...
...
@@ -413,6 +417,37 @@ void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t
bool_t
linphone_proxy_config_get_dial_escape_plus
(
const
LinphoneProxyConfig
*
cfg
){
return
cfg
->
dial_escape_plus
;
}
void
linphone_proxy_config_enable_statistics
(
LinphoneProxyConfig
*
cfg
,
bool_t
val
){
cfg
->
send_statistics
=
val
;
}
bool_t
linphone_proxy_config_send_statistics_enabled
(
LinphoneProxyConfig
*
cfg
){
// ensure that collector address is set too!
return
cfg
->
send_statistics
&&
cfg
->
reg_statistics_collector
!=
NULL
;
}
void
linphone_proxy_config_set_statistics_collector
(
LinphoneProxyConfig
*
cfg
,
const
char
*
collector
){
if
(
collector
!=
NULL
&&
strlen
(
collector
)
>
0
){
LinphoneAddress
*
addr
=
linphone_address_new
(
collector
);
if
(
!
addr
||
linphone_address_get_username
(
addr
)
==
NULL
){
ms_warning
(
"Invalid sip collector identity: %s"
,
collector
);
if
(
addr
)
linphone_address_destroy
(
addr
);
}
else
{
if
(
cfg
->
reg_statistics_collector
!=
NULL
)
ms_free
(
cfg
->
reg_statistics_collector
);
cfg
->
reg_statistics_collector
=
ms_strdup
(
collector
);
linphone_address_destroy
(
addr
);
}
}
}
const
char
*
linphone_proxy_config_get_statistics_collector
(
const
LinphoneProxyConfig
*
cfg
){
return
cfg
->
reg_statistics_collector
;
}
/*
* http://en.wikipedia.org/wiki/Telephone_numbering_plan
* http://en.wikipedia.org/wiki/Telephone_numbers_in_Europe
...
...
@@ -423,7 +458,7 @@ typedef struct dial_plan{
char
ccc
[
8
];
/*country calling code*/
int
nnl
;
/*maximum national number length*/
const
char
*
icp
;
/*international call prefix, ex: 00 in europe*/
}
dial_plan_t
;
/* TODO: fill with information for all countries over the world*/
...
...
@@ -708,7 +743,7 @@ static void lookup_dial_plan(const char *ccc, dial_plan_t *plan){
static
bool_t
is_a_phone_number
(
const
char
*
username
){
const
char
*
p
;
for
(
p
=
username
;
*
p
!=
'\0'
;
++
p
){
if
(
isdigit
(
*
p
)
||
if
(
isdigit
(
*
p
)
||
*
p
==
' '
||
*
p
==
'.'
||
*
p
==
'-'
||
...
...
@@ -736,12 +771,12 @@ static char *flatten_number(const char *number){
static
void
replace_plus
(
const
char
*
src
,
char
*
dest
,
size_t
destlen
,
const
char
*
icp
){
int
i
=
0
;
if
(
icp
&&
src
[
0
]
==
'+'
&&
(
destlen
>
(
i
=
strlen
(
icp
)))
){
src
++
;
strcpy
(
dest
,
icp
);
}
for
(;(
i
<
destlen
-
1
)
&&
*
src
!=
'\0'
;
++
i
){
dest
[
i
]
=*
src
;
src
++
;
...
...
@@ -756,7 +791,7 @@ int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const cha
char
*
flatten
;
flatten
=
flatten_number
(
username
);
ms_message
(
"Flattened number is '%s'"
,
flatten
);
if
(
proxy
->
dial_prefix
==
NULL
||
proxy
->
dial_prefix
[
0
]
==
'\0'
){
/*no prefix configured, nothing else to do*/
strncpy
(
result
,
flatten
,
result_len
);
...
...
@@ -824,7 +859,7 @@ void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char *realm
int
linphone_proxy_config_send_publish
(
LinphoneProxyConfig
*
proxy
,
LinphonePresenceModel
*
presence
){
int
err
=
0
;
if
(
proxy
->
state
==
LinphoneRegistrationOk
||
proxy
->
state
==
LinphoneRegistrationCleared
){
if
(
proxy
->
publish_op
==
NULL
){
proxy
->
publish_op
=
sal_op_new
(
proxy
->
lc
->
sal
);
...
...
@@ -1015,7 +1050,7 @@ void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *conf
lc
->
default_proxy
=
config
;
if
(
linphone_core_ready
(
lc
))
lp_config_set_int
(
lc
->
config
,
"sip"
,
"default_proxy"
,
linphone_core_get_default_proxy
(
lc
,
NULL
));
}
}
void
linphone_core_set_default_proxy_index
(
LinphoneCore
*
lc
,
int
index
){
if
(
index
<
0
)
linphone_core_set_default_proxy
(
lc
,
NULL
);
...
...
@@ -1059,6 +1094,9 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC
if
(
obj
->
reg_route
!=
NULL
){
lp_config_set_string
(
config
,
key
,
"reg_route"
,
obj
->
reg_route
);
}
if
(
obj
->
reg_statistics_collector
!=
NULL
){
lp_config_set_string
(
config
,
key
,
"reg_statistics_collector"
,
obj
->
reg_statistics_collector
);
}
if
(
obj
->
reg_identity
!=
NULL
){
lp_config_set_string
(
config
,
key
,
"reg_identity"
,
obj
->
reg_identity
);
}
...
...
@@ -1072,6 +1110,7 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC
lp_config_set_int
(
config
,
key
,
"reg_sendregister"
,
obj
->
reg_sendregister
);
lp_config_set_int
(
config
,
key
,
"publish"
,
obj
->
publish
);
lp_config_set_int
(
config
,
key
,
"dial_escape_plus"
,
obj
->
dial_escape_plus
);
lp_config_set_int
(
config
,
key
,
"send_statistics"
,
obj
->
send_statistics
);
lp_config_set_string
(
config
,
key
,
"dial_prefix"
,
obj
->
dial_prefix
);
lp_config_set_int
(
config
,
key
,
"privacy"
,
obj
->
privacy
);
}
...
...
@@ -1085,7 +1124,7 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
const
char
*
proxy
;
LinphoneProxyConfig
*
cfg
;
char
key
[
50
];
sprintf
(
key
,
"proxy_%i"
,
index
);
if
(
!
lp_config_has_section
(
config
,
key
)){
...
...
@@ -1094,29 +1133,33 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
cfg
=
linphone_proxy_config_new
();
identity
=
lp_config_get_string
(
config
,
key
,
"reg_identity"
,
NULL
);
identity
=
lp_config_get_string
(
config
,
key
,
"reg_identity"
,
NULL
);
proxy
=
lp_config_get_string
(
config
,
key
,
"reg_proxy"
,
NULL
);
linphone_proxy_config_set_identity
(
cfg
,
identity
);
linphone_proxy_config_set_server_addr
(
cfg
,
proxy
);
tmp
=
lp_config_get_string
(
config
,
key
,
"reg_route"
,
NULL
);
if
(
tmp
!=
NULL
)
linphone_proxy_config_set_route
(
cfg
,
tmp
);
tmp
=
lp_config_get_string
(
config
,
key
,
"reg_statistics_collector"
,
NULL
);
if
(
tmp
!=
NULL
)
linphone_proxy_config_set_statistics_collector
(
cfg
,
tmp
);
linphone_proxy_config_enable_statistics
(
cfg
,
lp_config_get_int
(
config
,
key
,
"send_statistics"
,
0
));
linphone_proxy_config_set_contact_parameters
(
cfg
,
lp_config_get_string
(
config
,
key
,
"contact_parameters"
,
NULL
));
linphone_proxy_config_set_contact_uri_parameters
(
cfg
,
lp_config_get_string
(
config
,
key
,
"contact_uri_parameters"
,
NULL
));
linphone_proxy_config_expires
(
cfg
,
lp_config_get_int
(
config
,
key
,
"reg_expires"
,
lp_config_get_default_int
(
config
,
"proxy"
,
"reg_expires"
,
600
)));
linphone_proxy_config_enableregister
(
cfg
,
lp_config_get_int
(
config
,
key
,
"reg_sendregister"
,
0
));
linphone_proxy_config_enable_publish
(
cfg
,
lp_config_get_int
(
config
,
key
,
"publish"
,
0
));
linphone_proxy_config_set_dial_escape_plus
(
cfg
,
lp_config_get_int
(
config
,
key
,
"dial_escape_plus"
,
lp_config_get_default_int
(
config
,
"proxy"
,
"dial_escape_plus"
,
0
)));
linphone_proxy_config_set_dial_prefix
(
cfg
,
lp_config_get_string
(
config
,
key
,
"dial_prefix"
,
lp_config_get_default_string
(
config
,
"proxy"
,
"dial_prefix"
,
NULL
)));
tmp
=
lp_config_get_string
(
config
,
key
,
"type"
,
NULL
);
if
(
tmp
!=
NULL
&&
strlen
(
tmp
)
>
0
)
if
(
tmp
!=
NULL
&&
strlen
(
tmp
)
>
0
)
linphone_proxy_config_set_sip_setup
(
cfg
,
tmp
);
linphone_proxy_config_set_privacy
(
cfg
,
lp_config_get_int
(
config
,
key
,
"privacy"
,
lp_config_get_default_int
(
config
,
"proxy"
,
"privacy"
,
LinphonePrivacyDefault
)));
...
...
@@ -1155,7 +1198,7 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){
ms_error
(
"Could not retrieve proxy uri !"
);