From b35a77751b278c7c81e6cc012df2d113f10b3116 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 5 Dec 2013 11:33:20 +0100 Subject: mgcp/rtp: Only update RTP header field offsets if enabled Currently seq_offset and timestamp_offset are updated on each SSRC change even when SSRC patching is not allowed. This patch fixes this by changing mgcp_patch_and_count() to only update these fields when SSRC patching is allowed. Sponsored-by: On-Waves ehf --- openbsc/src/libmgcp/mgcp_network.c | 44 ++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 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 d19b56e4c..c14b9133b 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -248,8 +248,6 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta inet_ntoa(addr->sin_addr), ntohs(addr->sin_port), endp->conn_mode); } else if (state->in_stream.ssrc != rtp_hdr->ssrc) { - int32_t tsdelta = state->out_stream.last_tsdelta; - LOGP(DMGCP, LOGL_NOTICE, "The SSRC changed on 0x%x: %u -> %u " "from %s:%d in %d\n", @@ -258,22 +256,36 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta inet_ntoa(addr->sin_addr), ntohs(addr->sin_port), endp->conn_mode); - if (tsdelta == 0) { - tsdelta = rtp_end->rate * rtp_end->frames_per_packet * - rtp_end->frame_duration_num / - rtp_end->frame_duration_den; + state->in_stream.ssrc = rtp_hdr->ssrc; + if (rtp_end->force_constant_ssrc) { + int32_t tsdelta = state->out_stream.last_tsdelta; + if (tsdelta == 0) { + tsdelta = rtp_end->rate * rtp_end->frames_per_packet * + rtp_end->frame_duration_num / + rtp_end->frame_duration_den; + LOGP(DMGCP, LOGL_NOTICE, + "Computed timestamp delta %d based on " + "rate %d, num frames %d, frame duration %d/%d\n", + tsdelta, rtp_end->rate, rtp_end->frames_per_packet, + rtp_end->frame_duration_num, + rtp_end->frame_duration_den); + } + state->seq_offset = + (state->out_stream.last_seq + 1) - seq; + state->timestamp_offset = + (state->out_stream.last_timestamp + tsdelta) - + timestamp; + state->patch = 1; + LOGP(DMGCP, LOGL_NOTICE, - "Computed timestamp delta %d based on " - "rate %d, num frames %d, frame duration %d/%d\n", - tsdelta, rtp_end->rate, rtp_end->frames_per_packet, - rtp_end->frame_duration_num, - rtp_end->frame_duration_den); + "SSRC patching enabled on 0x%x SSRC: %u " + "offset: %d tsdelta: %d " + "from %s:%d in %d\n", + ENDPOINT_NUMBER(endp), state->in_stream.ssrc, + state->seq_offset, tsdelta, + inet_ntoa(addr->sin_addr), ntohs(addr->sin_port), + endp->conn_mode); } - state->in_stream.ssrc = rtp_hdr->ssrc; - state->seq_offset = (state->out_stream.last_seq + 1) - seq; - state->timestamp_offset = - (state->out_stream.last_timestamp + tsdelta) - timestamp; - state->patch = rtp_end->force_constant_ssrc; state->in_stream.last_tsdelta = 0; } else { -- cgit v1.2.3