Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
005c28b9
Commit
005c28b9
authored
Jan 15, 2016
by
jehan
Browse files
remove symmetric ftp handling for stun packets because it’s now managed by rtp
parent
a4ad76a7
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/crypto/dtls_srtp.c
View file @
005c28b9
...
...
@@ -259,7 +259,6 @@ static bool_t ms_dtls_srtp_process_dtls_packet(mblk_t *msg, MSDtlsSrtpContext *c
DtlsRawPacket
*
incoming_dtls_packet
;
RtpSession
*
rtp_session
=
ctx
->
stream_sessions
->
rtp_session
;
OrtpStream
*
ortp_stream
=
is_rtp
?&
rtp_session
->
rtp
.
gs
:&
rtp_session
->
rtcp
.
gs
;
incoming_dtls_packet
=
(
DtlsRawPacket
*
)
ms_malloc0
(
sizeof
(
DtlsRawPacket
));
//DtlsRawPacket *incoming_dtls_packet = (DtlsRawPacket *)ms_malloc0(sizeof(DtlsRawPacket));
incoming_dtls_packet
->
next
=
NULL
;
...
...
@@ -268,17 +267,7 @@ static bool_t ms_dtls_srtp_process_dtls_packet(mblk_t *msg, MSDtlsSrtpContext *c
memcpy
(
incoming_dtls_packet
->
data
,
msg
->
b_rptr
,
msgLength
);
/*required by webrtc in server case when ice is not completed yet*/
if
(
!
rtp_session
->
use_connect
){
struct
sockaddr
*
addr
=
NULL
;
socklen_t
addrlen
;
addr
=
(
struct
sockaddr
*
)
&
msg
->
net_addr
;
addrlen
=
msg
->
net_addrlen
;
if
(
ortp_stream
->
socket
>
0
&&
rtp_session
->
symmetric_rtp
){
/* store the sender rtp address to do symmetric DTLS */
memcpy
(
&
ortp_stream
->
rem_addr
,
addr
,
addrlen
);
ortp_stream
->
rem_addrlen
=
addrlen
;
}
}
rtp_session_update_remote_sock_addr
(
rtp_session
,
msg
,
is_rtp
,
FALSE
);
ms_message
(
"DTLS Receive %s packet len %d sessions: %p rtp session %p ssl state is %x"
,
is_rtp
==
TRUE
?
"RTP"
:
"RTCP"
,
(
int
)
msgLength
,
ctx
->
stream_sessions
,
ctx
->
stream_sessions
->
rtp_session
,
ssl
->
state
);
...
...
src/otherfilters/msrtp.c
View file @
005c28b9
...
...
@@ -35,7 +35,8 @@ struct SenderData {
uint32_t
tsoff
;
uint32_t
last_ts
;
int64_t
last_sent_time
;
int64_t
last_stun_sent_time
;
int64_t
last_rtp_stun_sent_time
;
int64_t
last_rtcp_stun_sent_time
;
uint32_t
skip_until
;
int
rate
;
int
dtmf_duration
;
...
...
@@ -55,7 +56,7 @@ struct SenderData {
typedef
struct
SenderData
SenderData
;
/* Send dummy STUN packet to open NAT ports ASAP. */
static
void
send_stun_packet
(
RtpSession
*
s
)
static
void
send_stun_packet
(
RtpSession
*
s
,
bool_t
enable_rtp
,
bool_t
enable_rtcp
)
{
StunMessage
msg
;
mblk_t
*
mp
;
...
...
@@ -69,11 +70,20 @@ static void send_stun_packet(RtpSession *s)
stunBuildReqSimple
(
&
msg
,
NULL
,
FALSE
,
FALSE
,
1
);
len
=
stunEncodeMessage
(
&
msg
,
buf
,
len
,
NULL
);
if
(
len
>
0
)
{
mp
=
allocb
(
len
,
BPRI_MED
);
memcpy
(
mp
->
b_wptr
,
buf
,
len
);
mp
->
b_wptr
+=
len
;
ms_message
(
"Stun packet sent for session [%p]"
,
s
);
rtp_session_sendm_with_ts
(
s
,
mp
,
0
);
if
(
enable_rtp
)
{
mp
=
allocb
(
len
,
BPRI_MED
);
memcpy
(
mp
->
b_wptr
,
buf
,
len
);
mp
->
b_wptr
+=
len
;
ms_message
(
"Stun packet sent for session [%p]"
,
s
);
rtp_session_sendm_with_ts
(
s
,
mp
,
0
);
}
if
(
enable_rtcp
)
{
mp
=
allocb
(
len
,
BPRI_MED
);
memcpy
(
mp
->
b_wptr
,
buf
,
len
);
mp
->
b_wptr
+=
len
;
ms_message
(
"Stun packet sent on rtcp for session [%p]"
,
s
);
rtp_session_rtcp_sendm_raw
(
s
,
mp
);
}
}
}
...
...
@@ -97,7 +107,8 @@ static void sender_init(MSFilter * f)
d
->
relay_session_id_size
=
0
;
d
->
last_rsi_time
=
0
;
d
->
last_sent_time
=-
1
;
d
->
last_stun_sent_time
=
-
1
;
d
->
last_rtp_stun_sent_time
=
-
1
;
d
->
last_rtcp_stun_sent_time
=
-
1
;
d
->
last_ts
=
0
;
d
->
use_task
=
tmp
?
(
!!
atoi
(
tmp
))
:
FALSE
;
if
(
d
->
use_task
)
ms_message
(
"MSRtpSend will use tasks to send out packet at the beginning of ticks."
);
...
...
@@ -146,7 +157,7 @@ static int sender_set_session(MSFilter * f, void *arg)
d
->
rate
=
pt
->
clock_rate
;
d
->
dtmf_duration
=
(
default_dtmf_duration_ms
*
d
->
rate
)
/
1000
;
d
->
dtmf_ts_step
=
(
20
*
d
->
rate
)
/
1000
;
send_stun_packet
(
s
);
send_stun_packet
(
s
,
TRUE
,
TRUE
);
}
else
{
ms_warning
(
"Sending undefined payload type ?"
);
}
...
...
@@ -353,11 +364,17 @@ static int send_dtmf(MSFilter * f, uint32_t timestamp_start)
static
void
check_stun_sending
(
MSFilter
*
f
)
{
SenderData
*
d
=
(
SenderData
*
)
f
->
data
;
RtpSession
*
s
=
d
->
session
;
if
((
d
->
last_stun_sent_time
==
-
1
)
||
((
f
->
ticker
->
time
-
d
->
last_sent_time
>
2000
)
/*no need to send stun packets if media sent during last 2s*/
&&
(
f
->
ticker
->
time
-
d
->
last_stun_sent_time
)
>=
500
))
{
d
->
last_stun_sent_time
=
f
->
ticker
->
time
;
send_stun_packet
(
s
);
if
((
d
->
last_rtp_stun_sent_time
==
-
1
)
||
((
f
->
ticker
->
time
-
d
->
last_sent_time
>
2000
)
/*no need to send stun packets if media sent during last 2s*/
&&
(
f
->
ticker
->
time
-
d
->
last_rtp_stun_sent_time
)
>=
500
))
{
d
->
last_rtp_stun_sent_time
=
f
->
ticker
->
time
;
send_stun_packet
(
s
,
TRUE
,
FALSE
);
}
if
(
rtp_session_rtcp_enabled
(
s
)
&&
(
d
->
last_rtcp_stun_sent_time
==
-
1
||
(
rtp_session_get_stats
(
s
)
->
recv_rtcp_packets
==
0
/*no need to send stun packets if rtcp packet already received*/
&&
(
f
->
ticker
->
time
-
d
->
last_rtcp_stun_sent_time
)
>=
500
)))
{
d
->
last_rtcp_stun_sent_time
=
f
->
ticker
->
time
;
send_stun_packet
(
s
,
FALSE
,
TRUE
);
}
}
...
...
src/voip/mediastream.c
View file @
005c28b9
...
...
@@ -257,16 +257,7 @@ bool_t ms_is_ipv6(const char *remote) {
}
bool_t
ms_is_multicast_addr
(
const
struct
sockaddr
*
addr
)
{
switch
(
addr
->
sa_family
)
{
case
AF_INET
:
return
IN_MULTICAST
(
ntohl
(((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
));
case
AF_INET6
:
return
IN6_IS_ADDR_MULTICAST
(
&
(((
struct
sockaddr_in6
*
)
addr
)
->
sin6_addr
));
default:
return
FALSE
;
}
return
ortp_is_multicast_addr
(
addr
);
}
bool_t
ms_is_multicast
(
const
char
*
address
)
{
...
...
@@ -331,18 +322,8 @@ void media_stream_iterate(MediaStream *stream){
ms_message
(
"%s_stream_iterate[%p], local statistics available:"
"
\n\t
Local current jitter buffer size: %5.1fms"
,
media_stream_type_str
(
stream
),
stream
,
rtp_session_get_jitter_stats
(
stream
->
sessions
.
rtp_session
)
->
jitter_buffer_size_ms
);
}
else
if
(
evt
==
ORTP_EVENT_STUN_PACKET_RECEIVED
){
if
(
stream
->
ice_check_list
)
{
ice_handle_stun_packet
(
stream
->
ice_check_list
,
stream
->
sessions
.
rtp_session
,
ortp_event_get_data
(
ev
));
}
else
if
(
rtp_session_get_symmetric_rtp
(
stream
->
sessions
.
rtp_session
)){
/*try to know if we can trust stun packets for symetric rtp*/
rtp_stats_t
stats
;
media_stream_get_local_rtp_stats
(
stream
,
&
stats
);
if
(
stats
.
packet_recv
==
0
&&
!
ms_is_multicast_addr
((
const
struct
sockaddr
*
)
&
stream
->
sessions
.
rtp_session
->
rtp
.
gs
.
rem_addr
))
{
memcpy
(
&
stream
->
sessions
.
rtp_session
->
rtp
.
gs
.
rem_addr
,
&
ortp_event_get_data
(
ev
)
->
source_addr
,
ortp_event_get_data
(
ev
)
->
source_addrlen
);
ms_message
(
"stun packet received but no rtp yet for stream [%p], switching rtp destination address"
,
stream
);
}
}
}
else
if
(
evt
==
ORTP_EVENT_STUN_PACKET_RECEIVED
&&
stream
->
ice_check_list
){
ice_handle_stun_packet
(
stream
->
ice_check_list
,
stream
->
sessions
.
rtp_session
,
ortp_event_get_data
(
ev
));
}
else
if
((
evt
==
ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED
)
||
(
evt
==
ORTP_EVENT_DTLS_ENCRYPTION_CHANGED
))
{
ms_message
(
"%s_stream_iterate[%p]: is %s "
,
media_stream_type_str
(
stream
)
,
stream
,
media_stream_secured
(
stream
)
?
"encrypted"
:
"not encrypted"
);
}
...
...
src/voip/qosanalyzer.c
View file @
005c28b9
...
...
@@ -172,7 +172,7 @@ static bool_t simple_analyzer_process_rtcp(MSQosAnalyzer *objbase, mblk_t *rtcp)
if
(
pt
!=
NULL
)
obj
->
clockrate
=
pt
->
clock_rate
;
else
return
FALSE
;
}
if
(
ortp_loss_rate_estimator_process_report_block
(
objbase
->
lre
,
&
obj
->
session
->
rtp
,
rb
)){
if
(
ortp_loss_rate_estimator_process_report_block
(
objbase
->
lre
,
obj
->
session
,
rb
)){
cur
->
lost_percentage
=
ortp_loss_rate_estimator_get_value
(
objbase
->
lre
);
cur
->
int_jitter
=
1000
.
0
f
*
(
float
)
report_block_get_interarrival_jitter
(
rb
)
/
(
float
)
obj
->
clockrate
;
cur
->
rt_prop
=
rtp_session_get_round_trip_propagation
(
obj
->
session
);
...
...
@@ -350,7 +350,7 @@ static bool_t stateful_analyzer_process_rtcp(MSQosAnalyzer *objbase, mblk_t *rtc
if
(
rb
&&
report_block_get_ssrc
(
rb
)
==
rtp_session_get_send_ssrc
(
obj
->
session
)){
if
(
ortp_loss_rate_estimator_process_report_block
(
objbase
->
lre
,
&
obj
->
session
->
rtp
,
rb
)){
if
(
ortp_loss_rate_estimator_process_report_block
(
objbase
->
lre
,
obj
->
session
,
rb
)){
int
i
;
float
loss_rate
=
ortp_loss_rate_estimator_get_value
(
objbase
->
lre
);
float
up_bw
=
stateful_qos_analyzer_upload_bandwidth
(
obj
,
report_block_get_high_ext_seq
(
rb
));
...
...
src/voip/qualityindicator.c
View file @
005c28b9
...
...
@@ -139,7 +139,7 @@ void ms_quality_indicator_update_from_feedback(MSQualityIndicator *qi, mblk_t *r
float
rt_prop
=
rtp_session_get_round_trip_propagation
(
qi
->
session
);
bool_t
new_value
;
new_value
=
ortp_loss_rate_estimator_process_report_block
(
qi
->
lr_estimator
,
&
qi
->
session
->
rtp
,
rb
);
new_value
=
ortp_loss_rate_estimator_process_report_block
(
qi
->
lr_estimator
,
qi
->
session
,
rb
);
loss_rate
=
ortp_loss_rate_estimator_get_value
(
qi
->
lr_estimator
);
qi
->
remote_rating
=
compute_rating
(
loss_rate
/
100
.
0
f
,
inter_jitter
,
0
,
rt_prop
);
qi
->
remote_lq_rating
=
compute_lq_rating
(
loss_rate
/
100
.
0
f
,
inter_jitter
,
0
);
...
...
tester/mediastreamer2_adaptive_tester.c
View file @
005c28b9
...
...
@@ -305,7 +305,7 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
rb
=
rtcp_RR_get_report_block
(
evd
->
packet
,
0
);
}
if
(
rb
&&
ortp_loss_rate_estimator_process_report_block
(
ctx
->
estimator
,
&
ms
->
sessions
.
rtp_session
->
rtp
,
rb
)){
if
(
rb
&&
ortp_loss_rate_estimator_process_report_block
(
ctx
->
estimator
,
ms
->
sessions
.
rtp_session
,
rb
)){
float
diff
=
fabs
(
ortp_loss_rate_estimator_get_value
(
ctx
->
estimator
)
-
ctx
->
loss_rate
);
BC_ASSERT_TRUE
(
diff
>=
0
);
BC_ASSERT_TRUE
(
diff
<=
10
);
...
...
tester/mediastreamer2_audio_stream_tester.c
View file @
005c28b9
...
...
@@ -117,12 +117,19 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
}
}
static
void
basic_audio_stream_base
(
const
char
*
marielle_local_ip
,
int
marielle_local_rtp_port
,
int
marielle_local_rtcp_port
,
const
char
*
margaux_local_ip
,
int
margaux_local_rtp_port
,
int
margaux_local_rtcp_port
)
{
static
void
basic_audio_stream_base_2
(
const
char
*
marielle_local_ip
,
const
char
*
marielle_remote_ip
,
int
marielle_local_rtp_port
,
int
marielle_remote_rtp_port
,
int
marielle_local_rtcp_port
,
int
marielle_remote_rtcp_port
,
const
char
*
margaux_local_ip
,
const
char
*
margaux_remote_ip
,
int
margaux_local_rtp_port
,
int
margaux_remote_rtp_port
,
int
margaux_local_rtcp_port
,
int
margaux_remote_rtcp_port
,
int
lost_percentage
)
{
AudioStream
*
marielle
=
audio_stream_new2
(
marielle_local_ip
,
marielle_local_rtp_port
,
marielle_local_rtcp_port
);
stats_t
marielle_stats
;
AudioStream
*
margaux
=
audio_stream_new2
(
margaux_local_ip
,
margaux_local_rtp_port
,
margaux_local_rtcp_port
);
...
...
@@ -131,9 +138,13 @@ static void basic_audio_stream_base( const char* marielle_local_ip
char
*
hello_file
=
bc_tester_res
(
HELLO_8K_1S_FILE
);
char
*
recorded_file
=
bc_tester_file
(
RECORDED_8K_1S_FILE
);
int
marielle_rtp_sent
=
0
;
const
jitter_stats_t
*
jitter_stats
;
rtp_session_set_multicast_loopback
(
marielle
->
ms
.
sessions
.
rtp_session
,
TRUE
);
rtp_session_set_multicast_loopback
(
margaux
->
ms
.
sessions
.
rtp_session
,
TRUE
);
rtp_session_set_rtcp_report_interval
(
marielle
->
ms
.
sessions
.
rtp_session
,
1000
);
rtp_session_set_rtcp_report_interval
(
margaux
->
ms
.
sessions
.
rtp_session
,
1000
);
reset_stats
(
&
marielle_stats
);
reset_stats
(
&
margaux_stats
);
...
...
@@ -142,10 +153,10 @@ static void basic_audio_stream_base( const char* marielle_local_ip
BC_ASSERT_EQUAL
(
audio_stream_start_full
(
margaux
,
profile
,
ms_is_multicast
(
margaux_local_ip
)
?
margaux_local_ip
:
mar
ielle_local
_ip
,
ms_is_multicast
(
margaux_local_ip
)
?
margaux_local_rtp_port
:
mar
ielle_local
_rtp_port
,
mar
ielle_local
_ip
,
mar
ielle_local
_rtcp_port
,
ms_is_multicast
(
margaux_local_ip
)
?
margaux_local_ip
:
mar
gaux_remote
_ip
,
ms_is_multicast
(
margaux_local_ip
)
?
margaux_local_rtp_port
:
mar
gaux_remote
_rtp_port
,
mar
gaux_remote
_ip
,
mar
gaux_remote
_rtcp_port
,
0
,
50
,
NULL
...
...
@@ -157,10 +168,10 @@ static void basic_audio_stream_base( const char* marielle_local_ip
BC_ASSERT_EQUAL
(
audio_stream_start_full
(
marielle
,
profile
,
mar
gaux_local
_ip
,
mar
gaux_local
_rtp_port
,
mar
gaux_local
_ip
,
mar
gaux_local
_rtcp_port
,
mar
ielle_remote
_ip
,
mar
ielle_remote
_rtp_port
,
mar
ielle_remote
_ip
,
mar
ielle_remote
_rtcp_port
,
0
,
50
,
hello_file
...
...
@@ -177,10 +188,17 @@ static void basic_audio_stream_base( const char* marielle_local_ip
audio_stream_get_local_rtp_stats
(
marielle
,
&
marielle_stats
.
rtp
);
audio_stream_get_local_rtp_stats
(
margaux
,
&
margaux_stats
.
rtp
);
marielle_rtp_sent
=
marielle_stats
.
rtp
.
sent
;
jitter_stats
=
rtp_session_get_jitter_stats
(
margaux
->
ms
.
sessions
.
rtp_session
);
if
(
rtp_session_rtcp_enabled
(
marielle
->
ms
.
sessions
.
rtp_session
)
&&
rtp_session_rtcp_enabled
(
margaux
->
ms
.
sessions
.
rtp_session
))
{
BC_ASSERT_TRUE
(
rtp_session_get_round_trip_propagation
(
marielle
->
ms
.
sessions
.
rtp_session
)
>
0
);
BC_ASSERT_TRUE
(
rtp_session_get_stats
(
marielle
->
ms
.
sessions
.
rtp_session
)
->
recv_rtcp_packets
>
0
);
}
audio_stream_stop
(
marielle
);
/* No packet loss is assumed */
wait_for_until
(
&
margaux
->
ms
,
NULL
,(
int
*
)
&
margaux_stats
.
rtp
.
hw_recv
,
marielle_rtp_sent
,
2500
);
BC_ASSERT_TRUE
(
wait_for_until
(
&
margaux
->
ms
,
NULL
,(
int
*
)
&
margaux_stats
.
rtp
.
hw_recv
,
marielle_rtp_sent
*
(
100
-
lost_percentage
)
/
100
,
2500
)
)
;
audio_stream_stop
(
margaux
);
...
...
@@ -189,7 +207,27 @@ static void basic_audio_stream_base( const char* marielle_local_ip
free
(
hello_file
);
rtp_profile_destroy
(
profile
);
}
static
void
basic_audio_stream_base
(
const
char
*
marielle_local_ip
,
int
marielle_local_rtp_port
,
int
marielle_local_rtcp_port
,
const
char
*
margaux_local_ip
,
int
margaux_local_rtp_port
,
int
margaux_local_rtcp_port
)
{
basic_audio_stream_base_2
(
marielle_local_ip
,
margaux_local_ip
,
marielle_local_rtp_port
,
margaux_local_rtp_port
,
marielle_local_rtcp_port
,
margaux_local_rtcp_port
,
margaux_local_ip
,
marielle_local_ip
,
margaux_local_rtp_port
,
marielle_local_rtp_port
,
margaux_local_rtcp_port
,
marielle_local_rtcp_port
,
0
);
}
static
void
basic_audio_stream
(
void
)
{
basic_audio_stream_base
(
MARIELLE_IP
,
MARIELLE_RTP_PORT
,
MARIELLE_RTCP_PORT
,
MARGAUX_IP
,
MARGAUX_RTP_PORT
,
MARGAUX_RTCP_PORT
);
...
...
@@ -551,6 +589,40 @@ static void audio_stream_dtmf(int codec_payload, int initial_bitrate,int target_
}
#endif
static
void
symetric_rtp_with_wrong_addr
(
void
)
{
basic_audio_stream_base_2
(
MARIELLE_IP
,
"10.10.10.10"
/*dummy ip*/
,
MARIELLE_RTP_PORT
,
MARGAUX_RTP_PORT
,
MARIELLE_RTCP_PORT
,
MARGAUX_RTCP_PORT
,
MARGAUX_IP
,
MARIELLE_IP
,
MARGAUX_RTP_PORT
,
MARIELLE_RTP_PORT
,
MARGAUX_RTCP_PORT
,
MARIELLE_RTCP_PORT
,
5
);
}
static
void
symetric_rtp_with_wrong_rtcp_port
(
void
)
{
basic_audio_stream_base_2
(
MARIELLE_IP
,
MARGAUX_IP
,
MARIELLE_RTP_PORT
,
MARGAUX_RTP_PORT
,
MARIELLE_RTCP_PORT
,
MARGAUX_RTCP_PORT
,
MARGAUX_IP
,
MARIELLE_IP
,
MARGAUX_RTP_PORT
,
MARIELLE_RTP_PORT
,
MARGAUX_RTCP_PORT
,
MARIELLE_RTCP_PORT
+
10
/*dummy port*/
,
5
);
}
static
test_t
tests
[]
=
{
{
"Basic audio stream"
,
basic_audio_stream
},
...
...
@@ -563,7 +635,9 @@ static test_t tests[] = {
{
"Encrypted audio stream, encryption mandatory"
,
encrypted_audio_stream_encryption_mandatory
},
{
"Encrypted audio stream with key change + encryption mandatory"
,
encrypted_audio_stream_with_key_change_encryption_mandatory
},
{
"Codec change for audio stream"
,
codec_change_for_audio_stream
},
{
"TMMBR feedback for audio stream"
,
tmmbr_feedback_for_audio_stream
}
{
"TMMBR feedback for audio stream"
,
tmmbr_feedback_for_audio_stream
},
{
"Symetric rtp with wrong address"
,
symetric_rtp_with_wrong_addr
},
{
"Symetric rtp with wrong rtcp port"
,
symetric_rtp_with_wrong_rtcp_port
},
};
test_suite_t
audio_stream_test_suite
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment