aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_network.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-01-30 21:01:35 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-31 11:44:16 +0100
commiteacc9b92a15d541761ee6f77f9cdcf4983553bfe (patch)
tree36a313180719ff6e51698a1c292bb27622007f41 /openbsc/src/libmgcp/mgcp_network.c
parent303b54a2a42bfcd6d2dd509c6e092899e3c6a85b (diff)
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
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_network.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index 39d5807..5363fb8 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)