Commit 672d511d authored by Simon Morlat's avatar Simon Morlat

fix loss rate simulator, ensure that in permissive mode packets are always given in order

parent e3c89164
......@@ -91,6 +91,9 @@ typedef struct jitter_stats
#define RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(ts1,ts2) \
( ((uint32_t)((uint32_t)(ts1) - (uint32_t)(ts2))< (uint32_t)(1<<31)) && (ts1)!=(ts2) )
#define RTP_SEQ_IS_STRICTLY_GREATER_THAN(seq1,seq2)\
(((uint16_t)((uint16_t)(seq1) - (uint16_t)(seq2))< (uint16_t)(1<<15)) && (seq1!=seq2))
#define TIME_IS_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_NEWER_THAN(t1,t2)
#define TIME_IS_STRICTLY_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(t1,t2)
......
......@@ -271,6 +271,8 @@ typedef struct _RtpStream
uint32_t rcv_ts_offset; /* the first stream timestamp */
uint32_t rcv_query_ts_offset; /* the first user timestamp asked by the application */
uint32_t rcv_last_ts; /* the last stream timestamp got by the application */
uint16_t rcv_last_seq; /* the last stream sequence number got by the application*/
uint16_t pad;
uint32_t rcv_last_app_ts; /* the last application timestamp asked by the application */
uint32_t rcv_last_ret_ts; /* the timestamp of the last sample returned (only for continuous audio)*/
uint32_t hwrcv_extseq; /* last received on socket extended sequence number */
......
......@@ -223,7 +223,9 @@ static mblk_t *simulate_loss_rate(OrtpNetworkSimulatorCtx *net_sim_ctx, mblk_t *
net_sim_ctx->drops_to_ignore--;
return input;
}
net_sim_ctx->consecutive_drops++;
if (net_sim_ctx->params.consecutive_loss_probability>0){
net_sim_ctx->consecutive_drops++;
}
net_sim_ctx->drop_by_loss++;
freemsg(input);
return NULL;
......
......@@ -208,7 +208,6 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
session->inc_ssrc_candidate=rtp->ssrc;
}
if (session->inc_same_ssrc_count>=session->rtp.ssrc_changed_thres){
/* store the sender rtp address to do symmetric RTP */
if (!session->use_connect){
if (session->rtp.gs.socket>0 && session->symmetric_rtp){
......@@ -298,8 +297,10 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
ortp_debug("rtp_parse: timestamp jump?");
rtp_signal_table_emit2(&session->on_timestamp_jump,(long)&rtp->timestamp);
}
else if (RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(session->rtp.rcv_last_ts,rtp->timestamp)){
/* don't queue packets older than the last returned packet to the application*/
else if (RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(session->rtp.rcv_last_ts,rtp->timestamp)
|| RTP_SEQ_IS_STRICTLY_GREATER_THAN(session->rtp.rcv_last_seq,rtp->seq_number)){
/* don't queue packets older than the last returned packet to the application, or whose sequence number
is behind the last packet returned to the application*/
/* Call timstamp jumb in case of
* large negative Ts jump or if ts is set to 0
*/
......
......@@ -95,9 +95,6 @@ static uint32_t uint32_t_random(){
}
#define RTP_SEQ_IS_GREATER(seq1,seq2)\
((uint16_t)((uint16_t)(seq1) - (uint16_t)(seq2))< (uint16_t)(1<<15))
/* put an rtp packet in queue. It is called by rtp_parse()
A return value of -1 means the packet was a duplicate, 0 means the packet was ok */
int rtp_putq(queue_t *q, mblk_t *mp)
......@@ -126,7 +123,7 @@ int rtp_putq(queue_t *q, mblk_t *mp)
ortp_debug("rtp_putq: duplicated message.");
freemsg(mp);
return -1;
}else if (RTP_SEQ_IS_GREATER(rtp->seq_number,tmprtp->seq_number)){
}else if (RTP_SEQ_IS_STRICTLY_GREATER_THAN(rtp->seq_number,tmprtp->seq_number)){
insq(q,tmp->b_next,mp);
return 0;
......@@ -1157,7 +1154,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
goto end;
end:
end:
if (mp != NULL)
{
int msgsize = msgdsize (mp); /* evaluate how much bytes (including header) is received by app */
......@@ -1185,6 +1182,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
/*ortp_debug("Returned packet has timestamp %u, with clock slide compensated it is %u",packet_ts,rtp->timestamp);*/
}
session->rtp.rcv_last_ts = packet_ts;
session->rtp.rcv_last_seq = rtp->seq_number;
if (!(session->flags & RTP_SESSION_FIRST_PACKET_DELIVERED)){
rtp_session_set_flag(session,RTP_SESSION_FIRST_PACKET_DELIVERED);
}
......@@ -1567,6 +1565,7 @@ void rtp_session_reset (RtpSession * session)
session->rtp.rcv_ts_offset = 0;
session->rtp.rcv_query_ts_offset = 0;
session->rtp.rcv_last_ts = 0;
session->rtp.rcv_last_seq = 0;
session->rtp.rcv_last_app_ts = 0;
session->rtp.hwrcv_extseq = 0;
session->rtp.hwrcv_since_last_SR=0;
......
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