From eacc9b92a15d541761ee6f77f9cdcf4983553bfe Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 30 Jan 2014 21:01:35 +0100 Subject: mgcp/rtp: Compute delta timestamp based on wallclock Currently, when the SSRC changes within a stream and SSRC fixing is enabled, the RTP timestamp between the last packet that has been received with the old SSRC and the first packet of the new SSRC is always incremented by one packet duration. This can lead to audio muting (at least with the nanoBTS) when the wallclock interval between these packets is too large (> 1s). This patch changes the implementation to base the RTP timestamp offset on the wallclock interval that has passed between these two packets. Ticket: OW#466 Sponsored-by: On-Waves ehf --- openbsc/src/libmgcp/mgcp_network.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'openbsc/src/libmgcp/mgcp_network.c') diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 39d58073d..5363fb8de 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -415,10 +415,17 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta state->in_stream.ssrc = ssrc; if (rtp_end->force_constant_ssrc) { - const int16_t delta_seq = 1; + int16_t delta_seq; + /* Always increment seqno by 1 */ state->seq_offset = - (state->out_stream.last_seq + delta_seq) - seq; + (state->out_stream.last_seq + 1) - seq; + + /* Estimate number of packets that would have been sent */ + delta_seq = + (arrival_time - state->in_stream.last_arrival_time + + state->packet_duration/2) / + state->packet_duration; adjust_rtp_timestamp_offset(endp, state, rtp_end, addr, delta_seq, timestamp); @@ -452,6 +459,7 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta /* Save before patching */ state->in_stream.last_timestamp = timestamp; state->in_stream.last_seq = seq; + state->in_stream.last_arrival_time = arrival_time; if (rtp_end->force_aligned_timing && state->out_stream.ssrc == ssrc && state->packet_duration) -- cgit v1.2.3