aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_network.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-05 11:33:20 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-10 11:13:22 +0100
commitb35a77751b278c7c81e6cc012df2d113f10b3116 (patch)
tree34041c38cf431395905bdeb0793807aa8ff4bf48 /openbsc/src/libmgcp/mgcp_network.c
parent5e9549e6a968fa0b5ef313a3e5a2622ceff42839 (diff)
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
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_network.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index d19b56e..c14b913 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 {